Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-*.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating user timing marks.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "cpu-profile-analysis" skill from askskill: 1. Download https://raw.githubusercontent.com/microsoft/vscode/main/.github/skills/cpu-profile-analysis/SKILL.md 2. Save it as ~/.claude/skills/cpu-profile-analysis/SKILL.md 3. Reload skills and tell me it's ready
Analyze .cpuprofile files (V8 sampling profiler) and DevTools trace files (Trace-*.json, Chrome Trace Event Format) to find performance bottlenecks, compare code paths, and understand timing.
.cpuprofile or Trace-*.json file and wants to understand performancecode/didResolveTextFileEditorModel (trace files).cpuprofile: Top-level JSON with nodes, samples, timeDeltas keys. Created by the VS Code profiler.Trace-*.json: Top-level JSON with traceEvents array (and optional metadata). Created by Chrome/Electron DevTools (Performance tab). These are richer than .cpuprofile -- they contain CPU samples, layout/paint events, user timing marks, GC events, input events, and multi-process data.(idle), (program), or (garbage collector) represent no user code running..cpuprofile FilesA .cpuprofile is JSON with these top-level keys:
nodes: Array of call frame nodes forming a tree (each has id, callFrame, children)samples: Array of node IDs -- one per profiler tick, referencing the leaf (innermost) frametimeDeltas: Array of microsecond deltas between consecutive samplesstartTime / endTime: Absolute timestamps in microseconds$vscode: Optional VS Code metadataProfile and trace files can exceed V8's string limit (~512MB). Always check the file size first and choose the right parsing strategy:
import { readFileSync, statSync } from 'fs';
const stat = statSync(profilePath);
const sizeMB = stat.size / (1024 * 1024);
console.log(`File size: ${sizeMB.toFixed(0)}MB`);
let data;
if (sizeMB < 400) {
// Small enough for JSON.parse
data = JSON.parse(readFileSync(profilePath, 'utf8'));
} else {
// Too large -- use Buffer-based extraction (see "Handling Huge Files" section)
data = parseProfileFromBuffer(readFileSync(profilePath));
}
For files under ~400MB, JSON.parse(readFileSync(..., 'utf8')) works fine. For larger files, see the Handling Huge Files section below.
Profiles are often single-line JSON. Reformat for inspection (only if small enough):
if (sizeMB < 400) {
const data = JSON.parse(fs.readFileSync(profilePath, 'utf8'));
fs.writeFileSync(profilePath, JSON.stringify(data, null, 2));
}
Write a Node.js analysis script. Build these structures:
// Node lookup
const nodeMap = new Map(); // id -> node
const parentMap = new Map(); // id -> parent id
// Absolute timestamps from deltas
const timestamps = [data.startTime];
for (let i = 0; i < data.timeDeltas.length; i++) {
timestamps.push(timestamps[i] + data.timeDeltas[i]);
}
// Stack walker (leaf to root)
function getStack(sampleNodeId) {
const stack = [];
let id = sampleNodeId;
while (id !== undefined) {
const node = nodeMap.get(id);
if (node) stack.push(node.callFrame.functionName);
id = parentMap.get(id);
…
Analyze V8 heap snapshots to find memory leaks and object retention.
Merge session branch changes back into the base branch cleanly.
Launch VS Code OSS in isolation for automation and multi-process debugging.
Configure and manage agents, skills, prompts, and integrations in the editor.
Investigate failed PR checks and iteratively fix CI issues faster.
Update the GitHub Copilot CLI or SDK to a newer version.