Choosing a profiler or tracer
medium 7 minThe tool must observe the event that could explain the symptom.
Video lesson · Chapter 1 of 4
The CPU profile misses the longest wait
Theory
Read or listen first. About 2 min.
What it is
The tool must observe the event that could explain the symptom. A CPU sampler sees a running thread. An off-CPU profile can attribute sleep intervals to the stack where a thread blocked. A trace records selected events in sequence. Sample rates, aggregation keys and attachment scope change both cost and the conclusions a capture supports.
Why it exists
Latency rises while CPU flame graphs remain similar. Use utilization, saturation and errors to decide which resource merits closer observation. Bound tracing overhead on one replica and correlate the waiting stack with the lock owner. Captures can contain payloads or memory, so choose minimal fields and restrict access to incident artifacts.
If the worker is running during the missing interval, sample CPU stacks at representative load and correlate with request class.
The CPU profile misses the longest wait
Inside this chapter
- The USE Method: Utilization, Saturation, and Errors
- Check how busy a resource is, how much work waits and what errors it reports. Apply the three questions to each plausible resource at the correct scope.
- Sampling vs. Aggregation
- Sampling estimates a population from observations. Aggregation summarizes observations using chosen groups. A perfectly aggregated biased sample still gives a biased view of the population.
- perf tool usage
- Perf can sample hardware or software events and collect stacks. Symbols, permissions and the selected event determine whether a captured profile answers the incident question.
- eBPF (Extended Berkeley Packet Filter) for kernel tracing
- Kernel tracing can summarize selected events close to where they happen. Instrument narrowly, measure overhead and check for dropped observations before treating a count as exact.
- Flame Graphs for CPU bottleneck visualization
- A wide CPU stack shows many samples in that stack and its descendants. Flame width on an off-CPU graph represents a different quantity, so check the profile type.
- Core Dumps and debugging with gdb
- A core dump captures process state around termination. With matching symbols it can explain a crash stack. Access, retention and collection size need careful control.
- strace and ltrace for system call tracing
- System-call and library-call traces observe different interfaces. Use targeted timing or error counts when argument payloads would add overhead or unnecessary data exposure.
- tcpdump and Wireshark for network debugging
- Packet metadata can distinguish handshake, retransmission and application waits for an authorized service. Correlate both endpoints and use the narrowest useful capture interval.
- Continuous Profiling (Pyroscope, Parca)
- Continuous profiles permit retrospective comparison before and during a regression. Version labels, representative traffic and bounded profiling overhead determine their diagnostic value.
How it works
Step through the idea, or press Play.
Choose a resource. Select a resource that could explain the missing work or time.
Understand it
Worked incident
The CPU profile misses the longest wait
| Observation | Off-CPU lock wait (ms) | Interpretation |
|---|---|---|
| Baseline | 2 | The request spends little time blocked. |
| Incident | 460 | An off-CPU observation locates a long wait beneath the request handler. |
| After intervention | 12 | Reduce the owner’s critical section and verify off-CPU time and request latency together. |
Choose the next investigation
Summary
The whole topic in one minute.
A sleeping thread cannot accumulate CPU samples. The missing wall time is the quantity the investigation must account for.
If the worker is running during the missing interval, sample CPU stacks at representative load and correlate with request class.