Skip to content

Commit

Permalink
Enable 64B spans by default.
Browse files Browse the repository at this point in the history
This enables spans that are cacheline aligned.

PiperOrigin-RevId: 702797456
Change-Id: Ic779740b07058fecb9ed6d05f2b756396b4f9992
  • Loading branch information
v-gogte authored and copybara-github committed Dec 4, 2024
1 parent fcc9101 commit c42319e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
10 changes: 6 additions & 4 deletions tcmalloc/span_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,12 @@ TEST(SpanAllocatorTest, Alignment) {
ABSL_CACHELINE_SIZE];
}

// Not all spans are currently aligned to a cacheline.
//
// TODO(b/304135905): Modify this assumption.
EXPECT_LT(address_mod_cacheline[0], kNumSpans);
// TODO(b/304135905): Remove the opt out.
if (tcmalloc_big_span()) {
EXPECT_EQ(address_mod_cacheline[0], kNumSpans);
} else {
EXPECT_LT(address_mod_cacheline[0], kNumSpans);
}

// Verify alignof is respected.
for (auto [alignment, count] : address_mod_cacheline) {
Expand Down
7 changes: 3 additions & 4 deletions tcmalloc/static_vars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ GOOGLE_MALLOC_SECTION_BEGIN
namespace tcmalloc {
namespace tcmalloc_internal {

// TODO(b/304135905): Remove the opt out.
ABSL_ATTRIBUTE_WEAK bool default_want_disable_tcmalloc_big_span();
bool tcmalloc_big_span() {
// Disable 64B span if built against an opt-out.
Expand All @@ -72,8 +73,7 @@ bool tcmalloc_big_span() {
if (e) {
switch (e[0]) {
case '0':
// TODO(b/304135905): Enable this.
return false;
return true;
case '1':
return false;
default:
Expand All @@ -82,8 +82,7 @@ bool tcmalloc_big_span() {
}
}

// TODO(b/304135905): Enable this by default.
return false;
return true;
}

// Cacheline-align our SizeMap and CpuCache. They both have very hot arrays as
Expand Down
8 changes: 8 additions & 0 deletions tcmalloc/variants.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ test_variants = [
"copts": ["-DTCMALLOC_INTERNAL_256K_PAGES", "-DTCMALLOC_INTERNAL_NUMA_AWARE"],
"tags": ["noubsan"],
},
{
"name": "big_span_disable",
"malloc": "//tcmalloc",
"deps": [
"//tcmalloc:common_8k_pages",
],
"env": {"TCMALLOC_DISABLE_BIG_SPAN": "1"},
},
{
"name": "256k_pages_pow2_sharded_transfer_cache",
"malloc": "//tcmalloc:tcmalloc_256k_pages",
Expand Down

0 comments on commit c42319e

Please sign in to comment.