lean-bench

5.6. Picking the right cache mode🔗

The benchmark's declared cacheMode flows through to the child:

  • cacheMode := .warm (default) — the autotuner picks an inner repeat count and runs the function many times in one process. This is what you want for perf record / samply (dense profile) and for perf stat (steady-state counters).

  • cacheMode := .cold — the child runs the function exactly once. This is what you want when you specifically care about first-call costs: cache-cold paths, lazy initialization, JIT-style patterns. The downside is that the profile is very thin — consider --cache-mode cold plus a longer perf record run, or use a different profiler altogether (e.g., bpftrace watching a uprobe).

Pin from the CLI per run:

$ lake exe bench profile myFib --param 1024 \
    --cache-mode cold --profiler "perf record -F 999 -g --"