perf - have more marks for restoring editors (#175446)

This commit is contained in:
Benjamin Pasero
2023-02-26 08:56:33 +01:00
committed by GitHub
parent 60c6f5f524
commit 1ea0fa13cf
4 changed files with 22 additions and 6 deletions
+1 -1
View File
@@ -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);
};
+4 -2
View File
@@ -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) {
@@ -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) {
@@ -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
@@ -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.
@@ -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);
@@ -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> {
@@ -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;
}
@@ -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';
@@ -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()) {
@@ -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> {