Skip to content

Commit ec9e54e

Browse files
committed
Move terminal perf marks into own section
Part of microsoft#185393
1 parent cf23221 commit ec9e54e

File tree

3 files changed

+46
-19
lines changed

3 files changed

+46
-19
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ class PerfModelContentProvider implements ITextModelContentProvider {
128128
md.blank();
129129
this._addExtensionsTable(md);
130130
md.blank();
131+
this._addTerminalTable(md);
132+
md.blank();
131133
this._addRawPerfMarks(md);
132134
md.blank();
133135
this._addLoaderStats(md, stats);
@@ -222,6 +224,22 @@ class PerfModelContentProvider implements ITextModelContentProvider {
222224
}
223225
}
224226

227+
private _addTerminalTable(md: MarkdownBuilder): void {
228+
const table: Array<Array<string | number | undefined>> = [];
229+
const marks = this._terminalService.perfMarks;
230+
let lastStartTime = -1;
231+
let total = 0;
232+
for (const { name, startTime, detail } of marks) {
233+
const delta = lastStartTime !== -1 ? startTime - lastStartTime : 0;
234+
total += delta;
235+
table.push([name, Math.round(startTime), Math.round(delta), Math.round(total), detail ?? '']);
236+
lastStartTime = startTime;
237+
}
238+
239+
md.heading(2, 'Terminal Stats');
240+
md.table(['Name', 'Timestamp', 'Delta', 'Total', 'Detail'], table);
241+
}
242+
225243
private _addRawPerfMarks(md: MarkdownBuilder): void {
226244

227245
for (const [source, marks] of this._timerService.getPerformanceMarks()) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export interface ITerminalService extends ITerminalInstanceHost {
159159
readonly connectionState: TerminalConnectionState;
160160
readonly whenConnected: Promise<void>;
161161
readonly defaultLocation: TerminalLocation;
162+
readonly perfMarks: readonly PerformanceMark[];
162163

163164
onDidChangeActiveGroup: Event<ITerminalGroup | undefined>;
164165
onDidDisposeGroup: Event<ITerminalGroup>;

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

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,15 @@ export class TerminalService implements ITerminalService {
266266
}
267267

268268
private readonly _perfMarks: PerformanceMark[] = [];
269-
private _mark(name: string) {
270-
this._perfMarks.push(new PerformanceMark(name));
269+
get perfMarks(): readonly PerformanceMark[] { return this._perfMarks; }
270+
private _mark(name: string, detail?: string) {
271+
this._perfMarks.push(new PerformanceMark(name, { detail }));
271272
}
272273

273274
async initializePrimaryBackend() {
274-
this._mark('code/terminal/willGetTerminalBackend');
275+
this._mark('terminal/willGetTerminalBackend');
275276
this._primaryBackend = await this._terminalInstanceService.getBackend(this._environmentService.remoteAuthority);
276-
this._mark('code/terminal/didGetTerminalBackend');
277+
this._mark('terminal/didGetTerminalBackend');
277278
const enableTerminalReconnection = this.configHelper.config.enablePersistentSessions;
278279

279280
// Connect to the extension host if it's there, set the connection state to connected when
@@ -282,7 +283,7 @@ export class TerminalService implements ITerminalService {
282283

283284
const isPersistentRemote = !!this._environmentService.remoteAuthority && enableTerminalReconnection;
284285

285-
this._mark('code/terminal/willReconnect');
286+
this._mark('terminal/willReconnect');
286287
let reconnectedPromise: Promise<any>;
287288
if (isPersistentRemote) {
288289
reconnectedPromise = this._reconnectToRemoteTerminals();
@@ -293,7 +294,7 @@ export class TerminalService implements ITerminalService {
293294
}
294295
reconnectedPromise.then(() => {
295296
this._setConnected();
296-
this._mark('code/terminal/didReconnect');
297+
this._mark('terminal/didReconnect');
297298
this._timerService.setPerformanceMarks('terminal', this._perfMarks);
298299
this._whenConnected.complete();
299300
});
@@ -425,13 +426,13 @@ export class TerminalService implements ITerminalService {
425426
if (!backend) {
426427
return;
427428
}
428-
this._mark('code/terminal/willGetTerminalLayoutInfo');
429+
this._mark('terminal/willGetTerminalLayoutInfo');
429430
const layoutInfo = await backend.getTerminalLayoutInfo();
430-
this._mark('code/terminal/didGetTerminalLayoutInfo');
431+
this._mark('terminal/didGetTerminalLayoutInfo');
431432
backend.reduceConnectionGraceTime();
432-
this._mark('code/terminal/willRecreateTerminalGroups');
433+
this._mark('terminal/willRecreateTerminalGroups');
433434
await this._recreateTerminalGroups(layoutInfo);
434-
this._mark('code/terminal/didRecreateTerminalGroups');
435+
this._mark('terminal/didRecreateTerminalGroups');
435436
// now that terminals have been restored,
436437
// attach listeners to update remote when terminals are changed
437438
this._attachProcessLayoutListeners();
@@ -442,13 +443,13 @@ export class TerminalService implements ITerminalService {
442443
if (!localBackend) {
443444
return;
444445
}
445-
this._mark('code/terminal/willGetTerminalLayoutInfo');
446+
this._mark('terminal/willGetTerminalLayoutInfo');
446447
const layoutInfo = await localBackend.getTerminalLayoutInfo();
447-
this._mark('code/terminal/didGetTerminalLayoutInfo');
448+
this._mark('terminal/didGetTerminalLayoutInfo');
448449
if (layoutInfo && layoutInfo.tabs.length > 0) {
449-
this._mark('code/terminal/willRecreateTerminalGroups');
450+
this._mark('terminal/willRecreateTerminalGroups');
450451
await this._recreateTerminalGroups(layoutInfo);
451-
this._mark('code/terminal/didRecreateTerminalGroups');
452+
this._mark('terminal/didRecreateTerminalGroups');
452453
}
453454
// now that terminals have been restored,
454455
// attach listeners to update local state when terminals are changed
@@ -466,14 +467,15 @@ export class TerminalService implements ITerminalService {
466467
let terminalInstance: ITerminalInstance | undefined;
467468
let group: ITerminalGroup | undefined;
468469
for (const terminalLayout of terminalLayouts) {
469-
this._mark(`code/terminal/willRecreateTerminal/${terminalLayout.terminal?.id}`);
470-
if (this._lifecycleService.startupKind !== StartupKind.ReloadedWindow && terminalLayout.terminal?.type === 'Task') {
470+
const attachPersistentProcess = terminalLayout.terminal!;
471+
if (this._lifecycleService.startupKind !== StartupKind.ReloadedWindow && attachPersistentProcess.type === 'Task') {
471472
continue;
472473
}
474+
this._mark(`terminal/willRecreateTerminal/${attachPersistentProcess.id}`, `pid: ${attachPersistentProcess.pid}`);
473475
if (!terminalInstance) {
474476
// create group and terminal
475477
terminalInstance = await this.createTerminal({
476-
config: { attachPersistentProcess: terminalLayout.terminal! },
478+
config: { attachPersistentProcess },
477479
location: TerminalLocation.Panel
478480
});
479481
group = this._terminalGroupService.getGroupForInstance(terminalInstance);
@@ -483,11 +485,11 @@ export class TerminalService implements ITerminalService {
483485
} else {
484486
// add split terminals to this group
485487
terminalInstance = await this.createTerminal({
486-
config: { attachPersistentProcess: terminalLayout.terminal! },
488+
config: { attachPersistentProcess },
487489
location: { parentTerminal: terminalInstance }
488490
});
489491
}
490-
this._mark(`code/terminal/didRecreateTerminal/${terminalLayout.terminal?.id}`);
492+
this._mark(`terminal/didRecreateTerminal/${attachPersistentProcess.id}`, `pid: ${attachPersistentProcess.pid}`);
491493
}
492494
const activeInstance = this.instances.find(t => {
493495
return t.shellLaunchConfig.attachPersistentProcess?.id === groupLayout.activePersistentProcessId;
@@ -926,7 +928,13 @@ export class TerminalService implements ITerminalService {
926928
const isPtyTerminal = options?.config && 'customPtyImplementation' in options.config;
927929
const isLocalInRemoteTerminal = this._remoteAgentService.getConnection() && URI.isUri(options?.cwd) && options?.cwd.scheme === Schemas.vscodeFileResource;
928930
if (!isPtyTerminal && !isLocalInRemoteTerminal) {
931+
if (this._connectionState === TerminalConnectionState.Connecting) {
932+
this._mark(`terminal/willGetProfiles`);
933+
}
929934
await this._terminalProfileService.profilesReady;
935+
if (this._connectionState === TerminalConnectionState.Connecting) {
936+
this._mark(`terminal/didGetProfiles`, `count: ${this._terminalProfileService.availableProfiles.length}`);
937+
}
930938
}
931939
}
932940

0 commit comments

Comments
 (0)