Skip to content

Performance Methodology

The repository uses a conservative methodology for performance work: establish a correct baseline, isolate one variable, measure with the right preset, profile when causality is unclear, and publish only the conclusions that survive repetition.

Measurement contract

StepWhat to doWhy it matters
1. Reproducebuild and run the unmodified workload firstavoids optimizing a rumor
2. Choose the presetdebug, release, or relwithdebinfo depending on the questionkeeps results tied to an explicit execution mode
3. Validate correctnessrun the relevant tests before trusting numbersfast code that is wrong is noise
4. Measureuse benchmark executables or counters intentionallyprevents profiler cargo culting
5. Profileinspect call paths or counters when the cause is not obviousexplains why a result changed
6. Re-run and documentconfirm the effect and record the boundary conditionsmakes the claim auditable later

Preset selection matrix

PresetBest useTypical command
debugbaseline behavior and failing testscmake --preset=debug && cmake --build build/debug && ctest --preset=debug
releaserepresentative benchmark numberscmake --preset=release && cmake --build build/release && ctest --preset=release
relwithdebinfosymbolized profiling with meaningful optimizationcmake --preset=relwithdebinfo && cmake --build build/relwithdebinfo
asanmemory-safety investigationcmake --preset=asan && cmake --build build/asan && ctest --preset=asan
tsanconcurrency and memory-ordering investigationcmake --preset=tsan && cmake --build build/tsan && ctest --preset=tsan
ubsanundefined-behavior checks for low-level codecmake --preset=ubsan && cmake --build build/ubsan && ctest --preset=ubsan

Benchmark protocol

When the repository uses Google Benchmark-based executables, the protocol is straightforward:

  1. build an optimized binary, usually under build/release/examples/<module>/
  2. run the exact benchmark executable for the module you changed
  3. keep the dataset and compiler flags stable while you compare variants
  4. prefer multiple short, comparable runs over one anecdotal outlier

Representative examples include:

bash
./build/release/examples/02-memory-cache/aos_vs_soa_bench
./build/release/examples/04-simd-vectorization/simd_bench

A benchmark number is strong evidence only when the changed variable is clear. If code layout, compiler, dataset, and synchronization strategy all changed together, the result is descriptive but not diagnostic.

Profiling protocol

Use profiling when you need to explain a result, not merely display it.

Counter-oriented checks

bash
perf stat -d ./build/release/examples/02-memory-cache/aos_vs_soa_bench

Use this for quick checks on cache misses, branch behavior, or broad CPU-bound versus memory-bound suspicion.

Call-path inspection

bash
perf record -g --call-graph dwarf ./build/relwithdebinfo/examples/04-simd-vectorization/simd_bench
perf report

Use this when a benchmark changes but the cause is not obvious from source inspection.

FlameGraph workflow

bash
./tools/performance/generate_flamegraph.sh ./build/relwithdebinfo/examples/02-memory-cache/aos_vs_soa_bench

Use this when the explanation benefits from a durable visual artifact or when a wide call tree needs to be collapsed into a reviewable picture.

Interpreting results responsibly

Cache and memory work

For memory-layout changes, prefer explanations grounded in cache behavior, access locality, or false-sharing reduction. A speedup without that model is incomplete.

SIMD work

For vectorization, distinguish between:

  • compiler auto-vectorization
  • explicit intrinsics or wrapper-based SIMD
  • runtime dispatch that selects among ISA-specific implementations

Those are different engineering choices with different maintenance costs.

Concurrency work

For threading changes, never treat throughput alone as sufficient evidence. Pair results with synchronization reasoning and tsan where the change touched atomics, queues, or thread interaction.

External anchors

The repository's methodology is intentionally close to widely used public references:

Use the Research References page for a broader source shelf.

Released under the MIT License.