Profiling with a sampling profiler instead of an instrumenting one

An instrumenting profiler records every function call, which changes the timings it is measuring — small fast functions look disproportionately expensive because the overhead is per call.

# instrumenting: exact call counts, distorted timings, huge overhead
# xdebug.profiler_enable_trigger=1  →  cachegrind.out.*

# sampling: statistical, low overhead, safe on a live system
# a periodic snapshot of the stack, aggregated

$ php -d extension=tideways.so app.php
$ # or, poor man's version: a periodic gdb/eu-stack over the fpm pool

Sampling is what belongs on a production host, because the overhead is a fraction of a percent and the results reflect real traffic rather than a synthetic request. Instrumenting is better for a specific question — how many times is this called — asked locally. Mixing them up is how a team spends a week optimising a function that appeared expensive because it was called two million times cheaply.