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 - have more marks for restoring editors #175446

Merged
merged 1 commit into from Feb 26, 2023
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
2 changes: 1 addition & 1 deletion src/bootstrap-amd.js
Expand Up @@ -73,6 +73,6 @@ exports.load = function (entrypoint, onLoad, onError) {
onLoad = onLoad || function () { };
onError = onError || function (err) { console.error(err); };

performance.mark(`code/fork/willLoadCode`);
performance.mark('code/fork/willLoadCode');
loader([entrypoint], onLoad, onError);
};
6 changes: 4 additions & 2 deletions src/vs/workbench/browser/layout.ts
Expand Up @@ -737,6 +737,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi

// first ensure the editor part is ready
await this.editorGroupService.whenReady;
mark('code/restoreEditors/editorGroupsReady');

// apply editor layout if any
if (this.state.initialization.layout?.editors) {
Expand All @@ -753,6 +754,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
// fully loaded.

const editors = await this.state.initialization.editor.editorsToOpen;
mark('code/restoreEditors/editorsToOpenResolved');

let openEditorsPromise: Promise<unknown> | undefined = undefined;
if (editors.length) {
Expand Down Expand Up @@ -789,8 +791,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
// slow editors to resolve on startup
layoutRestoredPromises.push(
Promise.all([
openEditorsPromise,
this.editorGroupService.whenRestored
openEditorsPromise?.finally(() => mark('code/restoreEditors/editorsOpened')),
this.editorGroupService.whenRestored.finally(() => mark('code/restoreEditors/editorGroupsRestored'))
]).finally(() => {
// the `code/didRestoreEditors` perf mark is specifically
// for when visible editors have resolved, so we only mark
Expand Down
13 changes: 11 additions & 2 deletions src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts
Expand Up @@ -35,6 +35,7 @@ import { ViewContainerLocation } from 'vs/workbench/common/views';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { IEditorOptions as ICodeEditorOptions } from 'vs/editor/common/config/editorOptions';

/**
* An implementation of editor for file system resources.
Expand Down Expand Up @@ -96,7 +97,7 @@ export class TextFileEditor extends AbstractTextCodeEditor<ICodeEditorViewState>
}

override async setInput(input: FileEditorInput, options: IFileEditorInputOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
mark(`code/willSetInputToTextFileEditor`);
mark('code/willSetInputToTextFileEditor');

// Set input and resolve
await super.setInput(input, options, context, token);
Expand Down Expand Up @@ -151,7 +152,7 @@ export class TextFileEditor extends AbstractTextCodeEditor<ICodeEditorViewState>
await this.handleSetInputError(error, input, options);
}

mark(`code/didSetInputToTextFileEditor`);
mark('code/didSetInputToTextFileEditor');
}

protected async handleSetInputError(error: Error, input: FileEditorInput, options: ITextEditorOptions | undefined): Promise<void> {
Expand Down Expand Up @@ -286,6 +287,14 @@ export class TextFileEditor extends AbstractTextCodeEditor<ICodeEditorViewState>
this.editorControl?.setModel(null);
}

protected override createEditorControl(parent: HTMLElement, initialOptions: ICodeEditorOptions): void {
mark('code/willCreateTextFileEditorControl');

super.createEditorControl(parent, initialOptions);

mark('code/didCreateTextFileEditorControl');
}

protected override tracksEditorViewState(input: EditorInput): boolean {
return input instanceof FileEditorInput;
}
Expand Down
Expand Up @@ -6,6 +6,7 @@
import { localize } from 'vs/nls';
import { Emitter } from 'vs/base/common/event';
import { URI } from 'vs/base/common/uri';
import { mark } from 'vs/base/common/performance';
import { assertIsDefined, withNullAsUndefined } from 'vs/base/common/types';
import { EncodingMode, ITextFileService, TextFileEditorModelState, ITextFileEditorModel, ITextFileStreamContent, ITextFileResolveOptions, IResolvedTextFileEditorModel, ITextFileSaveOptions, TextFileResolveReason, ITextFileEditorModelSaveEvent } from 'vs/workbench/services/textfile/common/textfiles';
import { IRevertOptions, SaveReason, SaveSourceRegistry } from 'vs/workbench/common/editor';
Expand Down Expand Up @@ -275,6 +276,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil

override async resolve(options?: ITextFileResolveOptions): Promise<void> {
this.trace('resolve() - enter');
mark('code/willResolveTextFileEditorModel');

// Return early if we are disposed
if (this.isDisposed()) {
Expand All @@ -292,7 +294,10 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
return;
}

return this.doResolve(options);
// Resolve either from backup or from file
await this.doResolve(options);

mark('code/didResolveTextFileEditorModel');
}

private async doResolve(options?: ITextFileResolveOptions): Promise<void> {
Expand Down