Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add verbose logging for errors in perf script #97651

Merged
merged 1 commit into from
May 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { ILifecycleService, StartupKind } from 'vs/platform/lifecycle/common/lifecycle';
import { ILifecycleService, StartupKind, StartupKindToString } from 'vs/platform/lifecycle/common/lifecycle';
import product from 'vs/platform/product/common/product';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IUpdateService } from 'vs/platform/update/common/update';
Expand Down Expand Up @@ -41,9 +41,9 @@ export class StartupTimings implements IWorkbenchContribution {
}

private async _report() {
const isStandardStartup = await this._isStandardStartup();
const standardStartupError = await this._isStandardStartup();
this._reportStartupTimes().catch(onUnexpectedError);
this._appendStartupTimes(isStandardStartup).catch(onUnexpectedError);
this._appendStartupTimes(standardStartupError).catch(onUnexpectedError);
this._reportPerfTicks();
}

Expand All @@ -60,7 +60,7 @@ export class StartupTimings implements IWorkbenchContribution {
this._telemetryService.publicLog('startupTimeVaried', metrics);
}

private async _appendStartupTimes(isStandardStartup: boolean) {
private async _appendStartupTimes(standardStartupError: string | undefined) {
const appendTo = this._envService.args['prof-append-timers'];
if (!appendTo) {
// nothing to do
Expand All @@ -73,7 +73,7 @@ export class StartupTimings implements IWorkbenchContribution {
this._timerService.startupMetrics,
timeout(15000), // wait: cached data creation, telemetry sending
]).then(([startupMetrics]) => {
return promisify(appendFile)(appendTo, `${startupMetrics.ellapsed}\t${product.nameShort}\t${(product.commit || '').slice(0, 10) || '0000000000'}\t${sessionId}\t${isStandardStartup ? 'standard_start' : 'NO_standard_start'}\n`);
return promisify(appendFile)(appendTo, `${startupMetrics.ellapsed}\t${product.nameShort}\t${(product.commit || '').slice(0, 10) || '0000000000'}\t${sessionId}\t${standardStartupError === undefined ? 'standard_start' : 'NO_standard_start : ' + standardStartupError}\n`);
}).then(() => {
this._electronService.quit();
}).catch(err => {
Expand All @@ -82,37 +82,42 @@ export class StartupTimings implements IWorkbenchContribution {
});
}

private async _isStandardStartup(): Promise<boolean> {
private async _isStandardStartup(): Promise<string | undefined> {
// check for standard startup:
// * new window (no reload)
// * just one window
// * explorer viewlet visible
// * one text editor (not multiple, not webview, welcome etc...)
// * cached data present (not rejected, not created)
if (this._lifecycleService.startupKind !== StartupKind.NewWindow) {
return false;
return StartupKindToString(this._lifecycleService.startupKind);
}
if (await this._electronService.getWindowCount() !== 1) {
return false;
const windowCount = await this._electronService.getWindowCount();
if (windowCount !== 1) {
return 'Expected window count : 1, Actual : ' + windowCount;
}
const activeViewlet = this._viewletService.getActiveViewlet();
if (!activeViewlet || activeViewlet.getId() !== files.VIEWLET_ID) {
return false;
return 'Explorer viewlet not visible';
}
const visibleEditorPanes = this._editorService.visibleEditorPanes;
if (visibleEditorPanes.length !== 1 || !isCodeEditor(visibleEditorPanes[0].getControl())) {
return false;
if (visibleEditorPanes.length !== 1) {
return 'Expected text editor count : 1, Actual : ' + visibleEditorPanes.length;
}
if (this._panelService.getActivePanel()) {
return false;
if (!isCodeEditor(visibleEditorPanes[0].getControl())) {
return 'Active editor is not a text editor';
}
const activePanel = this._panelService.getActivePanel();
if (activePanel) {
return 'Current active panel : ' + this._panelService.getPanel(activePanel.getId())?.name;
}
if (!didUseCachedData()) {
return false;
return 'Either cache data is rejected or not created';
}
if (!await this._updateService.isLatestVersion()) {
return false;
return 'Not on latest version, updates available';
}
return true;
return undefined;
}

private _reportPerfTicks(): void {
Expand Down