Workflow for performance and memory evaluation in V8.
Use this skill when tasked with improving the performance or memory usage of a workload in V8. This workflow focuses on identifying bottlenecks and applying V8-side optimizations.
For performance analysis, you do NOT need to create a full implementation_plan.md until you are actually fixing the performance issue you've detected. Instead, maintain an Analysis Plan (e.g., in task.md or as a list of questions to answer) to guide the investigation.
Initialize the following tracks concurrently:
perf (e.g., perf stat, perf record).Use these flags to diagnose performance issues:
--prof: Generates profiling data (v8.log) for tick processor analysis.--trace-opt: Logs when functions are optimized by TurboFan/Maglev. Useful to check if hot functions are getting optimized.--trace-deopt: Logs when functions are deoptimized and the reason. Critical for fixing performance cliffs.--trace-ic: Logs inline cache state changes. High miss rates indicate polymorphic or megamorphic behavior.--trace-gc: Logs garbage collection events. High frequency indicates excessive allocations.--trace-maps: Logs map creation and transitions. Useful for debugging map stability issues.Crossbench is the central benchmark runner that should always be used to run things like JetStream.
~/crossbench, but could be anywhere. If not found in standard locations, ask the user for the path.poetry run cb instead of just running ./cb.py.# Run JetStream3 with a specific d8 binary
poetry run cb jetstream --browser=/path/to/d8 --env-validation=warn
--probe='v8.log' to generate a v8.log file.--probe='perf' to generate a linux-perf trace.poetry run cb describe probes to see all available probes.--env-validation=warn to bypass environment input prompts.poetry run cb describe to understand subcommands and probes.poetry run cb_validate_hjson -- file.hjson.poetry for Crossbench) is missing or failing, fall back to alternatives immediately (like jsb_run_bench) or ask the user, instead of spending many turns trying to fix the environment.In the jetski environment, you can also use the jsb_run_bench tool from v8-utils as an alternative for quick runs.
jsb_run_bench with paths to d8 binaries to compare performance.record: "perf" and record: "v8log".d8 --prof script.js or use Crossbench with --probe='v8.log'.tools/node-tick-processor v8.log or use v8log_analyze if available.For peak performance, it is often necessary to inspect the intermediate representations (IR) of the optimizing compiler (TurboFan or Turboshaft).
d8 --trace-turbo script.js or pass flags in Crossbench/jsb_run_bench. This generates JSON files containing the graph state at various optimization phases (e.g., turbo-*.json).go/turbolizer or in the V8 repository under tools/turbolizer).Beyond hotspots, look for areas where V8 can be improved to handle patterns better:
--trace-ic shows frequent misses, pivot to investigating object layout and stabilizing hidden classes.perf stats (cycles, instructions).