Wherein we put some code into the flame.
@llogiq I’m learning a bunch about sampling profilers (specifically, perf on linux), and would love some examples of the sampling bias you mention!
Since sampling profilers only look at the call stack on certain points they may miss functions that are shorter than the interval length, or misreport functions that are about sqrt(2I) long. There has been some mathematical work prooving that they can never be precise.
On the other hand, instrumenting code comes with its own caveats: instrumentation may increase pressure on the instruction cache, change the “weight” of functions so they’re no longer inlined, which would then preclude further optimizations.
That’s why it’s best to have both sampling and instrumenting compilers available, so you can measure with both and inform your cost model from that.