Skip to content

Commit

Permalink
Remove test that checks if HugeCache demand release config is set cor…
Browse files Browse the repository at this point in the history
…rectly.

We already verify this in get_stats_test. This test manipulates the global state, so remove it as it's redundant. It also removes certain flags that were not used.

PiperOrigin-RevId: 719409237
Change-Id: Ic0aa26d3954dd9a96541413e6300031788dcc94a
  • Loading branch information
v-gogte authored and copybara-github committed Jan 24, 2025
1 parent 7604ee7 commit e028f37
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
2 changes: 0 additions & 2 deletions tcmalloc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -911,14 +911,12 @@ cc_test(
"//tcmalloc/internal:config",
"//tcmalloc/internal:logging",
"//tcmalloc/internal:page_size",
"//tcmalloc/internal:parameter_accessors",
"//tcmalloc/testing:thread_manager",
"@com_github_google_benchmark//:benchmark",
"@com_google_absl//absl/base",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:nullability",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/meta:type_traits",
"@com_google_absl//absl/random",
"@com_google_absl//absl/random:bit_gen_ref",
Expand Down
21 changes: 3 additions & 18 deletions tcmalloc/huge_page_aware_allocator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "absl/base/optimization.h"
#include "absl/base/thread_annotations.h"
#include "absl/container/flat_hash_map.h"
#include "absl/flags/flag.h"
#include "absl/meta/type_traits.h"
#include "absl/random/bit_gen_ref.h"
#include "absl/random/distributions.h"
Expand All @@ -56,21 +55,15 @@
#include "tcmalloc/internal/config.h"
#include "tcmalloc/internal/logging.h"
#include "tcmalloc/internal/page_size.h"
#include "tcmalloc/internal/parameter_accessors.h"
#include "tcmalloc/malloc_extension.h"
#include "tcmalloc/mock_huge_page_static_forwarder.h"
#include "tcmalloc/page_allocator_test_util.h"
#include "tcmalloc/pages.h"
#include "tcmalloc/parameters.h"
#include "tcmalloc/span.h"
#include "tcmalloc/stats.h"
#include "tcmalloc/system-alloc.h"
#include "tcmalloc/testing/thread_manager.h"

ABSL_FLAG(std::string, tracefile, "", "file to pull trace from");
ABSL_FLAG(uint64_t, limit, 0, "");
ABSL_FLAG(bool, always_check_usage, false, "enable expensive memory checks");

namespace tcmalloc {
namespace tcmalloc_internal {
namespace {
Expand Down Expand Up @@ -477,12 +470,6 @@ TEST_P(HugePageAwareAllocatorTest,
old_cache_long_interval);
}

TEST_P(HugePageAwareAllocatorTest, SettingDemandBasedReleaseFlags) {
// Checks if we can set the demand-based release flags.
Parameters::set_huge_cache_demand_based_release(false);
EXPECT_EQ(Parameters::huge_cache_demand_based_release(), false);
}

TEST_P(HugePageAwareAllocatorTest, ReleasingSmall) {
const bool old_subrelease = allocator_->forwarder().hpaa_subrelease();
allocator_->forwarder().set_hpaa_subrelease(/*value=*/true);
Expand Down Expand Up @@ -1507,8 +1494,6 @@ TEST_F(StatTest, Basic) {
absl::BitGen rng;
Span* allocs[kNumAllocs];

const bool always_check_usage = absl::GetFlag(FLAGS_always_check_usage);

PrepTest();
// DO NOT MALLOC ANYTHING BELOW THIS LINE! WE'RE TRYING TO CAREFULLY COUNT
// ALLOCATIONS.
Expand All @@ -1518,7 +1503,7 @@ TEST_F(StatTest, Basic) {
Length k = RandomAllocSize(rng);
allocs[i] = Alloc(k, kSpanInfo);
// stats are expensive, don't always check
if (i % 10 != 0 && !always_check_usage) continue;
if (i % 10 != 0) continue;
CheckStats();
}

Expand All @@ -1538,13 +1523,13 @@ TEST_F(StatTest, Basic) {
}

// stats are expensive, don't always check
if (i % 10 != 0 && !always_check_usage) continue;
if (i % 10 != 0) continue;
CheckStats();
}

for (int i = 0; i < kNumAllocs; ++i) {
Free(allocs[i], kSpanInfo);
if (i % 10 != 0 && !always_check_usage) continue;
if (i % 10 != 0) continue;
CheckStats();
}

Expand Down

0 comments on commit e028f37

Please sign in to comment.