feat(fast_io): BGID recycling observability (#2296)#4362
Closed
oferchen wants to merge 1 commit into
Closed
Conversation
Free-list-first allocation already exists in BgidAllocator::allocate (see docs/audits/bgid-lifecycle.md sections 2 and 7); this change adds two atomic counters so callers can verify the recycling policy is in effect and operators can monitor steady-state churn. - BGID_REUSED_COUNT: incremented when allocate pops from the free-list. - BGID_FRESH_COUNT: incremented when allocate mints a new id from NEXT_BGID. Exhaustion (BgidExhausted) does not advance either counter. - Public accessors BgidAllocator::bgid_reused_count and BgidAllocator::bgid_freshly_allocated_count expose the snapshot values via the existing fast_io re-export. - Stub parity in io_uring_stub/buffer_ring.rs returns 0 for both so cross-platform callers compile without cfg-gating. Tests cover the three policy assertions called out in the BGE-4 spec: ten alloc/free/alloc cycles count at least ten reuses; 100 fresh allocations leave reused at 0; failed exhausted allocations leave both counters untouched.
4 tasks
Owner
Author
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
BGID_REUSED_COUNTandBGID_FRESH_COUNTatomic counters that record whether eachBgidAllocator::allocatecall was satisfied from the free-list or by minting fromNEXT_BGID.BgidAllocator::bgid_reused_count()andBgidAllocator::bgid_freshly_allocated_count()accessors via the existingfast_iore-export so benchmarks and operators can read the recycle ratio without touching the free-list mutex.io_uring_stub/buffer_ring.rsso cross-platform callers compile withoutcfg-gating.The free-list-first allocation path itself was already in place (see
docs/audits/bgid-lifecycle.mdsections 2 and 7, lines 197-203 inbuffer_ring.rs); this change adds the observability hooks that BGE-4 calls for so the existing recycling policy is bench-verifiable.Test plan
BgidAllocatorallocates 10, deallocates all, allocates 10 again:bgid_reused_count() >= 10,bgid_freshly_allocated_count() == 10.BgidAllocatorallocates 100 fresh with no deallocs:bgid_reused_count() == 0,bgid_freshly_allocated_count() == 100.cargo fmt --all.