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

allocator purge exposure ? #436

Open
devnexen opened this issue Dec 1, 2021 · 1 comment
Open

allocator purge exposure ? #436

devnexen opened this issue Dec 1, 2021 · 1 comment

Comments

@devnexen
Copy link
Contributor

devnexen commented Dec 1, 2021

jemalloc provides the ability to purge a specific arena via mallctl with the oid 'arena.[id].purge', so I was wondering if the feature closest to it would be LocalAllocator::flush() (or literally teardown in the upper level) and it was a good idea to expose such capability as C symbol ?

@mjp41
Copy link
Member

mjp41 commented Dec 1, 2021

The nearest bit is

static void handle_decay_tick(ChunkAllocatorState* state)
{
auto new_epoch = (state->epoch + 1) % NUM_EPOCHS;
// Flush old index for all threads.
ChunkAllocatorLocalState* curr = state->all_local;
while (curr != nullptr)
{
for (size_t sc = 0; sc < NUM_SLAB_SIZES; sc++)
{
auto& old_stack = curr->chunk_stack[sc][new_epoch];
ChunkRecord* record = old_stack.pop_all();
while (record != nullptr)
{
auto next = record->next.load();
// Disable pages for this
Pal::notify_not_using(
record->meta_common.chunk.unsafe_ptr(),
slab_sizeclass_to_size(sc));
// Add to global state
state->decommitted_chunk_stack[sc].push(record);
record = next;
}
}
curr = curr->next;
}
// Advance current index
state->epoch = new_epoch;
}

This on a timer pushes unused chunks of memory back into central pools and decommits them.

I want to get LowMemory notifications to call a modified version of this.

Your question makes me think that teardown should also interact with this code, and I don't think it currently does. I am deep in a concurrency issue on Verona at a moment, but can think this through tomorrow.

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

No branches or pull requests

2 participants