Skip to content

Commit

Permalink
Deploy plugins asynchronously (#13134)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
tortmayr authored Dec 21, 2023
1 parent ea0db7a commit f55710d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 17 additions & 5 deletions packages/plugin-ext/src/hosted/browser/hosted-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<PluginManagerExt | undefined> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class PluginDeployerContribution implements BackendApplicationContributio
@inject(PluginDeployer)
protected pluginDeployer: PluginDeployer;

initialize(): Promise<void> {
return this.pluginDeployer.start();
initialize(): void {
this.pluginDeployer.start().catch(error => this.logger.error('Initializing plugin deployer failed.', error));
}
}
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/main/node/plugin-deployer-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit f55710d

Please sign in to comment.