CR Feedback.

This commit is contained in:
Matthew Parkinson
2021-04-29 19:14:38 +01:00
committed by Matthew Parkinson
parent 208ab9a8e8
commit 5198821905
3 changed files with 18 additions and 16 deletions

View File

@@ -512,7 +512,7 @@ namespace snmalloc
DLList<Superslab, CapPtrCBChunk> super_available;
DLList<Superslab, CapPtrCBChunk> super_only_short_available;
RemoteCache remote;
RemoteCache remote_cache;
std::conditional_t<IsQueueInline, RemoteAllocator, RemoteAllocator*>
remote_alloc;
@@ -734,7 +734,8 @@ namespace snmalloc
SNMALLOC_FAST_PATH void handle_dealloc_remote(CapPtr<Remote, CBAlloc> p)
{
if (likely(Remote::trunc_target_id(p, &large_allocator) == get_trunc_id()))
auto target_id = Remote::trunc_target_id(p, &large_allocator);
if (likely(target_id == get_trunc_id()))
{
// Destined for my slabs
auto p_auth = large_allocator.template capptr_amplify<Remote>(p);
@@ -745,10 +746,8 @@ namespace snmalloc
{
// Merely routing; despite the cast here, p is going to be cast right
// back to a Remote.
remote.dealloc<Allocator>(
Remote::trunc_target_id(p, &large_allocator),
p.template as_reinterpret<FreeObject>(),
p->sizeclass());
remote_cache.dealloc<Allocator>(
target_id, p.template as_reinterpret<FreeObject>(), p->sizeclass());
}
}
@@ -819,11 +818,11 @@ namespace snmalloc
}
// Our remote queues may be larger due to forwarding remote frees.
if (likely(remote.capacity > 0))
if (likely(remote_cache.capacity > 0))
return;
stats().remote_post();
remote.post<Allocator>(this, get_trunc_id());
remote_cache.post<Allocator>(this, get_trunc_id());
}
/**
@@ -1535,11 +1534,12 @@ namespace snmalloc
// Check whether this will overflow the cache first. If we are a fake
// allocator, then our cache will always be full and so we will never hit
// this path.
if (remote.capacity > 0)
if (remote_cache.capacity > 0)
{
stats().remote_free(sizeclass);
auto offseted = apply_cache_friendly_offset(p, sizeclass);
remote.dealloc<Allocator>(target->trunc_id(), offseted, sizeclass);
remote_cache.dealloc<Allocator>(
target->trunc_id(), offseted, sizeclass);
return;
}
@@ -1578,10 +1578,10 @@ namespace snmalloc
stats().remote_free(sizeclass);
auto offseted = apply_cache_friendly_offset(p_auth, sizeclass);
remote.dealloc<Allocator>(target->trunc_id(), offseted, sizeclass);
remote_cache.dealloc<Allocator>(target->trunc_id(), offseted, sizeclass);
stats().remote_post();
remote.post<Allocator>(this, get_trunc_id());
remote_cache.post<Allocator>(this, get_trunc_id());
}
ChunkMap& chunkmap()

View File

@@ -123,10 +123,10 @@ namespace snmalloc
// Post all remotes, including forwarded ones. If any allocator posts,
// repeat the loop.
if (alloc->remote.capacity < REMOTE_CACHE)
if (alloc->remote_cache.capacity < REMOTE_CACHE)
{
alloc->stats().remote_post();
alloc->remote.post(alloc, alloc->get_trunc_id());
alloc->remote_cache.post(alloc, alloc->get_trunc_id());
done = false;
}

View File

@@ -75,7 +75,8 @@ namespace snmalloc
* Return allocator for this object. This may perform amplification.
*/
template<typename LargeAlloc>
static alloc_id_t trunc_target_id(CapPtr<Remote, CBAlloc> r, LargeAlloc* large_allocator)
static alloc_id_t
trunc_target_id(CapPtr<Remote, CBAlloc> r, LargeAlloc* large_allocator)
{
#ifdef SNMALLOC_DONT_CACHE_ALLOCATOR_PTR
// Rederive allocator id.
@@ -248,7 +249,8 @@ namespace snmalloc
// Use the next N bits to spread out remote deallocs in our own
// slot.
size_t slot = get_slot<Alloc>(
Remote::trunc_target_id(r, &allocator->large_allocator), post_round);
Remote::trunc_target_id(r, &allocator->large_allocator),
post_round);
RemoteList* l = &list[slot];
l->last->non_atomic_next = r;
l->last = r;