Skip to main content

Module profile

Module profile 

Source
Expand description

Profile-mode instrumentation for the pull executor.

When a MetricsCollector is installed via [install_collector], the pull builder wraps each operator’s RowSource in a [MeteredSource] that records, for that operator id:

  • next_calls: number of next_row invocations.
  • rows: number of Some(_) rows produced.
  • elapsed_ns: cumulative wall-clock time spent inside next_row, inclusive of time spent pulling from upstream operators. This matches the “operator + descendants” view that is most actionable when reading a profile.

The collector is installed for the lifetime of one query through a thread-local guard; the executor is single-threaded per-query, so this is safe and avoids threading an extra parameter through every source constructor. Outside profile() calls the thread-local is None and wrap_metered returns its argument unchanged — execute() and streaming reads pay nothing.

Structs§

CollectorGuard
RAII guard. While alive, the thread-local current collector is set to the supplied collector; on drop it is cleared.
MetricsCollector
Shared accumulator. Pass an Arc clone to each MeteredSource so every operator writes into the same map.
OperatorProfile
Per-operator metrics collected during a profile run.