Every engineer has taken a profile. Far fewer have taken one that answered the question actually being asked. This chapter is about the gap: why a single host's profile is statistically unable to see most regressions, why CPU flame graphs explain a minority of most latency problems, what eBPF really costs and where its stacks lie, why a mutex is a queue with a hard ceiling, how container CPU limits create latency modes that no profiler can see, and a method for going from a flame graph to a fix whose size you predicted in advance.
The mental model most people carry is that a profile is a measurement. It is an estimate. A sampling profiler interrupts each CPU at some frequency, records a stack, and counts. The share of samples landing in a frame estimates the share of CPU spent there, and like any proportion estimated from counts, its error shrinks as 1/√k where k is the number of hits in that frame. That single fact explains why continuous, fleet-wide profiling is not a luxury version of running pprof by hand; it is the only configuration in which most interesting questions become answerable.
Run the numbers. At 100 Hz on one fully busy core for a minute, you collect 6,000 samples. A function at 1% of CPU gets about 60 of them. Comparing two such profiles, the smallest change you can distinguish from noise at roughly two sigma is about 2·√2/√60, near ±37%. Your 5% regression in that function is invisible. A core-hour gets you to about ±5%. A fleet-hour across 200 hosts, 8 cores each at 50% busy, produces around 288 million samples, and a function at a tenth of a percent of CPU still collects 288,000 hits, enough to resolve half-percent changes. The diagram below is the whole argument for continuous profiling in one line.
Detectable Δ ≈ 2·√2 / √k for k hits, treating samples as independent. They are not (workloads are bursty and correlated), so the real curve sits above this one. The takeaway survives the caveat: a single host's profile cannot distinguish a 5% regression in a 1% function from noise; a fleet-hour can resolve changes in functions a thousand times smaller.
Two refinements matter in practice. First, samples are not independent; request mix is bursty and correlated, so the effective sample size is smaller than the raw count and the true curve sits above the idealised one. Aggregate across many hosts and longer windows rather than trusting one long run on one box. Second, the frequency is conventionally an odd number like 99 Hz rather than 100, so that sampling does not fall into lockstep with timer-driven work at round frequencies and systematically over- or under-count it. The same aliasing risk applies to any periodic activity in your own code: a batch flush every 10 ms sampled at exactly 100 Hz is either always seen or never seen.
The larger payoff is what fleet aggregation makes visible that no single service owner would ever look for. Google's published work is the reference here: Google-Wide Profiling (Ren et al., 2010) described always-on sampling across the fleet, and the later warehouse-scale characterisation by Kanev et al. (ISCA 2015) found that a "datacenter tax" of common low-level functions (memory movement, serialisation, compression, hashing, allocation, RPC plumbing) accounted for close to 30% of cycles. No team owns memmove. It never appears as a wide frame in any one service's flame graph because it is scattered across hundreds of callers. It only shows up when you invert the aggregation and sum leaf functions across everything you run.
1/√k
relative error, k = hits in frame
~3,200
hits/side to see a 5% change
99 Hz
avoid lockstep with timers
~30%
fleet cycles in shared 'tax' (Kanev 2015)
Architect's note · who pays for the profiler
One more bias to name: in managed runtimes, how the profiler takes the stack matters as much as how often. Profilers built on the JVM's safepoint-based stack APIs can only observe threads at safepoints, so a hot counted loop with its safepoint poll removed by the JIT is invisible and its time is attributed to whatever frame next reaches a safepoint. Tools that sample asynchronously (async-profiler via perf_events and AsyncGetCallTrace, JFR's own sampler) avoid that bias. If your fleet profiler and your ad-hoc profiler disagree about a JVM service, safepoint bias is the first hypothesis.
A typical request-serving thread in a service that calls a database, a cache and two downstreams spends most of its wall-clock time not running. On-CPU sampling sees only the running slices. Off-CPU analysis, pioneered in its modern form by Brendan Gregg, instruments the scheduler instead: record the stack and timestamp when a thread is switched out, compute the duration when it is switched back in, and sum durations by stack. The result is a flame graph whose width is time blocked, not CPU consumed.
The subtlety most people miss is that a thread has three states that matter, not two. It can be running, blocked (on I/O, a futex, a sleep), or runnable: woken, eligible, and waiting for a core. The standard off-CPU method measures from switch-out to switch-in, so it silently folds run-queue wait into whatever the thread was blocked on. A database call that took 5 ms on the wire and then waited 3 ms for a CPU appears as an 8 ms database stack.
A CPU flame graph explains 35% of this request. An off-CPU graph blames the database and the lock for 26 ms, but 7 of those ms were the thread already woken and waiting for a core — a scheduler problem that no amount of query tuning fixes.
Separating the two is cheap and underused. Per-thread run-queue delay is already accounted by the kernel: the second field of /proc/PID/task/TID/schedstat is cumulative nanoseconds spent runnable but waiting on a run queue (sample it at request start and end and you have run-queue delay per request for the cost of two file reads), and the scheduler wakeup-to-switch-in latency can be histogrammed with eBPF tools like runqlat. If run-queue delay is a material fraction of request latency, you are CPU-starved or badly scheduled, regardless of what utilisation dashboards say, and the fix is in 4.5, not in the code the off-CPU graph points at.
Two practical problems dominate real off-CPU work. The first is overhead: sched_switch fires on every context switch, and a busy host doing 200,000 switches a second spends a fifth of a core on the probe at one microsecond per event, and more once each event captures a user stack. The workable pattern is to aggregate by stack in the kernel, filter out blocks shorter than a threshold, and restrict to the target process. The second is idle threads. An off-CPU graph of a whole process is dominated by thread-pool workers parked on a condition variable waiting for work, epoll loops, and timer threads. That time is real but irrelevant. The graph that matters is off-CPU time of threads while they are serving a request, which requires request context: either tag samples with a span or request ID, or filter to stacks that pass through your request handler frames.
The next level is wakeup analysis. Knowing a thread slept 12 ms on a futex says who waited, not who was slow. Recording the waker's stack at sched_wakeup, and chaining wakers when the waker itself had been waiting, gives you the actual critical path: request thread waited on a lock, the lock holder was waiting on a log flush, the log flush was waiting on disk. That chain is the fix; the first link almost never is.
Illustrative timeline. Every request that touches the session lock during those 10 ms inherits the flush latency, so one slow device write becomes a latency spike across unrelated endpoints, and none of their CPU or off-CPU graphs mention the disk.
The chain has a stopping rule: follow wakers until you reach a link whose own wait is not explained by another thread, which is hardware (a device, an interrupt), a remote peer (a socket read), or a timer. That link is where the time was actually spent; everything above it is inherited latency. The failure mode this exposes is the most expensive one in the chapter because it spreads: once a durable write sits inside a shared lock, the device's latency distribution becomes the lock's hold-time distribution, and through 4.4's queueing math it becomes the tail of every endpoint that touches the lock. A p99.9 disk flush of tens of milliseconds, which is unremarkable on shared or network-attached storage, turns into a p99 regression on read endpoints that never do I/O. Wakeup tracing costs more than plain off-CPU tracing (two probes, two stacks), so run it targeted, per process and for minutes, not fleet-wide.
Pitfall · wall-clock profiles and the idle-thread swamp
eBPF made production kernel and user-space tracing safe enough to leave on: a verified program attaches to an event source, runs in kernel context, and writes to shared maps. The reason it is cheap when it is cheap is in-kernel aggregation. A profiler that increments a count in a hash map keyed by (pid, kernel stack id, user stack id) does bounded work per event and copies nothing to user space until the agent drains the map every few seconds. The same probe emitting a record per event to a ring buffer can be orders of magnitude more expensive at high event rates, and that is where most self-inflicted eBPF incidents come from.
perf_event (timer)
cost ∝ frequency, not traffic
tracepoint
stable ABI · cheap per hit
kprobe / fentry
any kernel fn · ABI drifts per kernel
uprobe / USDT
trap per hit · µs-order · dangerous on hot fns
kernel · verified BPF program
bpf_get_stackid() / walk user stack → key = (pid, kernel stack id, user stack id)
BPF hash map: key → count
aggregate in kernel · no per-event copy
per-event output (ring buffer per hit) is where overhead explodes
user-space agent
drain map every N s · map addrs via /proc/PID/maps (inside the container's mount ns) · ship build-ids, not symbols
the unwinding problem · what decides whether the stack is real
frame pointers
cheap walk · needs -fno-omit-frame-pointer / PreserveFramePointer
DWARF / .eh_frame
in-kernel table walk (newer agents) or 8 KB stack copy (perf dwarf)
JIT code
perf-PID.map / jitdump from the runtime, or frames show as hex
interpreters
native stack = eval loop; need runtime-aware unwinder or -X perf (Py 3.12+)
The event source sets the cost model. Timer-based sampling costs a function of frequency, independent of traffic, which is why it is the only thing safe to run fleet-wide unconditionally. Tracepoints are stable and cheap. Kprobes can attach almost anywhere in the kernel, but the functions they attach to are not an ABI and change between kernel versions, so an agent that works on one fleet generation silently loses coverage on the next. Uprobes are the dangerous one: each hit on an instrumented user-space instruction traps into the kernel, in the order of a microsecond depending on hardware and kernel. On a function called a million times a second across a host, that is a whole core, added directly to the request path. The classic incident is an engineer running a bpftrace one-liner against malloc or a hot RPC function on a production host to "just count calls", and watching p99 jump for as long as it runs.
Per-event costs are illustrative orders of magnitude; measure your own. Timer sampling sits two decades under the budget and does not move with traffic. A scheduler probe with stacks sits near it and scales with context-switch rate, so it is safe on a quiet host and not on a busy one. A uprobe on a hot allocator lands at several cores, directly on the request path.
The decision rule is a single multiplication done before attaching anything: events/s × cost per event against a budget, usually a fraction of a percent of the host. The event rate is the number people skip, and it is the one that can move three orders of magnitude between a staging box and a production host at peak. Measure the per-event cost rather than trusting a blog post: with the kernel.bpf_stats_enabled sysctl on, bpftool reports run_cnt and run_time_ns per program, which gives the BPF program's own cost per hit. It does not include the uprobe trap and context switch into the kernel, which for uprobes is most of the bill, so for those the honest measurement is an A/B on the target function's latency with and without the probe attached.
The agent's own failure modes are quieter and bias data rather than burning CPU. A stack-trace map is a fixed-size hash table; when it fills or two distinct stacks collide on a bucket, bpf_get_stackid returns an error and the sample is dropped unless the program asked to reuse the slot. The drops are silent, and they are not random: stacks seen early claim the slots, so a new hot path introduced by a deploy is exactly what gets under-counted. Perf ring buffers drop records under burst the same way. Before trusting a fleet profiler for regression detection, find out where it exports its drop and error counters, alert on them, and treat any profile window with material drops as unusable for diffs. The same applies to the symbolisation step in 4.7: an "unknown" frame bucket that grows after a deploy is a pipeline regression, not a code one.
The less discussed problem is stack unwinding, and it decides whether your profile is true. The kernel's cheap unwinder follows frame pointers. For a decade, most distribution packages and many language toolchains compiled with frame pointers omitted to recover a register, so stacks through libc, OpenSSL or any system library came back truncated to one or two frames and time was misattributed to whatever frame survived. Fedora 38 and Ubuntu 24.04 reversed that default specifically because of profiling, and the JVM has offered -XX:+PreserveFramePointer for years. Where frame pointers are absent, the options are copying a chunk of the user stack per sample and unwinding with DWARF later (perf's dwarf mode copies 8 KB per sample by default, which is expensive in CPU and storage), or converting .eh_frame into compact unwind tables loaded into BPF maps and unwinding in the kernel, which newer agents such as Parca's and the OpenTelemetry eBPF profiler do. The cost moves from every sample to every newly seen binary: tables are built when an executable is first seen, so the overhead concentrates on hosts with heavy process churn (CI runners, batch, shell-heavy jobs) rather than on long-lived servers.
JIT-compiled and interpreted code adds two more failure modes. JIT frames have no symbols on disk, so the runtime must publish them (a perf map file or jitdump) or they appear as bare addresses. Interpreters are worse: the native stack of a Python process is the evaluation loop repeated, so a native-only profiler reports that all time is spent in the interpreter. Python 3.12 added a perf trampoline mode (-X perf) that makes Python frames visible to native profilers; otherwise you need an agent that understands the interpreter's own frame structures.
Architect's note · containers and privileges
The cleanest way to reason about contention is to stop thinking of a lock as a code construct and treat it as a server. Acquisitions arrive at rate λ; the critical section is the service time S; utilisation of the lock is ρ = λ·S. Everything from Chapter 01 applies directly. With a 20 µs critical section, the lock can serve at most 50,000 acquisitions per second, on any number of cores. At 40,000/s it is 80% busy and the mean wait under M/M/1 assumptions is already four times the hold time; at 45,000/s it is nine.
Two corrections to the textbook model change what you should expect to see. Critical sections are closer to deterministic than exponential, and M/D/1 halves the M/M/1 wait; bursty arrivals (a batch of requests landing together, a timer firing across all workers) push it back up, so treat ρ/(1−ρ) as the right order of magnitude rather than a prediction. More important, a lock inside a service is a closed system: only N threads can contend, so the queue can never exceed N−1 and wait cannot explode the way the open-model curve suggests. It saturates instead. At ρ near 1 every thread spends most of its time queued, the lock admits exactly 1/S acquisitions per second, and additional offered load queues upstream in the thread pool or the accept backlog, where the lock profile cannot see it. That is why lock-bound services present as a throughput plateau with rising pool queueing, not as a latency spike on the lock itself.
Contention inflates the hold time itself: the lock word and the data it guards bounce between cores, so every added waiter makes each critical section slower. That shifts the whole curve left, which is the β (coherence) term of the Universal Scalability Law from Chapter 01 showing up inside a single mutex.
The practical signature is a throughput plateau below CPU saturation: you add instances or cores and requests per second barely move, while CPU stays at 50–60%. The second-order effect is what makes this worse than a textbook queue. Contention inflates S itself. The cache line holding the lock word, and the data the critical section touches, bounces between cores, and each transfer costs far more than a local cache hit. More waiters means longer critical sections means higher ρ: the curve shifts left as load rises. Adding cores to a contended service can reduce throughput, which is the coherence term of the Universal Scalability Law, observed from inside one mutex.
How contention shows up in profiles depends on the lock implementation, and that is why teams misread it. Adaptive mutexes spin briefly before parking. Short waits appear as on-CPU time in spin loops or in the lock's slow path, which looks like "the lock is expensive to call". Longer waits park on a futex and vanish from the CPU profile, appearing only off-CPU. A service can be lock-bound with no lock anywhere near the top of its CPU flame graph.
Runtime-native lock profilers exist and answer a question most people do not realise is ambiguous: whose stack do you want? Go has two. The block profile records the waiters: where goroutines sat blocked. The mutex profile attributes contention delay to the goroutine that held the lock and released it, so it points at the critical section that was too long. You nearly always want the second to find the fix and the first to measure the damage. JFR separates monitor contention (jdk.JavaMonitorEnter for synchronized) from parking (jdk.ThreadPark for java.util.concurrent locks); a JVM service that migrated from synchronized to ReentrantLock moves its contention from one event type to the other, and dashboards built on one go quiet.
The fixes follow from the queueing view, in order of leverage. Shrink S: move allocation, logging, I/O and anything that can fault out of the critical section; a page fault or a log flush inside a lock turns a 2 µs hold into a millisecond hold for every waiter. Reduce λ: batch acquisitions, or give each core its own shard and merge rarely. Split the server: stripe the lock by key so ρ divides by the stripe count. Replace the lock only last; lock-free structures move contention to CAS retry loops on the same contended cache line, which is still the coherence term.
Pitfall · the lock holder was not running
Kubernetes CPU limits are implemented with CFS bandwidth control: a quota of CPU time per period, 100 ms by default. A 2-CPU limit is 200 ms of CPU time per 100 ms of wall time, shared by every thread in the cgroup. The failure mode follows from the arithmetic. A process that sizes its parallelism from the host's cores rather than its quota (Go before 1.25 without automaxprocs, a JVM with container support disabled or predating it, most native thread pools and anything that reads nproc) runs far more threads than the quota can feed. On a 32-core node, when a collection cycle or a burst of work fires, 16 threads run in parallel and burn the 200 ms quota in 12.5 ms of wall time. For the remaining 87.5 ms of that period, nothing in the container runs. Any request that arrives in that gap waits for the next period.
Throttled time is invisible to every sampler: no thread is running, and none is blocked in a way sched_switch attributes to your code. It shows up in cgroup cpu.stat (nr_throttled, throttled_usec), not in any profile. If a lock holder is among the frozen threads, every waiter on that lock pays the full gap too.
The result is a latency mode: a secondary hump in the latency distribution at tens of milliseconds, appearing at modest average utilisation, because averages over one second or one minute are far coarser than the 100 ms enforcement window. Nothing in a CPU profile explains it, because throttled threads are neither running nor blocked on anything the profiler attributes to your code. The evidence lives in cpu.stat in the cgroup (nr_periods, nr_throttled, throttled_usec on cgroup v2; throttled_time in ns on v1), and it has to be read as a rate over short windows, because a monthly-average throttle ratio hides exactly the bursts that matter. A useful rule: if nr_throttled/nr_periods is more than a few percent on a latency-sensitive service, treat throttling as the leading hypothesis for any tail regression before reading a single flame graph.
The arithmetic explains why a few percent is the right threshold, and it lands on percentiles directly. With P threads runnable against a limit of L CPUs, a burst exhausts the quota after period × L/P, so the stall is about period × (1 − L/P): 87.5 ms for 16 threads on a limit of 2, zero once parallelism is sized to the limit. The share of requests that land in a stall is the share of wall time spent stalled, the throttled-period ratio times the gap fraction. Illustratively, throttling in 10% of periods with 87.5 ms gaps puts about 8.75% of wall time in a gap. Requests arriving uniformly hit it with that probability and wait on average half the gap, about 44 ms, so the slowest ~9% of requests are in the mode and both p95 and p99 are set by it, not by your code. At a 1% throttle ratio the same gaps reach under 1% of requests: the p99 hovers on the edge of the mode and flaps between runs, which is how throttling presents as "noisy p99" long before anyone calls it a regression. A service with fan-out makes it worse, because the chance one of N backends is mid-gap grows with N (Chapter 03).
The fixes each trade something. Removing CPU limits while keeping requests is common advice and is right for many latency-sensitive services, but it gives up isolation from noisy neighbours and makes capacity less predictable. Sizing thread pools and GC parallelism to the limit rather than the host is almost always right, but it does not make the problem disappear: a runtime correctly sized to 2 threads still has JIT compiler, GC and I/O helper threads, and a limit of 2 with an application that genuinely has 4 runnable threads for 60 ms throttles just the same. Runtime-level detail is Chapter 05's territory. Burst allowances (cpu.max.burst in cgroup v2, added in the 5.14-era kernels) let a cgroup bank unused quota for short spikes. Shorter periods reduce the maximum stall but raise scheduler overhead. Also worth knowing: an older kernel bug around per-CPU quota slice expiry caused throttling of workloads that were nowhere near their limit; it was fixed around Linux 5.4 and widely backported, but fleets on old kernels still see it.
Throttling is the loudest scheduler effect, not the only one. Run-queue latency from oversubscribed nodes looks like slowness everywhere at once. CPU migration across sockets throws away warm caches and, on NUMA hosts, moves the thread away from its memory (Chapter 05). SMT siblings mean a core at "50% utilised" may already be sharing execution units with another tenant's thread. Network softirq processing pinned to a few cores can make those cores run hot and starve application threads scheduled there; that shows up as high softirq time on a subset of CPUs, which per-host averages hide.
100 ms
default CFS period
87.5 ms
stall: 16 threads vs 2-CPU quota
field 2
/proc/PID/schedstat = run-queue ns
nr_throttled
cgroup cpu.stat — alert on the ratio
Architect's note · the 'utilisation' lie compounds
The inverted (bottom-up) view is the one most teams skip and most need, because distributed costs like allocation, copying, hashing and serialisation are thin in every caller and only become wide when merged by leaf. The start is picking the right instrument for the symptom, because every instrument is honest about a different question.
The most common wasted week in performance work is the first row's instrument pointed at the second row's symptom: a CPU flame graph for a latency problem that is mostly not CPU.
Differential flame graphs between releases are the highest-leverage view, and they carry the most dangerous trap. Most tools normalise each profile to 100% and colour the difference in share. If you make one component faster, every other component's share grows, and the diff paints unchanged code red. The reverse happens during a traffic-mix shift: a real regression in a cheap endpoint is diluted by growth in an expensive one. The fix is to diff absolute cost per unit of work: CPU-ms per request, per message, per byte, with the denominator taken from the same window and population as the samples.
The same trap in reverse hides real regressions during a traffic-mix shift. The denominator has to be work done (requests, bytes, messages) from the same window, which means the profiler and the request counter must agree on the window and the population.
Then use the discipline that separates a day of work from a week of guesswork: state a hypothesis that predicts a magnitude. Not "JSON encoding looks slow" but "encoding is 14% of on-CPU samples on the request path; removing the second encode should cut CPU per request by about 7%", followed by what that does to latency and capacity. That forces three checks most investigations skip. Amdahl bound: a frame at 14% of CPU caps your CPU win at 14%, and if the request is 30% CPU, it caps your latency win at about 4%. Critical path: CPU in a background flusher is capacity, not latency; tie samples to request spans (pprof labels, JFR context, trace IDs) so you know which frames are on the path you care about. Falsifiability: after the change, the profile diff should show that frame shrinking by the predicted amount. If latency improves but the frame did not shrink, your fix worked for a reason you do not understand, and it will regress.
The Amdahl bound caps service time, and teams routinely treat it as a cap on latency, which is wrong in both directions. On a host near saturation, a CPU saving also lowers utilisation, and queueing delay responds non-linearly. Illustratively, for a CPU-bound request on a host at ρ = 0.8, a 7% cut in CPU per request takes ρ to about 0.74; under an M/M/1 approximation mean response time S/(1−ρ) goes from 5.0·S to about 3.6·S, a 27% latency win from a 7% CPU change. The same change at 30% utilisation is worth about 10%, barely more than the raw 7%. So the prediction has three numbers, not one: CPU per request (which should match the frame shrink), utilisation after the change, and latency, which follows from the first two via the curve in Chapter 01. The decision rule: when a service is latency-bound near saturation, a modest CPU win is worth more than it looks, and it should be priced against the alternative of adding capacity to lower ρ; when a service is lightly loaded, CPU work buys cores, not latency, and should be justified in dollars. The reverse also holds, and it is how a small regression turns into an incident: 7% more CPU per request at ρ = 0.8 takes ρ to about 0.86 and makes the mean close to 50% slower.
Real services are not M/M/1 and the tail moves more than the mean, so read the shape, not the values. The shape is the decision rule: below roughly ρ 0.5 a CPU change is a cost question priced in cores; above roughly 0.7 it is a latency question, and a regression the Amdahl view calls small is not.
The asymmetry is the part that belongs in a design review. A per-deploy CPU diff of +3% gets waved through because "3% is noise"; on a service running its bottleneck at ρ 0.8 it is a double-digit latency regression, and five such deploys a quarter compound. Conversely, on a lightly loaded service the right answer to a +3% regression may be to accept it and price the cores. The profile answers how much CPU moved; only the utilisation of the resource that is actually the bottleneck (cores under quota, a lock, a connection pool) tells you what that move is worth. Put that ρ next to every CPU diff.
Microbenchmarks are useful for iterating on a fix and weak as evidence for it. They run with warm caches, a fixed input distribution, no lock contention and no co-tenants, which removes most of what made the production frame wide. Validate in production: canary the change, compare per-request CPU and the latency distribution between canary and baseline over the same window, and confirm the profile diff. Chapter 07 covers turning that into automated regression detection in CI.
Pitfall · inlining and the missing frame
The operational shape is settled: a node agent sampling at tens of hertz per CPU with in-kernel aggregation, a collector that symbolises and labels, a store that keeps recent profiles at fine resolution and merges older ones, and query surfaces for top-N, diffs and trace-linked views. What teams get wrong is where the cost lands. Agent CPU is small when done correctly. The real bill is symbols, labels and retention.
node agent
eBPF sampler, tens of Hz/CPU · in-kernel stack map · flush every ~10 s as pprof
collector
symbolise by build-id against a symbol store · attach labels: service, version, pod, span
profile store
columnar · merge raw 10 s profiles into coarser windows as they age
consumers
fleet top-N · deploy diff · trace → profile · PGO / BOLT input
agent CPU
well under 1% of a host at tens of Hz when aggregated in kernel (verify on your kernel and stack depth)
storage (illustrative)
5,000 processes × 8,640 profiles/day × 30 KB ≈ 1.3 TB/day before merging
label cardinality
a span-id or user-id label defeats merging and multiplies storage — sample it, don't index it
Symbolise centrally. Ship stripped binaries to production, record each binary's GNU build-id, push debug info to a symbol store at build time (debuginfod is the standard protocol), and let the collector resolve addresses. This keeps production images small, avoids symbolisation work on every node, and makes profiles of last month's binaries still readable. The failure mode is the build that forgot to upload symbols: every profile of that release is hex addresses, discovered during the incident when you need them.
Labels are where the design decision lives. Service, version, region and endpoint are low-cardinality and cheap, and they unlock the diffs in 4.6. Per-request identifiers (span IDs, user IDs, tenant IDs) are high-cardinality; attached as indexed labels they prevent profiles from merging and multiply storage by orders of magnitude. The workable pattern is to attach span IDs to a sample of profiles, or keep them only for a short window, so "show me CPU for the traces above p99" works for recent incidents without paying for it on every sample forever. The OpenTelemetry project has been standardising profiles as a signal alongside traces and metrics, which is the direction for this linkage; check its maturity before building on it.
The last connection is the one that turns profiling from diagnostics into compounding returns: profile-guided optimisation from production data. Go has shipped PGO since 1.21, consuming ordinary pprof CPU profiles to guide inlining and devirtualisation, with gains the Go team describes as a few percent. For C and C++, AutoFDO and Meta's BOLT (now part of LLVM) use sampled production profiles to lay out hot code for better instruction-cache and branch behaviour, which matters most for large binaries with flat profiles where nothing stands out. A few percent across a fleet with no code change is exactly the kind of return that justifies the platform, and it only exists if representative production profiles are collected continuously.
tens of Hz
fleet sampling, per CPU
build-id
key for central symbolisation
~1.3 TB/day
illustrative raw profile volume, 5k procs
few %
typical PGO gain, no code change
Architect's note · the three reports worth automating
Design review · questions to ask of a profiling platform or a performance claim
Where next