Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tcmalloc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ create_tcmalloc_libraries(
"huge_pages.h",
"huge_region.h",
"legacy_size_classes.cc",
"lowfrag_size_classes.cc",
"metadata_object_allocator.h",
"page_allocator.cc",
"page_allocator.h",
Expand Down
2 changes: 2 additions & 0 deletions tcmalloc/experiment_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum class Experiment : int {
TEST_ONLY_MM_VCPU, // TODO: b/245776120 - Complete experiment.
TEST_ONLY_TCMALLOC_ALWAYS_DISCARDING, // TODO: b/328301906 - Complete experiment.
TEST_ONLY_TCMALLOC_HEAP_PARTITIONING, // TODO: b/446814339 - Complete experiment.
TEST_ONLY_TCMALLOC_LOWFRAG_SIZECLASSES_V2,
TEST_ONLY_TCMALLOC_MADV_COLD_HUGEPAGE, // TODO: b/450368905 - Complete experiment.
TEST_ONLY_TCMALLOC_POW2_SIZECLASS,
TEST_ONLY_TCMALLOC_SHARDED_TRANSFER_CACHE,
Expand Down Expand Up @@ -58,6 +59,7 @@ inline constexpr ExperimentConfig experiments[] = {
{Experiment::TEST_ONLY_MM_VCPU, "TEST_ONLY_MM_VCPU"},
{Experiment::TEST_ONLY_TCMALLOC_ALWAYS_DISCARDING, "TEST_ONLY_TCMALLOC_ALWAYS_DISCARDING", /*brittle=*/true},
{Experiment::TEST_ONLY_TCMALLOC_HEAP_PARTITIONING, "TEST_ONLY_TCMALLOC_HEAP_PARTITIONING"},
{Experiment::TEST_ONLY_TCMALLOC_LOWFRAG_SIZECLASSES_V2, "TEST_ONLY_TCMALLOC_LOWFRAG_SIZECLASSES_V2"},
{Experiment::TEST_ONLY_TCMALLOC_MADV_COLD_HUGEPAGE, "TEST_ONLY_TCMALLOC_MADV_COLD_HUGEPAGE"},
{Experiment::TEST_ONLY_TCMALLOC_POW2_SIZECLASS, "TEST_ONLY_TCMALLOC_POW2_SIZECLASS", /*brittle=*/true},
{Experiment::TEST_ONLY_TCMALLOC_SHARDED_TRANSFER_CACHE, "TEST_ONLY_TCMALLOC_SHARDED_TRANSFER_CACHE", /*brittle=*/true},
Expand Down
2 changes: 2 additions & 0 deletions tcmalloc/global_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ static absl::string_view SizeClassConfigurationString(
case SizeClassConfiguration::kLegacy:
// TODO(b/242710633): remove this opt out.
return "SIZE_CLASS_LEGACY";
case SizeClassConfiguration::kLowFrag:
return "SIZE_CLASS_LOW_FRAG";
case SizeClassConfiguration::kReuse:
return "SIZE_CLASS_REUSE";
case SizeClassConfiguration::kReuseRelaxedBelow64:
Expand Down
751 changes: 751 additions & 0 deletions tcmalloc/lowfrag_size_classes.cc

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tcmalloc/size_classes_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ TEST_F(RunTimeSizeClassesTest, WastedSpan) {
case SizeClassConfiguration::kLegacy:
case SizeClassConfiguration::kReuse:
case SizeClassConfiguration::kReuseRelaxedBelow64:
case SizeClassConfiguration::kLowFrag:
// This test fails for other classes (was passing with a different span
// size allocation algorithm used between cl/130150125 and cl/139955211).
GTEST_SKIP();
Expand Down
2 changes: 2 additions & 0 deletions tcmalloc/sizemap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const SizeClasses& SizeMap::CurrentClasses() {
case SizeClassConfiguration::kLegacy:
// TODO(b/242710633): remove this opt out.
return kLegacySizeClasses;
case SizeClassConfiguration::kLowFrag:
return kLowFragSizeClasses;
}
TC_BUG("unreachable");
}
Expand Down
2 changes: 2 additions & 0 deletions tcmalloc/sizemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ extern const SizeClasses kSizeClasses;
extern const SizeClasses kExperimentalPow2SizeClasses;
extern const SizeClasses kLegacySizeClasses;
extern const SizeClasses kReuseRelaxedBelow64SizeClasses;
extern const SizeClasses kLowFragSizeClasses;

enum class SizeClassConfiguration {
kPow2Only = 2,
kLegacy = 4,
kReuse = 6,
kReuseRelaxedBelow64 = 8,
kLowFrag = 9,
};

// Size-class information + mapping
Expand Down
6 changes: 6 additions & 0 deletions tcmalloc/static_vars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,16 @@ size_t Static::pagemap_residence() {
int ABSL_ATTRIBUTE_WEAK default_want_legacy_size_classes();

SizeClassConfiguration Static::size_class_configuration() {
return SizeClassConfiguration::kLowFrag;
if (IsExperimentActive(Experiment::TEST_ONLY_TCMALLOC_POW2_SIZECLASS)) {
return SizeClassConfiguration::kPow2Only;
}

if (IsExperimentActive(
Experiment::TEST_ONLY_TCMALLOC_LOWFRAG_SIZECLASSES_V2)) {
return SizeClassConfiguration::kLowFrag;
}

// TODO(b/242710633): remove this opt out.
if (default_want_legacy_size_classes != nullptr &&
default_want_legacy_size_classes() > 0 &&
Expand Down
Loading