From f55710d25992c292ccc5782267f150a393ae2c89 Mon Sep 17 00:00:00 2001 From: Tobias Ortmayr Date: Wed, 20 Dec 2023 23:08:21 -0800 Subject: [PATCH] Deploy plugins asynchronously (#13134) - Make `initialize` method in `PluginDeployerContribution` sync to continue with backend loading while plugins are deployed - Fix wrong performance measurements of `resolvePlugins` & `deployPlugins` & in `PluginDeployerImpl` - Improve performance logging in `HostedPluginSupport` by only logging relevent measurements of `sync/`load` and `start` plugins (i.e. if the plugin count is 0 just stop the measurement but don`t log) - Update `I18nPreloadContribution` to ensure that we only load the localizations from the backend if the current locale is not equal to the default locale --- .../preload/i18n-preload-contribution.ts | 2 +- .../src/hosted/browser/hosted-plugin.ts | 22 ++++++++++++++----- .../main/node/plugin-deployer-contribution.ts | 4 ++-- .../src/main/node/plugin-deployer-impl.ts | 3 ++- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/core/src/browser/preload/i18n-preload-contribution.ts b/packages/core/src/browser/preload/i18n-preload-contribution.ts index 309c8df5f9436..0cddfa112e723 100644 --- a/packages/core/src/browser/preload/i18n-preload-contribution.ts +++ b/packages/core/src/browser/preload/i18n-preload-contribution.ts @@ -33,7 +33,7 @@ export class I18nPreloadContribution implements PreloadContribution { locale: defaultLocale }); } - if (nls.locale) { + if (nls.locale && nls.locale !== nls.defaultLocale) { const localization = await this.localizationServer.loadLocalization(nls.locale); if (localization.languagePack) { nls.localization = localization; diff --git a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts index 5772914b3ac19..fc454e5a58966 100644 --- a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts +++ b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts @@ -401,8 +401,12 @@ export class HostedPluginSupport { waitPluginsMeasurement.error('Backend deployment failed.'); } } - - syncPluginsMeasurement?.log(`Sync of ${this.getPluginCount(initialized)}`); + if (initialized > 0) { + // Only log sync measurement if there are were plugins to sync. + syncPluginsMeasurement?.log(`Sync of ${this.getPluginCount(initialized)}`); + } else { + syncPluginsMeasurement.stop(); + } } /** @@ -440,8 +444,12 @@ export class HostedPluginSupport { })); } } - - loadPluginsMeasurement.log(`Load contributions of ${this.getPluginCount(loaded)}`); + if (loaded > 0) { + // Only log load measurement if there are were plugins to load. + loadPluginsMeasurement?.log(`Load contributions of ${this.getPluginCount(loaded)}`); + } else { + loadPluginsMeasurement.stop(); + } return hostContributions; } @@ -512,7 +520,11 @@ export class HostedPluginSupport { return; } - startPluginsMeasurement.log(`Start of ${this.getPluginCount(started)}`); + if (started > 0) { + startPluginsMeasurement.log(`Start of ${this.getPluginCount(started)}`); + } else { + startPluginsMeasurement.stop(); + } } protected async obtainManager(host: string, hostContributions: PluginContributions[], toDisconnect: DisposableCollection): Promise { diff --git a/packages/plugin-ext/src/main/node/plugin-deployer-contribution.ts b/packages/plugin-ext/src/main/node/plugin-deployer-contribution.ts index 053ce001bb9df..d5c9f38d7aab9 100644 --- a/packages/plugin-ext/src/main/node/plugin-deployer-contribution.ts +++ b/packages/plugin-ext/src/main/node/plugin-deployer-contribution.ts @@ -28,7 +28,7 @@ export class PluginDeployerContribution implements BackendApplicationContributio @inject(PluginDeployer) protected pluginDeployer: PluginDeployer; - initialize(): Promise { - return this.pluginDeployer.start(); + initialize(): void { + this.pluginDeployer.start().catch(error => this.logger.error('Initializing plugin deployer failed.', error)); } } diff --git a/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts b/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts index 0fe63e7b5f24f..1eb032c397741 100644 --- a/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts +++ b/packages/plugin-ext/src/main/node/plugin-deployer-impl.ts @@ -130,8 +130,9 @@ export class PluginDeployerImpl implements PluginDeployer { id, type: PluginType.System })); + const resolvePlugins = this.measure('resolvePlugins'); const plugins = await this.resolvePlugins([...unresolvedUserEntries, ...unresolvedSystemEntries]); - deployPlugins.log('Resolve plugins list'); + resolvePlugins.log('Resolve plugins list'); await this.deployPlugins(plugins); deployPlugins.log('Deploy plugins list'); }