Repository navigation
Fix: Accurate memory statistics for arena allocators (#608) - #717
Merged
Merged
Conversation
…ator_gt` (unum-cloud#608) The previous `total_allocated()` reverse-engineered the total by dividing `last_capacity_` by the capacity multiplier in a loop. This was inaccurate when `ceil2(extended_bytes)` produced larger-than-expected arena sizes, causing the reverse calculation to undercount. Add a `total_allocated_` member that is incremented on each arena allocation and returned directly, making the method O(1) and exact.
Add `memory_stats_t` to `index_dense_gt` returning separate allocated, wasted, and reserved byte counts for both the graph tape allocator (alignment 64) and the vectors tape allocator (alignment 8).
Add `MemoryStats` shared struct to the cxx bridge and wire it through `NativeIndex::memory_stats()` in C++ to `Index::memory_stats()` in Rust, giving Rust callers per-tape allocated/wasted/reserved breakdowns.
3 tasks done
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.
Fixes #608 —
total_allocated()inmemory_mapping_allocator_gtwas reverse-engineering totals by dividing capacity in a loop, producing wrong results whenceil2()caused non-uniform capacity jumps.Changes
index_plugins.hpp— Replace the reverse-engineering loop with atotal_allocated_member incremented on each arena allocation. Handled in move ops andreset().index_dense.hpp— Addmemory_stats_tstruct andmemory_stats()method returning per-tape (graph / vectors) breakdowns of allocated, wasted, and reserved bytes.rust/lib.{hpp,cpp,rs}— Exposememory_stats()through the cxx bridge as a sharedMemoryStatsstruct with 6 fields, wired fromNativeIndexto the high-levelIndexwrapper.All C++ and Rust tests pass.