Skip to content

Commit 6d36404

Browse files
committed
Track terminal renderer marks in timer service
1 parent ed54d72 commit 6d36404

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

src/vs/workbench/contrib/performance/browser/perfviewEditor.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class PerfModelContentProvider implements ITextModelContentProvider {
129129
md.blank();
130130
this._addExtensionsTable(md);
131131
md.blank();
132-
this._addPerfMarksTable('Terminal Stats', md, this._terminalService.perfMarks);
132+
this._addPerfMarksTable('Terminal Stats', md, this._timerService.getPerformanceMarks().find(e => e[0] === 'renderer')?.[1].filter(e => e.name.startsWith('code/terminal/')));
133133
md.blank();
134134
this._addRawPerfMarks(md);
135135
md.blank();
@@ -225,7 +225,10 @@ class PerfModelContentProvider implements ITextModelContentProvider {
225225
}
226226
}
227227

228-
private _addPerfMarksTable(name: string, md: MarkdownBuilder, marks: readonly perf.PerformanceMark[]): void {
228+
private _addPerfMarksTable(name: string, md: MarkdownBuilder, marks: readonly perf.PerformanceMark[] | undefined): void {
229+
if (!marks) {
230+
return;
231+
}
229232
const table: Array<Array<string | number | undefined>> = [];
230233
let lastStartTime = -1;
231234
let total = 0;

src/vs/workbench/contrib/terminal/browser/terminal.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as perf from 'vs/base/common/performance';
76
import { IDimension } from 'vs/base/browser/dom';
87
import { Orientation } from 'vs/base/browser/ui/splitview/splitview';
98
import { Color } from 'vs/base/common/color';
@@ -161,7 +160,6 @@ export interface ITerminalService extends ITerminalInstanceHost {
161160
readonly connectionState: TerminalConnectionState;
162161
readonly whenConnected: Promise<void>;
163162
readonly defaultLocation: TerminalLocation;
164-
readonly perfMarks: readonly perf.PerformanceMark[];
165163

166164
onDidChangeActiveGroup: Event<ITerminalGroup | undefined>;
167165
onDidDisposeGroup: Event<ITerminalGroup>;

src/vs/workbench/contrib/terminal/browser/terminalService.ts

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { XtermTerminal } from 'vs/workbench/contrib/terminal/browser/xterm/xterm
5151
import { TerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminalInstance';
5252
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
5353
import { TerminalCapabilityStore } from 'vs/platform/terminal/common/capabilities/terminalCapabilityStore';
54+
import { mark } from 'vs/base/common/performance';
5455

5556
export class TerminalService implements ITerminalService {
5657
declare _serviceBrand: undefined;
@@ -263,16 +264,10 @@ export class TerminalService implements ITerminalService {
263264
return undefined;
264265
}
265266

266-
private readonly _perfMarks: PerformanceMark[] = [];
267-
get perfMarks(): readonly PerformanceMark[] { return this._perfMarks; }
268-
private _mark(name: string) {
269-
this._perfMarks.push(new PerformanceMark(name));
270-
}
271-
272267
async initializePrimaryBackend() {
273-
this._mark('code/terminal/willGetTerminalBackend');
268+
mark('code/terminal/willGetTerminalBackend');
274269
this._primaryBackend = await this._terminalInstanceService.getBackend(this._environmentService.remoteAuthority);
275-
this._mark('code/terminal/didGetTerminalBackend');
270+
mark('code/terminal/didGetTerminalBackend');
276271
const enableTerminalReconnection = this.configHelper.config.enablePersistentSessions;
277272

278273
// Connect to the extension host if it's there, set the connection state to connected when
@@ -281,7 +276,7 @@ export class TerminalService implements ITerminalService {
281276

282277
const isPersistentRemote = !!this._environmentService.remoteAuthority && enableTerminalReconnection;
283278

284-
this._mark('code/terminal/willReconnect');
279+
mark('code/terminal/willReconnect');
285280
let reconnectedPromise: Promise<any>;
286281
if (isPersistentRemote) {
287282
reconnectedPromise = this._reconnectToRemoteTerminals();
@@ -292,7 +287,7 @@ export class TerminalService implements ITerminalService {
292287
}
293288
reconnectedPromise.then(() => {
294289
this._setConnected();
295-
this._mark('code/terminal/didReconnect');
290+
mark('code/terminal/didReconnect');
296291
for (const backend of this._terminalInstanceService.getRegisteredBackends()) {
297292
backend.setConnected();
298293
}
@@ -426,13 +421,13 @@ export class TerminalService implements ITerminalService {
426421
if (!backend) {
427422
return;
428423
}
429-
this._mark('code/terminal/willGetTerminalLayoutInfo');
424+
mark('code/terminal/willGetTerminalLayoutInfo');
430425
const layoutInfo = await backend.getTerminalLayoutInfo();
431-
this._mark('code/terminal/didGetTerminalLayoutInfo');
426+
mark('code/terminal/didGetTerminalLayoutInfo');
432427
backend.reduceConnectionGraceTime();
433-
this._mark('code/terminal/willRecreateTerminalGroups');
428+
mark('code/terminal/willRecreateTerminalGroups');
434429
await this._recreateTerminalGroups(layoutInfo);
435-
this._mark('code/terminal/didRecreateTerminalGroups');
430+
mark('code/terminal/didRecreateTerminalGroups');
436431
// now that terminals have been restored,
437432
// attach listeners to update remote when terminals are changed
438433
this._attachProcessLayoutListeners();
@@ -443,13 +438,13 @@ export class TerminalService implements ITerminalService {
443438
if (!localBackend) {
444439
return;
445440
}
446-
this._mark('code/terminal/willGetTerminalLayoutInfo');
441+
mark('code/terminal/willGetTerminalLayoutInfo');
447442
const layoutInfo = await localBackend.getTerminalLayoutInfo();
448-
this._mark('code/terminal/didGetTerminalLayoutInfo');
443+
mark('code/terminal/didGetTerminalLayoutInfo');
449444
if (layoutInfo && layoutInfo.tabs.length > 0) {
450-
this._mark('code/terminal/willRecreateTerminalGroups');
445+
mark('code/terminal/willRecreateTerminalGroups');
451446
await this._recreateTerminalGroups(layoutInfo);
452-
this._mark('code/terminal/didRecreateTerminalGroups');
447+
mark('code/terminal/didRecreateTerminalGroups');
453448
}
454449
// now that terminals have been restored,
455450
// attach listeners to update local state when terminals are changed
@@ -471,7 +466,7 @@ export class TerminalService implements ITerminalService {
471466
if (this._lifecycleService.startupKind !== StartupKind.ReloadedWindow && attachPersistentProcess.type === 'Task') {
472467
continue;
473468
}
474-
this._mark(`terminal/willRecreateTerminal/${attachPersistentProcess.id}-${attachPersistentProcess.pid}`);
469+
mark(`code/terminal/willRecreateTerminal/${attachPersistentProcess.id}-${attachPersistentProcess.pid}`);
475470
if (!terminalInstance) {
476471
// create group and terminal
477472
terminalInstance = await this.createTerminal({
@@ -489,7 +484,7 @@ export class TerminalService implements ITerminalService {
489484
location: { parentTerminal: terminalInstance }
490485
});
491486
}
492-
this._mark(`terminal/didRecreateTerminal/${attachPersistentProcess.id}-${attachPersistentProcess.pid}`);
487+
mark(`code/terminal/didRecreateTerminal/${attachPersistentProcess.id}-${attachPersistentProcess.pid}`);
493488
}
494489
const activeInstance = this.instances.find(t => {
495490
return t.shellLaunchConfig.attachPersistentProcess?.id === groupLayout.activePersistentProcessId;
@@ -929,11 +924,11 @@ export class TerminalService implements ITerminalService {
929924
const isLocalInRemoteTerminal = this._remoteAgentService.getConnection() && URI.isUri(options?.cwd) && options?.cwd.scheme === Schemas.vscodeFileResource;
930925
if (!isPtyTerminal && !isLocalInRemoteTerminal) {
931926
if (this._connectionState === TerminalConnectionState.Connecting) {
932-
this._mark(`terminal/willGetProfiles`);
927+
mark(`code/terminal/willGetProfiles`);
933928
}
934929
await this._terminalProfileService.profilesReady;
935930
if (this._connectionState === TerminalConnectionState.Connecting) {
936-
this._mark(`terminal/didGetProfiles`);
931+
mark(`code/terminal/didGetProfiles`);
937932
}
938933
}
939934
}

0 commit comments

Comments
 (0)