提交 39a48c34 编写于 作者: J João Moreno 提交者: GitHub

Merge pull request #90355 from microsoft/joao/update-service-perf

Delay update service initialization until first window open
......@@ -398,7 +398,7 @@ export class CodeApplication extends Disposable {
const windows = appInstantiationService.invokeFunction(accessor => this.openFirstWindow(accessor, electronIpcServer, sharedProcessClient));
// Post Open Windows Tasks
this.afterWindowOpen();
appInstantiationService.invokeFunction(this.afterWindowOpen.bind(this));
// Tracing: Stop tracing after windows are ready if enabled
if (this.environmentService.args.trace) {
......@@ -714,13 +714,18 @@ export class CodeApplication extends Disposable {
return { fileUri: URI.file(path) };
}
private afterWindowOpen(): void {
private afterWindowOpen(accessor: ServicesAccessor): void {
// Signal phase: after window open
this.lifecycleMainService.phase = LifecycleMainPhase.AfterWindowOpen;
// Remote Authorities
this.handleRemoteAuthorities();
// Initialize update service
const updateService = accessor.get(IUpdateService);
if (updateService instanceof Win32UpdateService || updateService instanceof LinuxUpdateService || updateService instanceof DarwinUpdateService) {
updateService.initialize();
}
}
private handleRemoteAuthorities(): void {
......
......@@ -26,7 +26,7 @@ export abstract class AbstractUpdateService implements IUpdateService {
_serviceBrand: undefined;
protected readonly url: string | undefined;
protected url: string | undefined;
private _state: State = State.Uninitialized;
......@@ -49,7 +49,14 @@ export abstract class AbstractUpdateService implements IUpdateService {
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@IRequestService protected requestService: IRequestService,
@ILogService protected logService: ILogService,
) {
) { }
/**
* This must be called before any other call. This is a performance
* optimization, to avoid using extra CPU cycles before first window open.
* https://github.com/microsoft/vscode/issues/89784
*/
initialize(): void {
if (!this.environmentService.isBuilt) {
return; // updates are never enabled when running out of sources
}
......@@ -173,6 +180,7 @@ export abstract class AbstractUpdateService implements IUpdateService {
if (!this.url) {
return Promise.resolve(undefined);
}
return this.requestService.request({ url: this.url }, CancellationToken.None).then(context => {
// The update server replies with 204 (No Content) when no
// update is available - that's all we want to know.
......
......@@ -36,6 +36,10 @@ export class DarwinUpdateService extends AbstractUpdateService {
@ILogService logService: ILogService
) {
super(lifecycleMainService, configurationService, environmentService, requestService, logService);
}
initialize(): void {
super.initialize();
this.onRawError(this.onError, this, this.disposables);
this.onRawUpdateAvailable(this.onUpdateAvailable, this, this.disposables);
this.onRawUpdateDownloaded(this.onUpdateDownloaded, this, this.disposables);
......
......@@ -69,6 +69,10 @@ export class Win32UpdateService extends AbstractUpdateService {
@IFileService private readonly fileService: IFileService
) {
super(lifecycleMainService, configurationService, environmentService, requestService, logService);
}
initialize(): void {
super.initialize();
if (getUpdateType() === UpdateType.Setup) {
/* __GDPR__
......@@ -81,7 +85,7 @@ export class Win32UpdateService extends AbstractUpdateService {
"target" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
telemetryService.publicLog('update:win32SetupTarget', { target: product.target });
this.telemetryService.publicLog('update:win32SetupTarget', { target: product.target });
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册