Skip to content

Commit

Permalink
Tweak tracing
Browse files Browse the repository at this point in the history
- Trace "Handling remote" once per batch, rather than per element

- Remote queue events also log the associated metaslab; we'll use this
  to assess the efficacy of microsoft#634
  • Loading branch information
nwf-msr committed Sep 22, 2023
1 parent c225bfb commit 68788d1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/snmalloc/mem/corealloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ namespace snmalloc

#ifdef SNMALLOC_TRACING
message<1024>(
"Slab {} is unused, Object sizeclass {}",
"Slab {} is unused, Object sizeclass {}",
start_of_slab.unsafe_ptr(),
sizeclass);
#endif
Expand Down Expand Up @@ -480,10 +480,6 @@ namespace snmalloc
};
auto cb = [this,
&need_post](freelist::HeadPtr msg) SNMALLOC_FAST_PATH_LAMBDA {
#ifdef SNMALLOC_TRACING
message<1024>("Handling remote");
#endif

auto& entry =
Config::Backend::template get_metaentry(snmalloc::address_cast(msg));

Expand All @@ -492,6 +488,10 @@ namespace snmalloc
return true;
};

#ifdef SNMALLOC_TRACING
message<1024>("Handling remote queue before proceeding...");
#endif

if constexpr (Config::Options.QueueHeadsAreTame)
{
/*
Expand Down
17 changes: 10 additions & 7 deletions src/snmalloc/mem/localalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,18 @@ namespace snmalloc
* In the second case we need to recheck if this is a remote deallocation,
* as we might acquire the originating allocator.
*/
SNMALLOC_SLOW_PATH void dealloc_remote_slow(capptr::Alloc<void> p)
SNMALLOC_SLOW_PATH void
dealloc_remote_slow(const PagemapEntry& entry, capptr::Alloc<void> p)
{
if (core_alloc != nullptr)
{
#ifdef SNMALLOC_TRACING
message<1024>(
"Remote dealloc post {} ({})",
"Remote dealloc post {} ({}, {})",
p.unsafe_ptr(),
alloc_size(p.unsafe_ptr()));
alloc_size(p.unsafe_ptr()),
address_cast(entry.get_slab_metadata()));
#endif
const PagemapEntry& entry =
Config::Backend::template get_metaentry(address_cast(p));
local_cache.remote_dealloc_cache.template dealloc<sizeof(CoreAlloc)>(
entry.get_remote()->trunc_id(), p);
post_remote_cache();
Expand Down Expand Up @@ -680,12 +680,15 @@ namespace snmalloc
remote->trunc_id(), p_tame);
# ifdef SNMALLOC_TRACING
message<1024>(
"Remote dealloc fast {} ({})", p_raw, alloc_size(p_raw));
"Remote dealloc fast {} ({}, {})",
p_raw,
alloc_size(p_raw),
address_cast(entry.get_slab_metadata()));
# endif
return;
}

dealloc_remote_slow(p_tame);
dealloc_remote_slow(entry, p_tame);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/snmalloc/mem/remotecache.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ namespace snmalloc
}
}

// Reset capacity as we have empty everything
// Reset capacity as we have emptied everything
capacity = REMOTE_CACHE;

return sent_something;
Expand Down
2 changes: 1 addition & 1 deletion src/test/perf/contention/contention.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void test_tasks(size_t num_tasks, size_t count, size_t size)
ParallelTest<test_tasks_f> test(num_tasks);

std::cout << "Task test, " << num_tasks << " threads, " << count
<< " swaps per thread " << test.time() << "ticks" << std::endl;
<< " swaps per thread " << test.time() << " ticks" << std::endl;

for (size_t n = 0; n < swapsize; n++)
{
Expand Down

0 comments on commit 68788d1

Please sign in to comment.