Repository navigation
feat(engine): drain-parallel consumer instrumentation (force_insert + drain histograms) (#1545) - #4298
Merged
Conversation
…1545) Wires the metric prerequisites called out in docs/design/drain-parallel-consumer-thread.md section 7 (and the sequencing in section 10) into the production drain pipeline. - HistogramStats: pow-2 count buckets and microsecond-decade duration buckets, shared between the new metrics fields. - ReorderBuffer::force_insert now bumps a cumulative counter, exposed on the Metrics snapshot. Tracks the capacity-bound fallback that the design doc flags as a removal prerequisite. - ReorderBuffer::record_drain_batch / record_drain_pause publish into two histograms on every non-empty consumer drain. - DeltaConsumer publishes a live Metrics snapshot through an Arc<Mutex> and exposes it via DeltaConsumer::metrics for in-flight polling. - Unit tests cover the force_insert counter (including the bypass and out-of-window paths), the powers-of-two batch buckets, and the microsecond decade pause buckets. End-to-end tests on DeltaConsumer verify the synthetic backpressure path drives force_insert_count above zero and that the batch histogram accumulates samples covering every delivered item.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
…1545) (#4298) Wires the metric prerequisites called out in docs/design/drain-parallel-consumer-thread.md section 7 (and the sequencing in section 10) into the production drain pipeline. - HistogramStats: pow-2 count buckets and microsecond-decade duration buckets, shared between the new metrics fields. - ReorderBuffer::force_insert now bumps a cumulative counter, exposed on the Metrics snapshot. Tracks the capacity-bound fallback that the design doc flags as a removal prerequisite. - ReorderBuffer::record_drain_batch / record_drain_pause publish into two histograms on every non-empty consumer drain. - DeltaConsumer publishes a live Metrics snapshot through an Arc<Mutex> and exposes it via DeltaConsumer::metrics for in-flight polling. - Unit tests cover the force_insert counter (including the bypass and out-of-window paths), the powers-of-two batch buckets, and the microsecond decade pause buckets. End-to-end tests on DeltaConsumer verify the synthetic backpressure path drives force_insert_count above zero and that the batch histogram accumulates samples covering every delivered item.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
…1545) (#4298) Wires the metric prerequisites called out in docs/design/drain-parallel-consumer-thread.md section 7 (and the sequencing in section 10) into the production drain pipeline. - HistogramStats: pow-2 count buckets and microsecond-decade duration buckets, shared between the new metrics fields. - ReorderBuffer::force_insert now bumps a cumulative counter, exposed on the Metrics snapshot. Tracks the capacity-bound fallback that the design doc flags as a removal prerequisite. - ReorderBuffer::record_drain_batch / record_drain_pause publish into two histograms on every non-empty consumer drain. - DeltaConsumer publishes a live Metrics snapshot through an Arc<Mutex> and exposes it via DeltaConsumer::metrics for in-flight polling. - Unit tests cover the force_insert counter (including the bypass and out-of-window paths), the powers-of-two batch buckets, and the microsecond decade pause buckets. End-to-end tests on DeltaConsumer verify the synthetic backpressure path drives force_insert_count above zero and that the batch histogram accumulates samples covering every delivered item.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…1545) (#4298) Wires the metric prerequisites called out in docs/design/drain-parallel-consumer-thread.md section 7 (and the sequencing in section 10) into the production drain pipeline. - HistogramStats: pow-2 count buckets and microsecond-decade duration buckets, shared between the new metrics fields. - ReorderBuffer::force_insert now bumps a cumulative counter, exposed on the Metrics snapshot. Tracks the capacity-bound fallback that the design doc flags as a removal prerequisite. - ReorderBuffer::record_drain_batch / record_drain_pause publish into two histograms on every non-empty consumer drain. - DeltaConsumer publishes a live Metrics snapshot through an Arc<Mutex> and exposes it via DeltaConsumer::metrics for in-flight polling. - Unit tests cover the force_insert counter (including the bypass and out-of-window paths), the powers-of-two batch buckets, and the microsecond decade pause buckets. End-to-end tests on DeltaConsumer verify the synthetic backpressure path drives force_insert_count above zero and that the batch histogram accumulates samples covering every delivered item.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docs/design/drain-parallel-consumer-thread.md(section 7 / sequencing step 1) ahead of any topology change to thedelta-drain+delta-reorderpair.force_insertcumulative counter onReorderBufferplus twoHistogramStats(powers-of-two batch sizes, microsecond-decade pauses) recorded by the consumer drain loop.Metricssnapshot throughDeltaConsumer::metricsso operators can poll the new counters without waiting for transfer completion.Why
The design doc flags these counters as a removal-prerequisite for
force_insertand a diagnostic for head-of-line pressure. Landing them as a focused refactor lets follow-up topology work (single-thread consumer, SPSC ring) ship with before/after numbers from the same surface area.Implementation notes
HistogramStatsis a singleCopystruct with two scale variants. Sampling is allocation-free (one bucket bump per observation) and snapshots are returned by value throughMetrics.last_drain_atanchor; only non-empty drain iterations record a batch sample and the elapsed pause, so the histograms reflect actual delivered work rather than idle polling.Arc<Mutex<Metrics>>. Lock contention is bounded - one publish per drain iteration /force_insert, one read permetrics()call - and the lock is never held across I/O.Test plan
cargo fmt --allforce_insert_count_*,drain_batch_histogram_records_powers_of_two,drain_pause_histogram_records_microsecond_decades,metrics_force_insert_counter_increments_under_backpressure,metrics_drain_batch_histogram_accumulates