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 Jun 20, 2024
1 parent 97f8aea commit b676148
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/snmalloc/mem/localalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,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 @@ -679,7 +679,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
18 changes: 6 additions & 12 deletions src/snmalloc/mem/remotecache.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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};

SNMALLOC_FAST_PATH size_t
ring_set(typename Config::PagemapEntry::SlabMetadata* meta)
Expand All @@ -42,27 +41,25 @@ namespace snmalloc
freelist::Object::key_root,
open_meta[ix]->as_key_tweak());

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

forward(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;
}

public:
template<typename Forward>
SNMALLOC_FAST_PATH void dealloc(
typename Config::PagemapEntry::SlabMetadata* meta,
RemoteAllocator::alloc_id_t target_id,
freelist::HeadPtr r,
Forward forward)
{
Expand Down Expand Up @@ -102,7 +99,7 @@ namespace snmalloc
{
close_one_pending(forward, 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 Expand Up @@ -197,17 +194,14 @@ 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);

auto r = freelist::Object::make<capptr::bounds::AllocWild>(p);

batching.dealloc(
meta,
target_id,
r,
[this](
RemoteAllocator::alloc_id_t target_id,
Expand Down

0 comments on commit b676148

Please sign in to comment.