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
8 changes: 4 additions & 4 deletions tcmalloc/huge_page_filler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1041,10 +1041,10 @@ class HugePageFiller {
// not reported to ReleasePages calls?
Length unmapping_unaccounted_;

// Functionality related to time series tracking, using 3600 slots to record
// at least 60-mins demand history (maximumly using 1 slot every second).
// Functionality related to time series tracking, using 600 slots to record
// at least 10-mins demand history (maximumly using 1 slot every second).
void UpdateFillerStatsTracker();
using StatsTrackerType = SubreleaseStatsTracker<3600>;
using StatsTrackerType = SubreleaseStatsTracker<600>;
StatsTrackerType fillerstats_tracker_;

// Lifetime tracking for completely-freed hugepages
Expand Down Expand Up @@ -1083,7 +1083,7 @@ inline HugePageFiller<TrackerType>::HugePageFiller(
MemoryTagFunction& set_anon_vma_name,
SubreleaseUnbackedMode subrelease_unbacked_mode)
: size_(NHugePages(0)),
fillerstats_tracker_(clock, absl::Minutes(60), absl::Minutes(5),
fillerstats_tracker_(clock, absl::Minutes(10), absl::Minutes(5),
absl::Minutes(10)),
clock_(clock),
tag_(tag),
Expand Down
12 changes: 5 additions & 7 deletions tcmalloc/huge_page_filler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4347,10 +4347,8 @@ TEST_F(FillerTest, CheckSubreleaseStats) {
EXPECT_EQ(subrelease.total_pages_subreleased_due_to_limit, Length(19));
EXPECT_EQ(subrelease.total_hugepages_broken_due_to_limit.raw_num(), 2);
}
// The tracker can hold record collected accumulated in more than 60 mins if
// the reports were reported sparsely (hence same number of tracker slots can
// cover longer period).
FakeClock::Advance(absl::Minutes(60));
// The tracker can hold record collected longer than 10 mins.
FakeClock::Advance(absl::Minutes(10));
// Do some work
for (int i = 0; i < 5; ++i) {
result.push_back(AllocateVectorWithSpanAllocInfo(Length(1), kAllocInfo));
Expand Down Expand Up @@ -4388,7 +4386,7 @@ TEST_F(FillerTest, CheckSubreleaseStats) {
"limit)"));
ASSERT_THAT(
buffer,
testing::EndsWith("HugePageFiller: Subrelease stats last 60 min: total "
testing::EndsWith("HugePageFiller: Subrelease stats last 10 min: total "
"21 pages subreleased.\n"));
} else {
ASSERT_THAT(buffer,
Expand All @@ -4399,7 +4397,7 @@ TEST_F(FillerTest, CheckSubreleaseStats) {
"limit)"));
ASSERT_THAT(
buffer,
testing::EndsWith("HugePageFiller: Subrelease stats last 60 min: total "
testing::EndsWith("HugePageFiller: Subrelease stats last 10 min: total "
"0 pages subreleased.\n"));
}

Expand Down Expand Up @@ -5964,7 +5962,7 @@ HugePageFiller: at peak demand: 3547 pages (and 255 free, 38 unmapped)

HugePageFiller: Since the start of the execution, 0 subreleases (0 pages) were skipped due to either recent (0s) peaks, or the sum of short-term (0s) fluctuations and long-term (0s) trends.
HugePageFiller: 0.0000% of decisions confirmed correct, 0 pending (0.0000% of pages, 0 pending), as per anticipated 300s realized fragmentation.
HugePageFiller: Subrelease stats last 60 min: total 306 pages subreleased.
HugePageFiller: Subrelease stats last 10 min: total 306 pages subreleased.
)"));

absl::flat_hash_set<const PageTracker*> expected_pts, actual_pts;
Expand Down
27 changes: 12 additions & 15 deletions tcmalloc/huge_page_subrelease_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ class StatsTrackerTest : public testing::Test {
ClockResetter clock_resetter_;

protected:
static constexpr absl::Duration kWindow = absl::Minutes(60);
static constexpr absl::Duration kWindow = absl::Minutes(10);

// Epoch length: 0.5 min (i.e., 60-min window in 120 slots). The tracker can
// hold records longer than 60 mins, and we expect it to account the epoch
// Epoch length: 0.5 min (i.e., 10-min window in 20 slots). The tracker can
// hold records longer than 10 mins, and we expect it to account the epoch
// coverage correctly.
using StatsTrackerType = SubreleaseStatsTracker<120>;
using StatsTrackerType = SubreleaseStatsTracker<20>;
StatsTrackerType tracker_{
Clock{.now = FakeClock, .freq = GetFakeClockFrequency}, kWindow,
/*summary_interval=*/absl::Minutes(5), /*demand_cap_interval=*/
Expand Down Expand Up @@ -113,13 +113,10 @@ void StatsTrackerTest::GenerateDemandPoint(Length num_pages,
TEST_F(StatsTrackerTest, Works) {
// Epoch 1.
GenerateInterestingPoints(Length(1), Length(1));
// Epoch 101.
Advance(absl::Minutes(50));
GenerateInterestingPoints(Length(300), Length(100));
// Epoch 111.
// Epoch 11.
Advance(absl::Minutes(5));
GenerateInterestingPoints(Length(100), Length(200));
// Epoch 113.
// Epoch 13.
Advance(absl::Minutes(1));
GenerateInterestingPoints(Length(200), Length(100));

Expand All @@ -137,7 +134,7 @@ StatsTracker: at peak demand: 208 pages (and 111 free, 10 unmapped)

StatsTracker: Since the start of the execution, 0 subreleases (0 pages) were skipped due to either recent (0s) peaks, or the sum of short-term (0s) fluctuations and long-term (0s) trends.
StatsTracker: 0.0000% of decisions confirmed correct, 0 pending (0.0000% of pages, 0 pending), as per anticipated 300s realized fragmentation.
StatsTracker: Subrelease stats last 60 min: total 0 pages subreleased.
StatsTracker: Subrelease stats last 10 min: total 0 pages subreleased.
)"));
}
}
Expand Down Expand Up @@ -180,9 +177,9 @@ TEST_F(StatsTrackerTest, ComputeRecentPeaks) {
Length peak4 = tracker_.GetRecentPeak(absl::Minutes(5));
EXPECT_EQ(peak4, Length(150));
// Checks that the peak demand calculation works for longer interval.
Advance(absl::Minutes(50));
Advance(absl::Minutes(3));
GenerateDemandPoint(Length(30), Length(3000));
Length peak5 = tracker_.GetRecentPeak(absl::Minutes(52));
Length peak5 = tracker_.GetRecentPeak(absl::Minutes(4));
EXPECT_EQ(peak5, Length(150));
}

Expand Down Expand Up @@ -234,10 +231,10 @@ TEST_F(StatsTrackerTest, ComputeRecentDemand) {
tracker_.GetRecentDemand(absl::Minutes(1), absl::Minutes(1)));
// Checks that the demand calculation works: the calculated demand (100) is
// capped by the recent peak (10).
Advance(absl::Minutes(50));
Advance(absl::Minutes(8));
GenerateDemandPoint(Length(10), Length(7));
Length short_long_peak_pages5 =
tracker_.GetRecentDemand(absl::ZeroDuration(), absl::Minutes(51));
Length short_long_peak_pages5 = tracker_.GetRecentDemand(
absl::ZeroDuration(), absl::Minutes(9), absl::Minutes(2));
EXPECT_EQ(short_long_peak_pages5, Length(10));
}

Expand Down
Loading