chatPerf.ts ×3

Frontier kind: Code frontier

unlabeled · c_fc5296eacc39

349 tests · 7323 LOC · 37 files · introduces 0 tests · 92 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
3 ranges92 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
890 ranges7323 lines · 37 files · Browse complete extent
All tests (intent)
349 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 92 introduced LOC across 3 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/chatPerf.ts 92 introduced LOC · 3 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- chatPerf.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { mark, clearMarks } from '../../../../base/common/performance.js';
7 > import { URI } from '../../../../base/common/uri.js';
8 > import { chatSessionResourceToId } from './model/chatUri.js';
9 >
10 > const chatPerfPrefix = 'code/chat/';
11 >
12 > /** Tracks all mark names emitted per session so they can be cleared individually. */
13 > const chatMarksBySession = new Map<string, Set<string>>();
14 >
15 > /**
16 > * Well-defined perf scenarios for chat request lifecycle.
17 > * Each mark is a boundary of a measurable scenario — don't add marks
18 > * without defining what scenario they belong to.
19 > *
20 > * ## Scenarios
21 > *
22 > * **Time to UI Feedback** (perceived input lag):
23 > * `request/start` → `request/uiUpdated`
24 > *
25 > * **Instruction Collection Overhead**:
26 > * `request/willCollectInstructions` → `request/didCollectInstructions`
27 > *
28 > * **Extension Activation Wait** (first-request cold start):
29 > * `code/chat/willWaitForActivation` → `code/chat/didWaitForActivation`
30 > * (global marks, not session-scoped — emitted via {@link markChatGlobal})
31 > *
32 > * **Time to First Token** (the headline metric):
33 > * `request/start` → `request/firstToken`
34 > *
35 > * **Total Request Duration**:
36 > * `request/start` → `request/complete`
37 > *
38 > * **Agent Invocation Time** (LLM round-trip):
39 > * `agent/willInvoke` → `agent/didInvoke`
40 > */
41 > export const ChatPerfMark = {
42 > /** User pressed Enter / request initiated */
43 > RequestStart: 'request/start',
44 > /** Request added to model → UI shows the message */
45 > RequestUiUpdated: 'request/uiUpdated',
46 > /** Begin collecting .instructions.md / skills / hooks */
47 > WillCollectInstructions: 'request/willCollectInstructions',
48 > /** Done collecting instructions */
49 > DidCollectInstructions: 'request/didCollectInstructions',
50 > /** First streamed response content received */
51 > FirstToken: 'request/firstToken',
52 > /** Response fully complete */
53 > RequestComplete: 'request/complete',
54 > /** Agent invoke begins (LLM round-trip start) */
55 > AgentWillInvoke: 'agent/willInvoke',
56 > /** Agent invoke returns (LLM round-trip end) */
57 > AgentDidInvoke: 'agent/didInvoke',
58 > } as const;
59 >
60 > /**
61 > * Emits a performance mark scoped to a chat session:
62 > * `code/chat/<sessionResource>/<name>`
63 > *
64 > * Marks are automatically cleaned up when the corresponding chat model is
65 > * disposed — see {@link clearChatMarks}.
66 > */
67 > export function markChat(sessionResource: URI, name: string): void {
68 const sessionId = chatSessionResourceToId(sessionResource);
69 const fullName = `${chatPerfPrefix}${sessionId}/${name}`;
76 mark(fullName);
77 }
79 > /**
80 > * Clears all performance marks for the given chat session.
81 > * Called when the chat model is disposed.
82 > */
83 > export function clearChatMarks(sessionResource: URI): void {
84 const sessionId = chatSessionResourceToId(sessionResource);
85 const names = chatMarksBySession.get(sessionId);
91 }
92 }
94 > /**
95 > * Well-defined one-time global perf marks (not scoped to a session).
96 > * These are emitted via {@link markChatGlobal} and are never cleared.
97 > */
98 > export const ChatGlobalPerfMark = {
99 > /** Begin waiting for chat extension activation (SetupAgent) */
100 > WillWaitForActivation: 'willWaitForActivation',
101 > /** Extension activation + readiness complete (SetupAgent) */
102 > DidWaitForActivation: 'didWaitForActivation',
103 > } as const;
104 >
105 > /**
106 > * Emits a global (non-session-scoped) performance mark:
107 > * `code/chat/<name>`
108 > *
109 > * Used for one-time marks like activation that should persist across requests.
110 > */
111 > export function markChatGlobal(name: string): void {
112 mark(`${chatPerfPrefix}${name}`);
113 }