fix: exclude paused sections from instrumentation measurement#44
Conversation
Merging this PR will improve performance by ×72
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | BM_large_setup |
13,179,310.3 ns | 883.1 ns | ×15,000 |
| ⚡ | Simulation | BM_large_setup_teardown |
13,179,436.1 ns | 989.7 ns | ×13,000 |
| ⚡ | Simulation | BM_large_setup |
10,561,210.6 ns | 913.9 ns | ×12,000 |
| ⚡ | Simulation | BM_large_setup_teardown |
10,561,302.5 ns | 933.6 ns | ×11,000 |
| ⚡ | WallTime | BM_Vector_PushBack[10000] |
39.7 µs | 34 µs | +16.63% |
| ⚡ | WallTime | BM_Vector_Reserve[10000] |
36.1 µs | 31.2 µs | +15.46% |
| ⚡ | WallTime | BM_Vector_PushBack[1000] |
4.3 µs | 3.7 µs | +14.83% |
| ⚡ | WallTime | BM_Vector_Reserve[1000] |
3.6 µs | 3.2 µs | +14.59% |
| ⚡ | WallTime | BM_Vector_Reserve[100] |
390.6 ns | 350.7 ns | +11.36% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing cod-2033-codspeed-cpp-includes-setupteardown-in-instrumentation-mode (e47ecff) with main (f5a917f)
Congrats! CodSpeed is installed 🎉
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
|
646ed4c to
696eaa1
Compare
Greptile SummaryThis PR wires
Confidence Score: 4/5The core toggle-collect logic is correct for the common case, but a benchmark that ends its loop body with PauseTiming() will leave measurement_collecting=false; the next benchmark then starts with collection already logically off, corrupting its instruction count. One targeted fix to measurement_start() resolves it. The missing reset of measurement_collecting between benchmarks means any test suite where a benchmark uses PauseTiming-for-teardown will silently record wrong instruction counts for the benchmark that follows it. This is a real, reproducible defect on the changed path — not a theoretical concern — but it only manifests in multi-benchmark runs with that teardown pattern. core/include/measurement.hpp — measurement_start() needs to reset measurement_collecting to true so subsequent benchmarks always begin with collection in the expected state. Important Files Changed
|
8f254f0 to
5f8b3af
Compare
|
I had not noticed that at the valgrind level there was only toggle. I dont think we should expose explicit start stop then, lgtm |
5f8b3af to
3212716
Compare
7241899 to
a091c87
Compare
a091c87 to
e47ecff
Compare
PauseTiming/ResumeTiming now stop/start Callgrind instrumentation in
CODSPEED_ANALYSIS mode, ensuring setup/teardown code is not included
in benchmark measurements.
Depends on CodSpeedHQ/instrument-hooks#29