Skip to content

Commit b784e05

Browse files
authored
Revert "perf - log slow running workbench contribs (microsoft#159656)" (microsoft#162312)
* Revert "perf - log slow running workbench contribs (microsoft#159656)" This reverts commit b7d5b65. * stop logging slownes * still log perf but only running out of sources
1 parent e05324c commit b784e05

File tree

109 files changed

+198
-216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+198
-216
lines changed

src/vs/workbench/api/browser/extensionHost.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ export class ExtensionPoints implements IWorkbenchContribution {
9090
}
9191
}
9292

93-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(ExtensionPoints, 'ExtensionPoints', LifecyclePhase.Starting);
93+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(ExtensionPoints, LifecyclePhase.Starting);

src/vs/workbench/api/browser/viewsExtensionPoint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,4 +642,4 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
642642
}
643643

644644
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
645-
workbenchRegistry.registerWorkbenchContribution(ViewsExtensionHandler, 'ViewsExtensionHandler', LifecyclePhase.Starting);
645+
workbenchRegistry.registerWorkbenchContribution(ViewsExtensionHandler, LifecyclePhase.Starting);

src/vs/workbench/browser/actions/textInputActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ export class TextInputActionsProvider extends Disposable implements IWorkbenchCo
9999
}
100100
}
101101

102-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(TextInputActionsProvider, 'TextInputActionsProvider', LifecyclePhase.Ready);
102+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(TextInputActionsProvider, LifecyclePhase.Ready);

src/vs/workbench/browser/parts/dialogs/dialog.web.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ export class DialogHandlerContribution extends Disposable implements IWorkbenchC
7575
}
7676

7777
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
78-
workbenchRegistry.registerWorkbenchContribution(DialogHandlerContribution, 'DialogHandlerContribution', LifecyclePhase.Starting);
78+
workbenchRegistry.registerWorkbenchContribution(DialogHandlerContribution, LifecyclePhase.Starting);

src/vs/workbench/browser/parts/editor/editor.contribution.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEdit
122122

123123
//#region Workbench Contributions
124124

125-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(EditorAutoSave, 'EditorAutoSave', LifecyclePhase.Ready);
126-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(EditorStatus, 'EditorStatus', LifecyclePhase.Ready);
127-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(UntitledTextEditorWorkingCopyEditorHandler, 'UntitledTextEditorWorkingCopyEditorHandler', LifecyclePhase.Ready);
128-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DynamicEditorConfigurations, 'DynamicEditorConfigurations', LifecyclePhase.Ready);
125+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(EditorAutoSave, LifecyclePhase.Ready);
126+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(EditorStatus, LifecyclePhase.Ready);
127+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(UntitledTextEditorWorkingCopyEditorHandler, LifecyclePhase.Ready);
128+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DynamicEditorConfigurations, LifecyclePhase.Ready);
129129

130130
registerEditorContribution(FloatingClickMenu.ID, FloatingClickMenu);
131131

