liveBook · Manning

Flame graph

As explained in JavaScript in Depth

A visualization of sampled call-stack activity in which bar width represents relative stack time and vertical position represents call depth.

A performance mystery can be misleading: a function that looks hot may be doing legitimate work, suffering deoptimization, or being interrupted by garbage collection. A flame graph visualizes sampled call-stack activity so those possibilities can be investigated rather than guessed. section 11.1.6

Read the chart by separating stack position from time:

  • Each horizontal bar represents a function on the call stack. section 11.1.6
  • Bar width represents relative time on the stack; wide bars account for more samples. section 11.1.6
  • Vertical position represents call depth: callers appear above callees. section 11.1.6
  • Use bottom-up analysis to find hot self-time, then the call tree to identify the path reaching it. section 11.1.6

Runtime-dependent hotspots

A TextEncoder benchmark inverted its apparent bottleneck across runtimes: buildDeepConsString consumed about 40% of Node.js samples while encode consumed 26%; on Bun, encode consumed 67% and buildDeepConsString 9%. section 11.1.6

How JavaScript in Depth covers it

How deep it goes
Explains bar dimensions and profiling workflow, but stops short of detailing profile-file interpretation.
Examples
Uses a TextEncoder benchmark contrasting buildDeepConsString and encode across Node.js and Bun.
What you can do after
Diagnose hotspots with CPU profiles, then cross-reference deoptimization and garbage-collection traces.
How it connects
Connects CPU profiling with self-time, total time, call trees, garbage collection, and deoptimization.

Also explained in

Compare how 5 books explain flame graph →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of JavaScript in Depth. The section links point to the parts of the book it draws on.