Skip to main content

Module stream

Module stream 

Source
Expand description

Bounded sample sink: drop and count, never block (#635).

§The app must not pay for a slow consumer

Samples flow from the probe thread to the daemon. If the daemon reads slowly — or stops reading — the producer must keep running. Blocking would push the consumer’s latency back into the profiled application, which inverts the entire point of a low-overhead probe: the observation would change the thing being observed, and a wedged daemon would become a wedged app.

So the sink is bounded, and when it is full SampleSink::offer drops the sample and increments a counter rather than waiting. Dropping is a normal, reported outcome, not an error — a consumer that sees dropped > 0 knows its view is incomplete and by how much.

§Why counted rather than silent

A profile missing samples looks exactly like a profile of a less busy program. Reporting the drop count is what lets a reader tell “the app was idle” from “we couldn’t keep up”.

Structs§

SampleSink
A bounded, non-blocking sink shared between producer and consumer.
SinkStats
What the sink has seen.

Constants§

DEFAULT_CAPACITY
Default queue depth.