Skip to content

Commit

Permalink
Try: remotecache: don't store allocator IDs
Browse files Browse the repository at this point in the history
We can, as Matt so kindly reminds me, go get them from the pagemap.  Since we
need this value only when closing a ring, the read from over there is probably
not very onerous.  (We could also get the slab pointer from an object in the
ring, but we need that whenever inserting into the cache, so it's probably more
sensible to store that locally?)
  • Loading branch information
nwf-msr committed May 22, 2024
1 parent 5ee6abf commit 865a24b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/snmalloc/mem/localalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ namespace snmalloc
address_cast(entry.get_slab_metadata()));
#endif
local_cache.remote_dealloc_cache.template dealloc<sizeof(CoreAlloc)>(
entry.get_slab_metadata(), entry.get_remote()->trunc_id(), p);
entry.get_slab_metadata(), p);
post_remote_cache();
return;
}
Expand Down Expand Up @@ -678,7 +678,7 @@ namespace snmalloc
if (local_cache.remote_dealloc_cache.reserve_space(entry))
{
local_cache.remote_dealloc_cache.template dealloc<sizeof(CoreAlloc)>(
entry.get_slab_metadata(), remote->trunc_id(), p_tame);
entry.get_slab_metadata(), p_tame);
# ifdef SNMALLOC_TRACING
message<1024>(
"Remote dealloc fast {} ({}, {})",
Expand Down
16 changes: 6 additions & 10 deletions src/snmalloc/mem/remotecache.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ namespace snmalloc
std::array<freelist::Builder<false, true>, RINGS> open_builder;
std::array<typename Config::PagemapEntry::SlabMetadata*, RINGS> open_meta =
{nullptr};
std::array<RemoteAllocator::alloc_id_t, RINGS> open_target = {0};

/**
* The total amount of memory we are waiting for before we will dispatch
Expand Down Expand Up @@ -97,20 +96,19 @@ namespace snmalloc
freelist::Object::key_root,
open_meta[ix]->as_key_tweak());

forward<allocator_size>(open_target[ix], rmsg);
auto& entry = Config::Backend::get_metaentry(address_cast(rmsg));

forward<allocator_size>(entry.get_remote()->trunc_id(), rmsg);

open_meta[ix] = nullptr;
}

SNMALLOC_FAST_PATH void init_one_pending(
size_t ix,
typename Config::PagemapEntry::SlabMetadata* meta,
RemoteAllocator::alloc_id_t id)
size_t ix, typename Config::PagemapEntry::SlabMetadata* meta)
{
open_builder[ix].init(
0, freelist::Object::key_root, open_meta[ix]->as_key_tweak());
open_meta[ix] = meta;
open_target[ix] = id;
}

SNMALLOC_FAST_PATH size_t
Expand All @@ -123,9 +121,7 @@ namespace snmalloc

template<size_t allocator_size>
SNMALLOC_FAST_PATH void dealloc(
typename Config::PagemapEntry::SlabMetadata* meta,
RemoteAllocator::alloc_id_t target_id,
capptr::Alloc<void> p)
typename Config::PagemapEntry::SlabMetadata* meta, capptr::Alloc<void> p)
{
SNMALLOC_ASSERT(initialised);

Expand Down Expand Up @@ -167,7 +163,7 @@ namespace snmalloc
{
close_one_pending<allocator_size>(victim_ix);
}
init_one_pending(victim_ix, meta, target_id);
init_one_pending(victim_ix, meta);

open_builder[victim_ix].add(
r, freelist::Object::key_root, meta->as_key_tweak());
Expand Down

0 comments on commit 865a24b

Please sign in to comment.