Skip to content
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

perf - update window jump list in new phase Eventually #159536

Merged
merged 1 commit into from Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/vs/code/electron-main/app.ts
Expand Up @@ -109,6 +109,7 @@ import { ExtensionsProfileScannerService, IExtensionsProfileScannerService } fro
import { IExtensionsScannerService } from 'vs/platform/extensionManagement/common/extensionsScannerService';
import { ExtensionsScannerService } from 'vs/platform/extensionManagement/node/extensionsScannerService';
import { UserDataTransientProfilesHandler } from 'vs/platform/userDataProfile/electron-main/userDataTransientProfilesHandler';
import { RunOnceScheduler, runWhenIdle } from 'vs/base/common/async';

/**
* The main VS Code application. There will only ever be one instance,
Expand Down Expand Up @@ -555,9 +556,16 @@ export class CodeApplication extends Disposable {
if (this.environmentMainService.args.trace) {
appInstantiationService.invokeFunction(accessor => this.stopTracingEventually(accessor, windows));
}

// Set lifecycle phase to `Eventually` after a short delay and when idle (min 2.5sec, max 5sec)
const eventuallyPhaseScheduler = this._register(new RunOnceScheduler(() => {
this._register(runWhenIdle(() => this.lifecycleMainService.phase = LifecycleMainPhase.Eventually, 2500));
}, 2500));
eventuallyPhaseScheduler.schedule();
}

private setUpHandlers(instantiationService: IInstantiationService): void {

// Auth Handler
this._register(instantiationService.createInstance(ProxyAuthHandler));

Expand Down
Expand Up @@ -175,7 +175,13 @@ export const enum LifecycleMainPhase {
* and is typically the best place to do work that is not required
* for the window to open.
*/
AfterWindowOpen = 3
AfterWindowOpen = 3,

/**
* The last phase after a window has opened and some time has passed
* (2-5 seconds).
*/
Eventually = 4
}

export class LifecycleMainService extends Disposable implements ILifecycleMainService {
Expand Down
Expand Up @@ -62,8 +62,9 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa

private registerListeners(): void {

// Install window jump list after opening window
this.lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.handleWindowsJumpList());
// Install window jump list delayed after opening window
// because perf measurements have shown this to be slow
this.lifecycleMainService.when(LifecycleMainPhase.Eventually).then(() => this.handleWindowsJumpList());

// Add to history when entering workspace
this._register(this.workspacesManagementMainService.onDidEnterWorkspace(event => this.addRecentlyOpened([{ workspace: event.workspace, remoteAuthority: event.window.remoteAuthority }])));
Expand Down