for disable renderer cpu profiling, keep long task telemetry (#162307)

fixes https://github.com/microsoft/vscode/issues/161767

Co-authored-by: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com>
This commit is contained in:
Johannes Rieken 2022-09-30 14:38:21 +02:00 committed by GitHub
parent 20e2a1524d
commit 9fb452c485
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,7 +37,6 @@ export class RendererProfiling {
const eventHistory = new RingBuffer<{ command: string; timestamp: number }>(5);
this._disposables.add(commandService.onWillExecuteCommand(e => eventHistory.push({ command: e.commandId, timestamp: Date.now() })));
const sessionDisposables = this._disposables.add(new DisposableStore());
const obs = new PerformanceObserver(list => {
@ -51,11 +50,7 @@ export class RendererProfiling {
return;
}
// pause observation, we'll take a detailed look
obs.disconnect();
const sessionId = generateUuid();
logService.warn(`[perf] Renderer reported VERY LONG TASK (${maxDuration}ms), starting auto profiling session '${sessionId}'`);
// all visible views
const views = viewsDescriptorService.viewContainers.map(container => {
@ -74,31 +69,34 @@ export class RendererProfiling {
editors: JSON.stringify(editors),
});
// start heartbeat monitoring
nativeHostService.startHeartbeat(sessionId).then(success => {
if (!success) {
logService.warn('[perf] FAILED to start heartbeat sending');
return;
}
// // start heartbeat monitoring
// const sessionDisposables = this._disposables.add(new DisposableStore());
// logService.warn(`[perf] Renderer reported VERY LONG TASK (${maxDuration}ms), starting auto profiling session '${sessionId}'`);
// // pause observation, we'll take a detailed look
// obs.disconnect();
// nativeHostService.startHeartbeat(sessionId).then(success => {
// if (!success) {
// logService.warn('[perf] FAILED to start heartbeat sending');
// return;
// }
// start sending a repeated heartbeat which is expected to be received by the main side
const handle1 = setInterval(() => nativeHostService.sendHeartbeat(sessionId), 500);
// // start sending a repeated heartbeat which is expected to be received by the main side
// const handle1 = setInterval(() => nativeHostService.sendHeartbeat(sessionId), 500);
// stop heartbeat after 20s
const handle2 = setTimeout(() => sessionDisposables.clear(), 20 * 1000);
// // stop heartbeat after 20s
// const handle2 = setTimeout(() => sessionDisposables.clear(), 20 * 1000);
// cleanup
// - stop heartbeat
// - reconnect perf observer
sessionDisposables.add(toDisposable(() => {
clearInterval(handle1);
clearTimeout(handle2);
nativeHostService.stopHeartbeat(sessionId);
logService.warn(`[perf] STOPPING to send heartbeat`);
obs.observe({ entryTypes: ['longtask'] });
}));
});
// // cleanup
// // - stop heartbeat
// // - reconnect perf observer
// sessionDisposables.add(toDisposable(() => {
// clearInterval(handle1);
// clearTimeout(handle2);
// nativeHostService.stopHeartbeat(sessionId);
// logService.warn(`[perf] STOPPING to send heartbeat`);
// obs.observe({ entryTypes: ['longtask'] });
// }));
// });
});
this._disposables.add(toDisposable(() => obs.disconnect()));