src/vs/workbench/browser/workbench.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
1818
(function registerConfiguration(): void {
1919

2020
// Migration support
21-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(ConfigurationMigrationWorkbenchContribution, 'ConfigurationMigrationWorkbenchContribution', LifecyclePhase.Eventually);
21+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(ConfigurationMigrationWorkbenchContribution, LifecyclePhase.Eventually);
2222

2323
// Workbench
2424
registry.registerConfiguration({

src/vs/workbench/common/contributions.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
99
import { runWhenIdle, IdleDeadline } from 'vs/base/common/async';
1010
import { mark } from 'vs/base/common/performance';
1111
import { ILogService } from 'vs/platform/log/common/log';
12+
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
1213

1314
/**
1415
* A workbench contribution that will be loaded when the workbench starts and disposed when the workbench shuts down.
@@ -23,21 +24,15 @@ export namespace Extensions {
2324

2425
type IWorkbenchContributionSignature<Service extends BrandedService[]> = new (...services: Service) => IWorkbenchContribution;
2526

26-
interface IWorkbenchContributionRegistration {
27-
readonly id: string;
28-
readonly ctor: IConstructorSignature<IWorkbenchContribution>;
29-
}
30-
3127
export interface IWorkbenchContributionsRegistry {
3228

3329
/**
3430
* Registers a workbench contribution to the platform that will be loaded when the workbench starts and disposed when
3531
* the workbench shuts down.
3632
*
37-
* @param id the identifier of the contribution.
3833
* @param phase the lifecycle phase when to instantiate the contribution.
3934
*/
40-
registerWorkbenchContribution<Services extends BrandedService[]>(contribution: IWorkbenchContributionSignature<Services>, id: string, phase: LifecyclePhase): void;
35+
registerWorkbenchContribution<Services extends BrandedService[]>(contribution: IWorkbenchContributionSignature<Services>, phase: LifecyclePhase): void;
4136

4237
/**
4338
* Starts the registry by providing the required services.
@@ -50,15 +45,15 @@ class WorkbenchContributionsRegistry implements IWorkbenchContributionsRegistry
5045
private instantiationService: IInstantiationService | undefined;
5146
private lifecycleService: ILifecycleService | undefined;
5247
private logService: ILogService | undefined;
48+
private environmentService: IEnvironmentService | undefined;
5349

54-
private readonly toBeInstantiated = new Map<LifecyclePhase, IWorkbenchContributionRegistration[]>();
50+
private readonly toBeInstantiated = new Map<LifecyclePhase, IConstructorSignature<IWorkbenchContribution>[]>();
5551

56-
registerWorkbenchContribution(ctor: IConstructorSignature<IWorkbenchContribution>, id: string, phase: LifecyclePhase = LifecyclePhase.Starting): void {
57-
const contribution = { id, ctor };
52+
registerWorkbenchContribution(ctor: IConstructorSignature<IWorkbenchContribution>, phase: LifecyclePhase = LifecyclePhase.Starting): void {
5853

5954
// Instantiate directly if we are already matching the provided phase
60-
if (this.instantiationService && this.lifecycleService && this.logService && this.lifecycleService.phase >= phase) {
61-
this.safeCreateInstance(this.instantiationService, this.logService, contribution, phase);
55+
if (this.instantiationService && this.lifecycleService && this.logService && this.environmentService && this.lifecycleService.phase >= phase) {
56+
this.safeCreateInstance(this.instantiationService, this.logService, this.environmentService, ctor, phase);
6257
}
6358

6459
// Otherwise keep contributions by lifecycle phase
@@ -69,34 +64,35 @@ class WorkbenchContributionsRegistry implements IWorkbenchContributionsRegistry
6964
this.toBeInstantiated.set(phase, toBeInstantiated);
7065
}
7166

72-
toBeInstantiated.push(contribution);
67+
toBeInstantiated.push(ctor as IConstructorSignature<IWorkbenchContribution>);
7368
}
7469
}
7570

7671
start(accessor: ServicesAccessor): void {
7772
const instantiationService = this.instantiationService = accessor.get(IInstantiationService);
7873
const lifecycleService = this.lifecycleService = accessor.get(ILifecycleService);
7974
const logService = this.logService = accessor.get(ILogService);
75+
const environmentService = this.environmentService = accessor.get(IEnvironmentService);
8076

8177
for (const phase of [LifecyclePhase.Starting, LifecyclePhase.Ready, LifecyclePhase.Restored, LifecyclePhase.Eventually]) {
82-
this.instantiateByPhase(instantiationService, lifecycleService, logService, phase);
78+
this.instantiateByPhase(instantiationService, lifecycleService, logService, environmentService, phase);
8379
}
8480
}
8581

86-
private instantiateByPhase(instantiationService: IInstantiationService, lifecycleService: ILifecycleService, logService: ILogService, phase: LifecyclePhase): void {
82+
private instantiateByPhase(instantiationService: IInstantiationService, lifecycleService: ILifecycleService, logService: ILogService, environmentService: IEnvironmentService, phase: LifecyclePhase): void {
8783

8884
// Instantiate contributions directly when phase is already reached
8985
if (lifecycleService.phase >= phase) {
90-
this.doInstantiateByPhase(instantiationService, logService, phase);
86+
this.doInstantiateByPhase(instantiationService, logService, environmentService, phase);
9187
}
9288

9389
// Otherwise wait for phase to be reached
9490
else {
95-
lifecycleService.when(phase).then(() => this.doInstantiateByPhase(instantiationService, logService, phase));
91+
lifecycleService.when(phase).then(() => this.doInstantiateByPhase(instantiationService, logService, environmentService, phase));
9692
}
9793
}
9894

99-
private doInstantiateByPhase(instantiationService: IInstantiationService, logService: ILogService, phase: LifecyclePhase): void {
95+
private doInstantiateByPhase(instantiationService: IInstantiationService, logService: ILogService, environmentService: IEnvironmentService, phase: LifecyclePhase): void {
10096
const toBeInstantiated = this.toBeInstantiated.get(phase);
10197
if (toBeInstantiated) {
10298
this.toBeInstantiated.delete(phase);
@@ -108,7 +104,7 @@ class WorkbenchContributionsRegistry implements IWorkbenchContributionsRegistry
108104
mark(`code/willCreateWorkbenchContributions/${phase}`);
109105

110106
for (const ctor of toBeInstantiated) {
111-
this.safeCreateInstance(instantiationService, logService, ctor, phase); // catch error so that other contributions are still considered
107+
this.safeCreateInstance(instantiationService, logService, environmentService, ctor, phase); // catch error so that other contributions are still considered
112108
}
113109

114110
mark(`code/didCreateWorkbenchContributions/${phase}`);
@@ -123,7 +119,7 @@ class WorkbenchContributionsRegistry implements IWorkbenchContributionsRegistry
123119
const instantiateSome = (idle: IdleDeadline) => {
124120
while (i < toBeInstantiated.length) {
125121
const ctor = toBeInstantiated[i++];
126-
this.safeCreateInstance(instantiationService, logService, ctor, phase); // catch error so that other contributions are still considered
122+
this.safeCreateInstance(instantiationService, logService, environmentService, ctor, phase); // catch error so that other contributions are still considered
127123
if (idle.timeRemaining() < 1) {
128124
// time is up -> reschedule
129125
runWhenIdle(instantiateSome, forcedTimeout);
@@ -136,19 +132,19 @@ class WorkbenchContributionsRegistry implements IWorkbenchContributionsRegistry
136132
}
137133
}
138134

139-
private safeCreateInstance(instantiationService: IInstantiationService, logService: ILogService, contribution: IWorkbenchContributionRegistration, phase: LifecyclePhase): void {
135+
private safeCreateInstance(instantiationService: IInstantiationService, logService: ILogService, environmentService: IEnvironmentService, ctor: IConstructorSignature<IWorkbenchContribution>, phase: LifecyclePhase): void {
140136
const now: number | undefined = phase < LifecyclePhase.Restored ? Date.now() : undefined;
141137

142138
try {
143-
instantiationService.createInstance(contribution.ctor);
139+
instantiationService.createInstance(ctor);
144140
} catch (error) {
145-
logService.error(`Unable to instantiate workbench contribution ${contribution.id}.`, error);
141+
logService.error(`Unable to instantiate workbench contribution ${ctor.name}.`, error);
146142
}
147143

148-
if (typeof now === 'number') {
144+
if (typeof now === 'number' && !environmentService.isBuilt /* only log out of sources where we have good ctor names */) {
149145
const time = Date.now() - now;
150-
if (time > 5) {
151-
logService.warn(`Workbench contribution ${contribution.id} blocked restore phase by ${time}ms.`);
146+
if (time > 20) {
147+
logService.warn(`Workbench contribution ${ctor.name} blocked restore phase by ${time}ms.`);
152148
}
153149
}
154150
}

src/vs/workbench/contrib/audioCues/browser/audioCues.contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle
1717

1818
registerSingleton(IAudioCueService, AudioCueService, false);
1919

20-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(AudioCueLineFeatureContribution, 'AudioCueLineFeatureContribution', LifecyclePhase.Restored);
21-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(AudioCueLineDebuggerContribution, 'AudioCueLineDebuggerContribution', LifecyclePhase.Restored);
20+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(AudioCueLineFeatureContribution, LifecyclePhase.Restored);
21+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(AudioCueLineDebuggerContribution, LifecyclePhase.Restored);
2222

2323
const audioCueFeatureBase: IConfigurationPropertySchema = {
2424
'type': 'string',

src/vs/workbench/contrib/bracketPairColorizer2Telemetry/browser/bracketPairColorizer2Telemetry.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ class BracketPairColorizer2TelemetryContribution {
5151
}
5252
}
5353

54-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(BracketPairColorizer2TelemetryContribution, 'BracketPairColorizer2TelemetryContribution', LifecyclePhase.Restored);
54+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(BracketPairColorizer2TelemetryContribution, LifecyclePhase.Restored);
5555

src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,7 @@ registerAction2(class ToggleGrouping extends Action2 {
323323
});
324324

325325
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(
326-
BulkEditPreviewContribution,
327-
'BulkEditPreviewContribution',
328-
LifecyclePhase.Ready
326+
BulkEditPreviewContribution, LifecyclePhase.Ready
329327
);
330328

331329
const refactorPreviewViewIcon = registerIcon('refactor-preview-view-icon', Codicon.lightbulb, localize('refactorPreviewViewIcon', 'View icon of the refactor preview view.'));

0 commit comments

Comments
 (0)