Add local caching to chunk allocator

This commit is contained in:
Matthew Parkinson
2021-10-20 16:55:08 +01:00
committed by Matthew Parkinson
parent 20a114cb62
commit 72ccb23d02
5 changed files with 174 additions and 8 deletions

View File

@@ -58,6 +58,11 @@ namespace snmalloc
*/
MetaslabCache alloc_classes[NUM_SIZECLASSES];
/**
* Local cache for the Chunk allocator.
*/
ChunkAllocatorLocalState chunk_local_state;
/**
* Local entropy source and current version of keys for
* this thread
@@ -376,6 +381,7 @@ namespace snmalloc
auto chunk_record = clear_slab(meta, sizeclass);
ChunkAllocator::dealloc<SharedStateHandle>(
get_backend_local_state(),
chunk_local_state,
chunk_record,
sizeclass_to_slab_sizeclass(sizeclass));
@@ -548,6 +554,9 @@ namespace snmalloc
message_queue().invariant();
}
ChunkAllocator::register_local_state<SharedStateHandle>(
get_backend_local_state(), chunk_local_state);
#ifndef NDEBUG
for (sizeclass_t i = 0; i < NUM_SIZECLASSES; i++)
{
@@ -746,6 +755,7 @@ namespace snmalloc
auto [slab, meta] =
snmalloc::ChunkAllocator::alloc_chunk<SharedStateHandle>(
get_backend_local_state(),
chunk_local_state,
sizeclass,
slab_sizeclass,
slab_size,