提交 157fbda8 编写于 作者: J Johannes Rieken

prompt some users to profile after slowish startup

上级 1081ef16
...@@ -76,7 +76,7 @@ export enum Platform { ...@@ -76,7 +76,7 @@ export enum Platform {
Windows Windows
} }
export let _platform: Platform = Platform.Web; let _platform: Platform = Platform.Web;
if (_isNative) { if (_isNative) {
if (_isMacintosh) { if (_isMacintosh) {
_platform = Platform.Mac; _platform = Platform.Mac;
......
...@@ -21,6 +21,48 @@ import { IMessageService } from 'vs/platform/message/common/message'; ...@@ -21,6 +21,48 @@ import { IMessageService } from 'vs/platform/message/common/message';
import { ITimerService } from 'vs/workbench/services/timer/common/timerService'; import { ITimerService } from 'vs/workbench/services/timer/common/timerService';
import { IWorkbenchContributionsRegistry, IWorkbenchContribution, Extensions } from 'vs/workbench/common/contributions'; import { IWorkbenchContributionsRegistry, IWorkbenchContribution, Extensions } from 'vs/workbench/common/contributions';
import product from 'vs/platform/node/product'; import product from 'vs/platform/node/product';
import { platform, Platform } from 'vs/base/common/platform';
import { release } from 'os';
const percentiles: { [key: string]: [number, number] } = {
// 80th - 90th percentiles
['Linux_4.10.0-20-generic']: [3474, 6300],
['Linux_4.10.0-21-generic']: [5342, 12022],
['Linux_4.10.13-1-ARCH']: [3047, 4248],
['Linux_4.10.13-200.fc25.x86_64']: [2380, 2895],
['Linux_4.10.14-200.fc25.x86_64']: [5164, 14042],
['Linux_4.4.0-21-generic']: [3777, 8160],
['Linux_4.4.0-72-generic']: [6173, 10730],
['Linux_4.4.0-75-generic']: [4769, 8560],
['Linux_4.4.0-77-generic']: [3834, 7343],
['Linux_4.4.0-78-generic']: [3115, 7078],
['Linux_4.8.0-49-generic']: [7174, 10362],
['Linux_4.8.0-51-generic']: [3906, 7385],
['Linux_4.8.0-52-generic']: [6757, 13741],
['Linux_4.9.0-2-amd64']: [4348, 8754],
['Mac_14.5.0']: [4403, 7216],
['Mac_15.4.0']: [3831, 4946],
['Mac_15.5.0']: [5080, 8296],
['Mac_15.6.0']: [4621, 7160],
['Mac_16.0.0']: [4748, 11248],
['Mac_16.1.0']: [4309, 6106],
['Mac_16.3.0']: [2756, 3674],
['Mac_16.4.0']: [3625, 5463],
['Mac_16.5.0']: [3617, 5288],
['Mac_16.6.0']: [3655, 5279],
['Mac_16.7.0']: [4415, 6624],
['Windows_10.0.10240']: [8284, 14438],
['Windows_10.0.10586']: [5903, 9224],
['Windows_10.0.14393']: [6065, 10567],
['Windows_10.0.15063']: [5521, 8696],
['Windows_10.0.16184']: [5604, 10671],
['Windows_10.0.16188']: [7028, 12852],
['Windows_10.0.16193']: [6431, 9628],
['Windows_6.1.7601']: [7794, 15194],
['Windows_6.3.9600']: [6129, 10188],
};
const myPercentiles = percentiles[`${Platform[platform]}_${release()}`];
class PerformanceContribution implements IWorkbenchContribution { class PerformanceContribution implements IWorkbenchContribution {
...@@ -32,7 +74,6 @@ class PerformanceContribution implements IWorkbenchContribution { ...@@ -32,7 +74,6 @@ class PerformanceContribution implements IWorkbenchContribution {
@IStorageService private _storageService: IStorageService, @IStorageService private _storageService: IStorageService,
@IExtensionService extensionService: IExtensionService, @IExtensionService extensionService: IExtensionService,
) { ) {
const dumpFile = _envService.args['prof-startup-timers']; const dumpFile = _envService.args['prof-startup-timers'];
if (dumpFile) { if (dumpFile) {
// wait for extensions being loaded // wait for extensions being loaded
...@@ -63,37 +104,58 @@ class PerformanceContribution implements IWorkbenchContribution { ...@@ -63,37 +104,58 @@ class PerformanceContribution implements IWorkbenchContribution {
private _checkTimersAndSuggestToProfile() { private _checkTimersAndSuggestToProfile() {
const disabled = true; if (!this._timerService.isInitialStartup) {
if (disabled) {
return; return;
} }
//TODO(joh) use better heuristics (70th percentile, not vm, etc)
const value = this._storageService.get(this.getId(), StorageScope.GLOBAL, undefined); // 1: Check that we have some data about this
if (value !== undefined) { // OS version to which we can compare this startup.
// Then only go for startups between the 80th and
// 90th percentile.
if (!Array.isArray(myPercentiles)) {
return;
}
const [from, to] = myPercentiles;
const { ellapsed } = this._timerService.startupMetrics;
if (ellapsed < from || ellapsed > to) {
return; return;
} }
// 2: Ignore virtual machines and only ask users
// to profile with a certain propability
if (virtualMachineHint.value() >= .5) { if (virtualMachineHint.value() >= .5) {
// return;
}
if (Math.ceil(Math.random() * 50) !== 1) {
return; return;
} }
const { ellapsed } = this._timerService.startupMetrics; // 3: Don't ask for the stable version, only
if (ellapsed > 5000 && Math.ceil(Math.random() * 10) % 3 === 0) { // ask once per version/build
const profile = this._messageService.confirm({ if (this._envService.appQuality === 'stable') {
type: 'info', // don't ask in stable
message: localize('slow', "Slow startup detected"), return;
detail: localize('slow.detail', "Sorry that you just had a slow startup. Please restart '{0}' with profiling enabled, share the profiles with us, and we will work hard to make startup great again.", this._envService.appNameLong), }
primaryButton: 'Restart and profile' const mementoKey = `performance.didPromptToProfile.${product.commit}`;
}); const value = this._storageService.get(mementoKey, StorageScope.GLOBAL, undefined);
if (value !== undefined) {
if (profile) { // only ask once per version
this._storageService.store(this.getId(), 'didProfile', StorageScope.GLOBAL); return;
this._windowsService.relaunch({ addArgs: ['--prof-startup'] }); }
} else {
this._storageService.store(this.getId(), 'didReject', StorageScope.GLOBAL);
} const profile = this._messageService.confirm({
type: 'info',
message: localize('slow', "Slow startup detected"),
detail: localize('slow.detail', "Sorry that you just had a slow startup. Please restart '{0}' with profiling enabled, share the profiles with us, and we will work hard to make startup great again.", this._envService.appNameLong),
primaryButton: 'Restart and profile'
});
if (profile) {
this._storageService.store(mementoKey, 'didProfile', StorageScope.GLOBAL);
this._windowsService.relaunch({ addArgs: ['--prof-startup'] });
} else {
this._storageService.store(mementoKey, 'didReject', StorageScope.GLOBAL);
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册