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
2 changes: 2 additions & 0 deletions tcmalloc/experiment_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace tcmalloc {
enum class Experiment : int {
// clang-format off
// go/keep-sorted start
TCMALLOC_DEMAND_CYCLE_120S, // TODO: b/540987155 - Complete experiment.
TCMALLOC_HUGE_REGION_ADAPTIVE_RELEASE, // TODO: b/535197873 - Complete experiment.
TCMALLOC_PER_CPU_CACHE_SIZE_1MB, // TODO: b/514747820 - Complete experiment.
TCMALLOC_PGHO_EXPERIMENT, // TODO: b/460486507 - Complete experiment.
Expand Down Expand Up @@ -53,6 +54,7 @@ struct ExperimentConfig {
// clang-format off
inline constexpr ExperimentConfig experiments[] = {
// go/keep-sorted start
{Experiment::TCMALLOC_DEMAND_CYCLE_120S, "TCMALLOC_DEMAND_CYCLE_120S"},
{Experiment::TCMALLOC_HUGE_REGION_ADAPTIVE_RELEASE, "TCMALLOC_HUGE_REGION_ADAPTIVE_RELEASE"},
{Experiment::TCMALLOC_PER_CPU_CACHE_SIZE_1MB, "TCMALLOC_PER_CPU_CACHE_SIZE_1MB"},
{Experiment::TCMALLOC_PGHO_EXPERIMENT, "TCMALLOC_PGHO_EXPERIMENT"},
Expand Down
13 changes: 12 additions & 1 deletion tcmalloc/huge_page_subrelease.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "tcmalloc/common.h"
#include "tcmalloc/experiment.h"
#include "tcmalloc/huge_pages.h"
#include "tcmalloc/internal/clock.h"
#include "tcmalloc/internal/config.h"
Expand Down Expand Up @@ -332,7 +333,17 @@ class SubreleaseStatsTracker {
// spikes. The demand is capped to the peak observed in the history window.
Length GetRecentDemand(absl::Duration short_interval,
absl::Duration long_interval) {
return GetRecentDemand(short_interval, long_interval, demand_cap_interval_);
if (IsExperimentActive(Experiment::TCMALLOC_DEMAND_CYCLE_120S)) {
// As the interval value can be updated online, we have to load the
// demand_cap_interval here rather than in the constructor.
return GetRecentDemand(short_interval, long_interval,
long_interval == absl::ZeroDuration()
? short_interval
: long_interval);
} else {
return GetRecentDemand(short_interval, long_interval,
demand_cap_interval_);
}
}

// Calculates demand requirements for the skip subrelease: we do not
Expand Down
12 changes: 10 additions & 2 deletions tcmalloc/parameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ static std::atomic<int64_t>& skip_subrelease_short_interval_ns() {
#if defined(TCMALLOC_INTERNAL_SMALL_BUT_SLOW)
interval = absl::ZeroDuration();
#else
interval = absl::Seconds(60);
if (IsExperimentActive(Experiment::TCMALLOC_DEMAND_CYCLE_120S)) {
interval = absl::Seconds(10);
} else {
interval = absl::Seconds(60);
}
#endif

absl::base_internal::LowLevelCallOnce(&flag, [&]() {
Expand All @@ -127,7 +131,11 @@ static std::atomic<int64_t>& skip_subrelease_long_interval_ns() {
#if defined(TCMALLOC_INTERNAL_SMALL_BUT_SLOW)
interval = absl::ZeroDuration();
#else
interval = absl::Seconds(300);
if (IsExperimentActive(Experiment::TCMALLOC_DEMAND_CYCLE_120S)) {
interval = absl::Seconds(120);
} else {
interval = absl::Seconds(300);
}
#endif

absl::base_internal::LowLevelCallOnce(&flag, [&]() {
Expand Down
21 changes: 15 additions & 6 deletions tcmalloc/testing/get_stats_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,21 @@ TEST_F(GetStatsTest, Pbtxt) {
EXPECT_THAT(buf, HasSubstr("tcmalloc_skip_subrelease_short_interval_ns: 0"));
EXPECT_THAT(buf, HasSubstr("tcmalloc_skip_subrelease_long_interval_ns: 0"));
#else
EXPECT_THAT(
buf,
HasSubstr("tcmalloc_skip_subrelease_short_interval_ns: 60000000000"));
EXPECT_THAT(
buf,
HasSubstr("tcmalloc_skip_subrelease_long_interval_ns: 300000000000"));
if (IsExperimentActive(Experiment::TCMALLOC_DEMAND_CYCLE_120S)) {
EXPECT_THAT(
buf,
HasSubstr("tcmalloc_skip_subrelease_short_interval_ns: 10000000000"));
EXPECT_THAT(
buf,
HasSubstr("tcmalloc_skip_subrelease_long_interval_ns: 120000000000"));
} else {
EXPECT_THAT(
buf,
HasSubstr("tcmalloc_skip_subrelease_short_interval_ns: 60000000000"));
EXPECT_THAT(
buf,
HasSubstr("tcmalloc_skip_subrelease_long_interval_ns: 300000000000"));
}
#endif

EXPECT_THAT(buf, HasSubstr("tcmalloc_release_partial_alloc_pages: true"));
Expand Down
6 changes: 6 additions & 0 deletions tcmalloc/variants.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ test_variants = [
"deps": ["//tcmalloc:common_8k_pages"],
"env": {"BORG_EXPERIMENTS": "TCMALLOC_SONIC_MADV_NOHUGEPAGE_REGIONS"},
},
{
"name": "tcmalloc_demand_cycle_120s",
"malloc": "//tcmalloc",
"deps": ["//tcmalloc:common_8k_pages"],
"env": {"BORG_EXPERIMENTS": "TCMALLOC_DEMAND_CYCLE_120S"},
},
]

def create_tcmalloc_library(
Expand Down
Loading