feat(transfer): add ReorderBuffer stall-duration and queue-depth metrics#3984
Merged
Conversation
oferchen
added a commit
that referenced
this pull request
May 18, 2026
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
ReorderBufferStatsstruct with five counters:current_depth,peak_depth,stall_count,total_stall_nanos, anditems_deliveredto theBoundedReorderBufferin the transfer crateinsert()to track stall episodes (head-of-line blocking when a non-head item arrives into an empty buffer) and queue depth high-water marksmetrics()accessor returning a snapshot of all counters, plusmean_stall_nanos()derived accessorwith_clock()constructor for reproducible test assertions on stall timingImplements the observability layer from the design note in
docs/design/reorderbuffer-metrics-and-bypass.md(Part A). This is a prerequisite for the bypass optimization (#1886) - the metrics confirm whether head-of-line stalls are significant enough to justify bypassing the reorder buffer when--delay-updatesis off.Test plan
in_order_delivery_no_stall- verifies zero stalls and zero stall time for sequential insertionout_of_order_produces_stall- verifies stall count increments and stall duration accumulates when head is missingmultiple_stall_episodes- verifies distinct stall episodes are counted independentlypeak_depth_monotonically_nondecreasing- verifies peak depth never decreases across insertions and drainsqueue_depth_tracks_buffered_count- verifiescurrent_depthmatchesbuffered_count()items_delivered_counts_all_drained- verifies delivery counter accuracymean_stall_nanos_derived_correctly- verifies arithmetic on the derived accessorstale_insert_does_not_affect_metrics- verifies already-delivered sequence numbers do not perturb counterscounters_monotonic_across_permutation- all counters are monotonically non-decreasing across reversed permutationsidentity_permutation_zero_stalls- identity permutation always produces zero stalls