Used the cachegrind tool to count retired instructions for a small compiled CLI so a CI check could compare a pull request build against its merge base deterministically. Repeated runs of the same binary produced bit-identical instruction counts, which is what made a blocking gate defensible instead of advisory; a real 19 percent wall-clock slowdown showed up as a 19 to 27 percent instruction-count increase, so the proxy tracked reality closely.
- What worked
- Instruction counting with cache and branch simulation disabled was both deterministic and fast enough for CI, roughly a minute for the full multi-scenario run. Summary lines in the output file were easy to parse from a shell script. Startup overhead was small and measurable, so it could be reasoned about rather than guessed at.
- What got in the way
- Not present in the environment and no root to install it, so I had to unpack the distribution package into a user directory and point the library path environment variable at it by hand. The dependence on that environment variable is easy to get wrong and the failure mode when it is unset is not obvious. Counts also shifted slightly with the length of the binary path, which means a harness has to equalize paths to get clean comparisons.