Conversation
Store aligned allocations directly in BufferLease and reuse MemoryReservation for individual buffers and aggregate staging charges. Field drop order frees the allocation before releasing its charge; allocation errors release the reservation automatically. Remove the optional allocation, BufferOwner enum, custom lease destructor, and redundant deallocation state while preserving alignment and memory-limit behavior. Validation: managed-memory and append-staging unit tests passed.
Remove test-only preparation and growth methods from buffer ownership types. Initialize engine test buffers through the same target and completion interfaces as production, and use prepared ranges for fixed staging buffers. Replace growth-only coverage with initialized-prefix, reuse, zero-initialization, and out-of-bounds access checks. Validation: cargo x check, cargo x test including extended tests, cargo x lint, and Linux all-targets workspace compilation with all features passed.
Give retained ownership fields, scope guards, and required trait parameters ordinary names with narrowly scoped expect attributes. Preserve drop order and guard lifetimes, including write-lock poisoning tests, and rename actively used fields without suppressions. Remove unused return-value bindings and obsolete benchmark parameters. Document the naming convention and the distinction between retained guards and discarded values in CONTRIBUTING.md. Validation: cargo x check, cargo x test including extended tests, cargo x lint, and Linux all-targets workspace compilation with all features passed.
Use underscore-prefixed local bindings for guards and resources retained until scope exit, removing redundant lint expectations without changing drop timing. Keep ordinary field names and precise dead-code expectations for unread ownership fields. Document this distinction in CONTRIBUTING.md. Unused trait parameters and unnecessary bindings retain their existing cleanup. Validation: cargo x check, cargo x test (including extended tests), cargo x lint, and Linux workspace compilation with all targets and features passed.
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
BufferLeasealways owns an allocation, but previously modeled it as optional and manually coordinated deallocation with separate fixed/transient ownership cases. Store the allocation directly and share one reservation guard with append staging. Field drop order frees the allocation before returning its budget; allocation failure releases the reservation automatically.Option<AlignedBuffer>,BufferOwner, and a custom lease destructorAlignedBufferfollowed by an optionalMemoryReservationMemoryReservation/ManagedMemory::reservefor aggregate and individual charges#[expect(dead_code)]or#[expect(unused_variables)]where neededLocal guards and resources retained until scope exit keep conventional underscore-prefixed bindings without extra lint attributes.
CONTRIBUTING.mdrecords the distinction between fields and local lifetime bindings. Guard lifetimes, field drop order, public APIs, and on-disk formats are preserved.Review
cache2/src/managed_memory.rsfirst. Existing coverage exercises memory limits, retained values, I/O completion, quarantined buffers, cancellation, and poisoned locks; updated buffer tests cover initialized prefixes, reuse, zeroed fixed buffers, and rejected out-of-bounds access.Validation:
cargo x check,cargo x test(including extended tests),cargo x lint, andcargo check --target x86_64-unknown-linux-gnu --workspace --all-targets --all-featurespassed.