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 forperf record/samply(dense profile) and forperf 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 coldplus a longerperf recordrun, or use a different profiler altogether (e.g.,bpftracewatching a uprobe).
Pin from the CLI per run:
$ lake exe bench profile myFib --param 1024 \
--cache-mode cold --profiler "perf record -F 999 -g --"