From ad4c157c120973ea2555fe0b2e89756d32ec55d2 Mon Sep 17 00:00:00 2001 From: TCMalloc Team Date: Mon, 9 Nov 2026 11:07:49 -0800 Subject: [PATCH] Update SamplingTest.ParamChange to use an 11000-byte allocation size. This ensures that unaligned and 2048-byte aligned allocations map to the same 12288-byte size class under both default and flexible no-reuse size-class configurations, and references kRequestedSize in CountMatchingBytes. Co-authored-by: Chris Kennelly PiperOrigin-RevId: 1017487537 --- tcmalloc/testing/sampling_test.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tcmalloc/testing/sampling_test.cc b/tcmalloc/testing/sampling_test.cc index 0e6bfb666..18e446e2e 100644 --- a/tcmalloc/testing/sampling_test.cc +++ b/tcmalloc/testing/sampling_test.cc @@ -54,11 +54,16 @@ bool StackMatches(const char* target, const void* const* stack, size_t len) { return false; } +// An 11000 byte allocation aligned to 2K will map to the same size class as +// malloc(11000). +constexpr size_t kRequestedSize = 11000; +constexpr size_t kRequestedAlignment = 2048; + template size_t CountMatchingBytes(const char* target, Profile profile) { size_t sum = 0; profile.Iterate([&](const Profile::Sample& e) { - if (e.requested_size == 10000 || !CheckSize) { + if (e.requested_size == kRequestedSize || !CheckSize) { if (StackMatches(target, e.stack, e.depth)) { sum += static_cast(e.sum); } @@ -68,11 +73,6 @@ size_t CountMatchingBytes(const char* target, Profile profile) { return sum; } -// A 10000 byte allocation aligned to 2K will map to the same size class as -// malloc(10000). -constexpr size_t kRequestedSize = 10000; -constexpr size_t kRequestedAlignment = 2048; - ABSL_ATTRIBUTE_NOINLINE static void* AllocateAllocate(bool align) { void* p; if (align) {