Skip to content

Commit

Permalink
Small changes to 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 Jun 19, 2024
1 parent 72f26b8 commit e0188ad
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
16 changes: 9 additions & 7 deletions src/snmalloc/mem/corealloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,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 @@ -490,10 +490,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 @@ -502,6 +498,10 @@ namespace snmalloc
return true;
};

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

if constexpr (Config::Options.QueueHeadsAreTame)
{
/*
Expand Down Expand Up @@ -935,9 +935,11 @@ namespace snmalloc
else
report_fatal_error(
"debug_is_empty: found non-empty allocator: size={} on "
"slab_start {}",
"slab_start {} meta {} entry {}",
sizeclass_full_to_size(size_class),
slab_start);
slab_start,
address_cast(slab_metadata),
address_cast(&entry));
};

auto test = [&error](auto& queue) {
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 @@ -274,18 +274,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 @@ -681,12 +681,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 e0188ad

Please sign in to comment.