-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorder eager extension activation #176706
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea very much. But here's a different way to tackle it:
- the extension host receives startup related activation requests via
AbstractExtHostExtensionService.$activateByEvent
- from debugging this locally, all file system activation events are already received there, they're all just waiting on the
readyToRunExtensions
barrier - we could open the barrier and then wait for all activation events to finish and only then do the eager activation events (
*
,workspaceContains
, etc). - this would allow to avoid having a special case for filesystems, and it would work for all kinds of startup related activation events.
- we should test this, I only tried it locally, not on the web.
Here's a change that could be applied on main
to get what I describe:
diff --git a/src/vs/workbench/api/common/extHostExtensionActivator.ts b/src/vs/workbench/api/common/extHostExtensionActivator.ts
index 47f20ca08dd..26c8795aaa6 100644
--- a/src/vs/workbench/api/common/extHostExtensionActivator.ts
+++ b/src/vs/workbench/api/common/extHostExtensionActivator.ts
@@ -193,6 +193,14 @@ export class ExtensionsActivator implements IDisposable {
}
}
+ public async waitForActivatingExtensions(): Promise<void> {
+ const res: Promise<boolean>[] = [];
+ for (const [_, op] of this._operations) {
+ res.push(op.wait());
+ }
+ await Promise.all(res);
+ }
+
public isActivated(extensionId: ExtensionIdentifier): boolean {
const op = this._operations.get(extensionId);
return Boolean(op && op.value);
diff --git a/src/vs/workbench/api/common/extHostExtensionService.ts b/src/vs/workbench/api/common/extHostExtensionService.ts
index 0b0dba8355b..afe2939e5b8 100644
--- a/src/vs/workbench/api/common/extHostExtensionService.ts
+++ b/src/vs/workbench/api/common/extHostExtensionService.ts
@@ -756,6 +756,10 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
return this._readyToStartExtensionHost.wait()
.then(() => this._readyToRunExtensions.open())
+ .then(() => {
+ // wait for all activation events that came in during workbench startup, but at maximum 1s
+ return Promise.race([this._activator.waitForActivatingExtensions(), timeout(1000)]);
+ })
.then(() => this._handleEagerExtensions())
.then(() => {
this._eagerExtensionsActivated.open();
@alexdima I just tried this out https://insiders.vscode.dev/github/microsoft/vscode?vscode-version=9402aef94bbb84354fe22b3455a13750be79e3f5 and it seems to work well in web and remote. Thank you for the pointer! |
For #171135
In local testing (launch VS Code then open
Developer: Startup Performance
this exhibits a mild reduction in the time tocode/didStartWorkbench
. I'd like to get some additional validation in insiders for whether this makes a difference e.g. with the perf bot.