Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose amount of memory in chainbase_node_allocator's free list #51

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

spoonincode
Copy link
Member

Add a new accessor to chainbase, get_reclaimable_memory(), which returns the amount of memory tied up in all chainbase_node_allocators' free lists (this is memory not reported in get_free_memory())

@@ -398,6 +400,16 @@ namespace chainbase {
return _db_file.get_segment_manager()->get_free_memory();
}

size_t get_reclaimable_memory() const {
size_t ret = 0;
for(const unique_ptr<abstract_index>& ai_ptr : _index_map) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use _index_list instead of _index_map?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, yes, but we should also make the change elsewhere for consistency if doing that (I just copied what was being done elsewhere here). There likely isn't much of a benefit beyond skipping the if(!ai_ptr) check though (which is nice to skip!), since the _index_map is still -- practically speaking -- small and just another vector anyways.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, OK, it was not clear to me that the _index_map was small as well, because of the comment at line 561:
This is a full map (size 2^16) of all possible index designed for constant time lookup.

@spoonincode spoonincode merged commit 60757ff into main Aug 13, 2024
7 checks passed
@spoonincode spoonincode deleted the reclaimable_memory branch August 13, 2024 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants