expose chainbase's new "reclaimable" memory in db_size_api
#526
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.
As of Leap 3.1, chainbase has not just the boost interprocess allocator (
segment_manager
) but alsochainbase_node_allocator
was is layered on top of thesegment_manager
. Both of these allocators maintain their own free list. But sincechainbase_node_allocator
sits on top ofsegment_manager
, the memory tied up inchainbase_node_allocator
's free list is considered used memory from the perspective ofsegment_manager
.The
chainbase_node_allocator
isn't used for everything, for example it's not used for the CoW strings. So various bits of code interface with the top layer but then other bits of code the bottom layer.And the
db_size_api
is looking at free memory in the bottom layer. That is, whendb_size_api
reports the free bytes it's reporting from the perspective of the bottom allocator even though the top allocator may have an extensive free list that would be used first for allocations against it. This can create some confusing and/or deceptive reports of memory usage.To help provide some visibility to this "used from perspective of bottom layer but free from perspective of top layer" memory, add a new field to
db_size_api
's response which is the total amount of memory in the top layer's free list. I've called this 'reclaimable' memory as a differentiator.Some other options I considered:
Don't have a new field in
db_size_api
's response but instead consider the top allocator's free list as part of the existingfree
/used
counts. The problem with this is that the bottom allocator's free memory is what governs nodeos falling over. So it would be deceptive to return, in an extreme example, 4GB of free memory but really only 256MB of that is free from the perspective of the bottom allocator (since some allocations do go directly to the bottom allocator).Don't allow
chainbase_node_allocator
's free list to grow limitless as it can now. This was my first preference. Howeverchainbase_node_allocator
allocates chunks of 64 items from the bottom allocator which means those chunks would need to be freed as a whole. Pretty much impossible. So insteadchainbase_node_allocator
would need to allocate 1-by-1 from the bottom allocator, but I'm unsure the time and space penalty for doing that. Without further research it would not be a change I'd blindly make.Needs AntelopeIO/chainbase#51