diff --git a/tcmalloc/experiment_config.h b/tcmalloc/experiment_config.h index 45a05b7bc..241291daa 100644 --- a/tcmalloc/experiment_config.h +++ b/tcmalloc/experiment_config.h @@ -24,7 +24,6 @@ enum class Experiment : int { // clang-format off TEST_ONLY_TCMALLOC_POW2_SIZECLASS, TEST_ONLY_TCMALLOC_SHARDED_TRANSFER_CACHE, - TCMALLOC_METADATA_HUGEPAGE, // TODO(b/345239704): Complete experiment. TEST_ONLY_TCMALLOC_HUGE_CACHE_RELEASE_30S, // TODO(b/319872040): Complete experiment. TEST_ONLY_TCMALLOC_REUSE_SIZE_CLASSES, // TODO(b/358126781): Complete experiment. TCMALLOC_HUGE_REGION_DEMAND_BASED_RELEASE, // TODO(b/328440160): Complete experiment. @@ -45,7 +44,6 @@ struct ExperimentConfig { inline constexpr ExperimentConfig experiments[] = { {Experiment::TEST_ONLY_TCMALLOC_POW2_SIZECLASS, "TEST_ONLY_TCMALLOC_POW2_SIZECLASS"}, {Experiment::TEST_ONLY_TCMALLOC_SHARDED_TRANSFER_CACHE, "TEST_ONLY_TCMALLOC_SHARDED_TRANSFER_CACHE"}, - {Experiment::TCMALLOC_METADATA_HUGEPAGE, "TCMALLOC_METADATA_HUGEPAGE"}, {Experiment::TEST_ONLY_TCMALLOC_HUGE_CACHE_RELEASE_30S, "TEST_ONLY_TCMALLOC_HUGE_CACHE_RELEASE_30S"}, {Experiment::TEST_ONLY_TCMALLOC_REUSE_SIZE_CLASSES, "TEST_ONLY_TCMALLOC_REUSE_SIZE_CLASSES"}, {Experiment::TCMALLOC_HUGE_REGION_DEMAND_BASED_RELEASE, "TCMALLOC_HUGE_REGION_DEMAND_BASED_RELEASE"}, diff --git a/tcmalloc/parameters.cc b/tcmalloc/parameters.cc index 096b99eed..b3b15bac3 100644 --- a/tcmalloc/parameters.cc +++ b/tcmalloc/parameters.cc @@ -121,19 +121,6 @@ static std::atomic& huge_region_demand_based_release_enabled() { return v; } -// As set_metadata_hugepage is determined at runtime, we cannot require constant -// initialization for the atomic. This avoids an initialization order fiasco. -static std::atomic& tag_metadata_hugepage_enabled() { - ABSL_CONST_INIT static absl::once_flag flag; - ABSL_CONST_INIT static std::atomic v{true}; - absl::base_internal::LowLevelCallOnce(&flag, [&]() { - if (IsExperimentActive(Experiment::TCMALLOC_METADATA_HUGEPAGE)) { - v.store(false, std::memory_order_relaxed); - } - }); - return v; -} - // Configures short and long intervals to zero by default. We expect to set them // to the non-zero durations once the feature is no longer experimental. static std::atomic& skip_subrelease_short_interval_ns() { @@ -284,7 +271,6 @@ ABSL_CONST_INIT std::atomic Parameters::per_cpu_caches_dynamic_slab_( true); ABSL_CONST_INIT std::atomic Parameters::madvise_( MadvisePreference::kDontNeed); -ABSL_CONST_INIT std::atomic Parameters::tag_metadata_separately_(true); ABSL_CONST_INIT std::atomic Parameters::min_hot_access_hint_(kDefaultMinHotAccessHint); ABSL_CONST_INIT std::atomic @@ -339,10 +325,6 @@ bool Parameters::huge_region_demand_based_release() { std::memory_order_relaxed); } -bool Parameters::tag_metadata_separately() { - return tag_metadata_hugepage_enabled().load(std::memory_order_relaxed); -} - bool Parameters::dense_trackers_sorted_on_spans_allocated() { ABSL_CONST_INIT static absl::once_flag flag; ABSL_CONST_INIT static std::atomic v{false}; @@ -510,10 +492,6 @@ bool TCMalloc_Internal_GetReleasePagesFromHugeRegionEnabled() { return Parameters::release_pages_from_huge_region(); } -bool TCMalloc_Internal_GetTagMetadataSeparatelyEnabled() { - return Parameters::tag_metadata_separately(); -} - bool TCMalloc_Internal_GetResizeSizeClassMaxCapacityEnabled() { return Parameters::resize_size_class_max_capacity(); } @@ -583,11 +561,6 @@ void TCMalloc_Internal_SetReleasePagesFromHugeRegionEnabled(bool v) { std::memory_order_relaxed); } -void TCMalloc_Internal_SetTagMetadataSeparatelyEnabled(bool v) { - tcmalloc::tcmalloc_internal::tag_metadata_hugepage_enabled().store( - v, std::memory_order_relaxed); -} - void TCMalloc_Internal_SetResizeSizeClassMaxCapacityEnabled(bool v) { Parameters::resize_size_class_max_capacity_.store(v, std::memory_order_relaxed); diff --git a/tcmalloc/parameters.h b/tcmalloc/parameters.h index e560c9b29..07771a21d 100644 --- a/tcmalloc/parameters.h +++ b/tcmalloc/parameters.h @@ -114,12 +114,6 @@ class Parameters { return release_pages_from_huge_region_.load(std::memory_order_relaxed); } - static bool tag_metadata_separately(); - - static void set_tag_metadata_separately(bool value) { - TCMalloc_Internal_SetTagMetadataSeparatelyEnabled(value); - } - static bool resize_size_class_max_capacity() { return resize_size_class_max_capacity_.load(std::memory_order_relaxed); } @@ -230,7 +224,6 @@ class Parameters { friend void ::TCMalloc_Internal_SetHugeCacheDemandBasedRelease(bool v); friend void ::TCMalloc_Internal_SetHugeRegionDemandBasedRelease(bool v); friend void ::TCMalloc_Internal_SetReleasePagesFromHugeRegionEnabled(bool v); - friend void ::TCMalloc_Internal_SetTagMetadataSeparatelyEnabled(bool v); friend void ::TCMalloc_Internal_SetResizeSizeClassMaxCapacityEnabled(bool v); friend void ::TCMalloc_Internal_SetMaxPerCpuCacheSize(int32_t v); friend void ::TCMalloc_Internal_SetMaxTotalThreadCacheBytes(int64_t v); @@ -272,7 +265,6 @@ class Parameters { static std::atomic huge_cache_demand_based_release_; static std::atomic release_pages_from_huge_region_; static std::atomic resize_size_class_max_capacity_; - static std::atomic tag_metadata_separately_; static std::atomic profile_sampling_interval_; static std::atomic per_cpu_caches_dynamic_slab_; static std::atomic madvise_; diff --git a/tcmalloc/system-alloc.cc b/tcmalloc/system-alloc.cc index 7c03d9841..273ec2678 100644 --- a/tcmalloc/system-alloc.cc +++ b/tcmalloc/system-alloc.cc @@ -288,10 +288,7 @@ static AddressRegionFactory::UsageHint TagToHint(MemoryTag tag) { case MemoryTag::kCold: return UsageHint::kInfrequentAccess; case MemoryTag::kMetadata: - if (Parameters::tag_metadata_separately()) { - return UsageHint::kMetadata; - } - return UsageHint::kInfrequentAllocation; + return UsageHint::kMetadata; } ASSUME(false); diff --git a/tcmalloc/testing/system-alloc_test.cc b/tcmalloc/testing/system-alloc_test.cc index face09fcb..c3b0901d4 100644 --- a/tcmalloc/testing/system-alloc_test.cc +++ b/tcmalloc/testing/system-alloc_test.cc @@ -32,7 +32,6 @@ #include "tcmalloc/internal/logging.h" #include "tcmalloc/internal/proc_maps.h" #include "tcmalloc/malloc_extension.h" -#include "tcmalloc/parameters.h" #ifndef PR_SET_VMA #define PR_SET_VMA 0x53564d41 @@ -224,9 +223,8 @@ TEST(Basic, RetryFailTest) { free(q); } -// Verify when tag_metadata_separately is true, the usage hint is kMetadata. +// Verify default behavior for tcmalloc metadata utilizes usage hint kMetadata. TEST(UsageHint, VerifyUsageHintkMetadataTest) { - Parameters::set_tag_metadata_separately(true); MallocExtension::SetRegionFactory(&f); // Need a large enough size to trigger the system allocator, // 2.0 is an arbitrary number. Else it would continue to use the previous @@ -238,21 +236,6 @@ TEST(UsageHint, VerifyUsageHintkMetadataTest) { ::operator delete(ptr); } -// Verify that when tag_metadata_separately is false, the usage hint is -// kInfrequentAllocation. -TEST(UsageHint, WhenNotTaggingMetadataSeparately) { - Parameters::set_tag_metadata_separately(false); - MallocExtension::SetRegionFactory(&f); - // Need a large enough size to trigger the system allocator, - // 2.0 is an arbitrary number. Else it would continue to use the previous - // hugepage region and a new usage hint wouldn't be assigned - void* ptr = ::operator new(kMinMmapAlloc * 2.0); - EXPECT_EQ(f.usage_hint_, - AddressRegionFactory::UsageHint::kInfrequentAllocation) - << "Usage hint is " << hintToString(f.usage_hint_); - ::operator delete(ptr); -} - } // namespace } // namespace tcmalloc_internal } // namespace tcmalloc