cpu-profile-analysis

Analyze V8 CPU profiles and Chrome DevTools trace files to find performance bottlenecks.

Updated Apr 14, 2026
One-click install
npx skills add https://github.com/jimeh/hucode --skill cpu-profile-analysis-jimeh
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cpu-profile-analysis
Source: https://github.com/jimeh/hucode/tree/main/.github/skills/cpu-profile-analysis
Command: npx skills add https://github.com/jimeh/hucode --skill cpu-profile-analysis-jimeh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Performance profile files like .cpuprofile and Trace-*.json are massive, dense JSON structures that are impractical to inspect manually, making it hard to pinpoint slow functions, long tasks, or rendering bottlenecks. ## Core Features & Use Cases - CPU Profile Analysis: Parse V8 sampling profiler data to compute self-time per function, identify activity regions, and compare code paths. - DevTools Trace Analysis: Extract user timing marks, long tasks, layout/paint events, GC pressure, and input latency from Chrome Trace Event Format files across Renderer, Browser, and GPU processes. - Huge File Handling: Buffer-based parsing strategies for profiles exceeding V8's ~512MB string limit. - Use Case: Given a 150MB Trace-*.json from VS Code's Electron DevTools, identify which functions block the main thread during editor startup and measure time between code/willResolveTextFileEditorModel milestones. ## Quick Start Analyze the attached Trace-2024.json file and tell me which functions consume the most CPU time on the renderer main thread.

Frequently Asked Questions about cpu-profile-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I analyze a .cpuprofile file to find slow functions?▼

Parse the JSON to build a node map from the nodes array, then walk samples and timeDeltas to compute self-time per function. Sort functions by self-time descending to find the top cost centers, filtering out idle, program, and garbage collector frames.

What is the difference between a .cpuprofile and a Trace-*.json file?▼

A .cpuprofile contains only V8 sampling profiler data (nodes, samples, timeDeltas). A Trace-*.json uses the Chrome Trace Event Format and additionally includes layout/paint events, user timing marks, GC events, input events, and multi-process data from Browser, Renderer, and GPU processes.

Why does JSON.parse fail on large trace files?▼

V8 cannot create strings larger than roughly 512MB, so readFileSync with utf8 encoding fails on huge profiles. Read the file as a raw Buffer instead, scan for JSON key boundaries by bytes, and parse individual sections or events as small sub-buffers.

How do I find long tasks blocking the main thread in a Chrome trace?▼

Filter traceEvents for RunTask events with phase X on the CrRendererMain thread where dur exceeds 50000 microseconds (50ms). Sort by duration descending to surface the most expensive tasks blocking rendering and input.

Can I extract CPU profile data from a DevTools trace file?▼

Yes. Trace files embed the full CPU profile as Profile and ProfileChunk events in the disabled-by-default-v8.cpu_profiler category. Merge the nodes, samples, and timeDeltas from all chunks to reconstruct a complete cpuprofile-equivalent structure.