From 865a24b438cbf28bcfe19cc32e4f5fc3b463ecfb Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Thu, 21 Mar 2024 21:20:03 +0000 Subject: [PATCH] Try: remotecache: don't store allocator IDs 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?) --- src/snmalloc/mem/localalloc.h | 4 ++-- src/snmalloc/mem/remotecache.h | 16 ++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/snmalloc/mem/localalloc.h b/src/snmalloc/mem/localalloc.h index f83783ca3..85d7b723f 100644 --- a/src/snmalloc/mem/localalloc.h +++ b/src/snmalloc/mem/localalloc.h @@ -285,7 +285,7 @@ namespace snmalloc address_cast(entry.get_slab_metadata())); #endif local_cache.remote_dealloc_cache.template dealloc( - entry.get_slab_metadata(), entry.get_remote()->trunc_id(), p); + entry.get_slab_metadata(), p); post_remote_cache(); return; } @@ -678,7 +678,7 @@ namespace snmalloc if (local_cache.remote_dealloc_cache.reserve_space(entry)) { local_cache.remote_dealloc_cache.template dealloc( - entry.get_slab_metadata(), remote->trunc_id(), p_tame); + entry.get_slab_metadata(), p_tame); # ifdef SNMALLOC_TRACING message<1024>( "Remote dealloc fast {} ({}, {})", diff --git a/src/snmalloc/mem/remotecache.h b/src/snmalloc/mem/remotecache.h index 276988032..6ed883f48 100644 --- a/src/snmalloc/mem/remotecache.h +++ b/src/snmalloc/mem/remotecache.h @@ -29,7 +29,6 @@ namespace snmalloc std::array, RINGS> open_builder; std::array open_meta = {nullptr}; - std::array open_target = {0}; /** * The total amount of memory we are waiting for before we will dispatch @@ -97,20 +96,19 @@ 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; } SNMALLOC_FAST_PATH size_t @@ -123,9 +121,7 @@ namespace snmalloc template SNMALLOC_FAST_PATH void dealloc( - typename Config::PagemapEntry::SlabMetadata* meta, - RemoteAllocator::alloc_id_t target_id, - capptr::Alloc p) + typename Config::PagemapEntry::SlabMetadata* meta, capptr::Alloc p) { SNMALLOC_ASSERT(initialised); @@ -167,7 +163,7 @@ namespace snmalloc { close_one_pending(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());