Skip to content

Commit d892274

Browse files
nilayvaishcopybara-github
authored andcommitted
Remove the enum for dense tracker type in the HugePageFiller
We no longer need it. The dense trackers are now always sorted on number of spans allocated. PiperOrigin-RevId: 769920774 Change-Id: I7ecf1ef63d8d6f328e1518382832211db9166fe9
1 parent c948d9a commit d892274

File tree

5 files changed

+330
-397
lines changed

5 files changed

+330
-397
lines changed

tcmalloc/huge_page_aware_allocator.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ class StaticForwarder {
131131
struct HugePageAwareAllocatorOptions {
132132
MemoryTag tag;
133133
HugeRegionUsageOption use_huge_region_more_often = huge_region_option();
134-
HugePageFillerDenseTrackerType dense_tracker_type =
135-
HugePageFillerDenseTrackerType::kSpansAllocated;
136134
HugePageFillerSparseTrackerType sparse_tracker_type =
137135
Parameters::sparse_trackers_coarse_longest_free_range()
138136
? HugePageFillerSparseTrackerType::kCoarseLongestFreeRange
@@ -452,8 +450,8 @@ inline HugePageAwareAllocator<Forwarder>::HugePageAwareAllocator(
452450
unback_(*this),
453451
unback_without_lock_(*this),
454452
collapse_(*this),
455-
filler_(options.dense_tracker_type, options.sparse_tracker_type, unback_,
456-
unback_without_lock_, collapse_),
453+
filler_(options.sparse_tracker_type, unback_, unback_without_lock_,
454+
collapse_),
457455
regions_(options.use_huge_region_more_often),
458456
tracker_allocator_(forwarder_.arena()),
459457
region_allocator_(forwarder_.arena()),

tcmalloc/huge_page_aware_allocator_fuzz.cc

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void FuzzHPAA(const std::string& s) {
8787
// [1] - HugeRegionsMode.
8888
// [2] - HugeCache release time
8989
// [3:4] - Reserved.
90-
// [5] - Dense tracker type
90+
// [5] - Reserved.
9191
// [6] - Sparse tracker type
9292
// [7:12] - Reserved.
9393
//
@@ -119,11 +119,6 @@ void FuzzHPAA(const std::string& s) {
119119

120120
const int32_t huge_cache_release_s = std::max<int32_t>(data[2], 1);
121121

122-
const HugePageFillerDenseTrackerType dense_tracker_type =
123-
static_cast<uint8_t>(data[5]) >= 128
124-
? HugePageFillerDenseTrackerType::kLongestFreeRangeAndChunks
125-
: HugePageFillerDenseTrackerType::kSpansAllocated;
126-
127122
const HugePageFillerSparseTrackerType sparse_tracker_type =
128123
static_cast<uint8_t>(data[6]) >= 128
129124
? HugePageFillerSparseTrackerType::kExactLongestFreeRange
@@ -138,7 +133,6 @@ void FuzzHPAA(const std::string& s) {
138133
options.tag = tag;
139134
options.use_huge_region_more_often = huge_region_option;
140135
options.huge_cache_time = absl::Seconds(huge_cache_release_s);
141-
options.dense_tracker_type = dense_tracker_type;
142136
options.sparse_tracker_type = sparse_tracker_type;
143137
HugePageAwareAllocator<FakeStaticForwarderWithUnback> allocator(options);
144138
auto& forwarder = allocator.forwarder();
@@ -196,9 +190,7 @@ void FuzzHPAA(const std::string& s) {
196190
// This is an invalid size class, so skip it.
197191
break;
198192
}
199-
if (dense_tracker_type ==
200-
HugePageFillerDenseTrackerType::kSpansAllocated &&
201-
density == AccessDensityPrediction::kDense) {
193+
if (density == AccessDensityPrediction::kDense) {
202194
length = Length(1);
203195
}
204196

@@ -214,8 +206,6 @@ void FuzzHPAA(const std::string& s) {
214206
SpanAllocInfo alloc_info = {.objects_per_span = num_objects,
215207
.density = density};
216208
TC_CHECK(
217-
dense_tracker_type ==
218-
HugePageFillerDenseTrackerType::kLongestFreeRangeAndChunks ||
219209
density == AccessDensityPrediction::kSparse ||
220210
length == Length(1));
221211
if (use_aligned) {

tcmalloc/huge_page_filler.h

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -332,34 +332,23 @@ enum class LFRRequirement : bool {
332332
kMatchingLFR,
333333
};
334334

335-
enum class HugePageFillerDenseTrackerType : bool {
336-
// Hugepages sorted on longest free range and chunk index. This is currently
337-
// the default.
338-
kLongestFreeRangeAndChunks,
339-
// Hugepages sorted only on number of spans allocated. As we allocate
340-
// single-page many-object spans, we do not sort hugepages on longest free
341-
// range when this configuration is used.
342-
kSpansAllocated,
343-
};
344-
345335
// This tracks a set of unfilled hugepages, and fulfills allocations
346336
// with a goal of filling some hugepages as tightly as possible and emptying
347337
// out the remainder.
348338
template <class TrackerType>
349339
class HugePageFiller {
350340
public:
351341
explicit HugePageFiller(
352-
HugePageFillerDenseTrackerType dense_tracker_type,
353342
HugePageFillerSparseTrackerType sparse_tracker_type,
354343
MemoryModifyFunction& unback ABSL_ATTRIBUTE_LIFETIME_BOUND,
355344
MemoryModifyFunction& unback_without_lock ABSL_ATTRIBUTE_LIFETIME_BOUND,
356345
MemoryModifyFunction& collapse ABSL_ATTRIBUTE_LIFETIME_BOUND);
357-
HugePageFiller(Clock clock, HugePageFillerDenseTrackerType dense_tracker_type,
358-
HugePageFillerSparseTrackerType sparse_tracker_type,
359-
MemoryModifyFunction& unback ABSL_ATTRIBUTE_LIFETIME_BOUND,
360-
MemoryModifyFunction& unback_without_lock
361-
ABSL_ATTRIBUTE_LIFETIME_BOUND,
362-
MemoryModifyFunction& collapse ABSL_ATTRIBUTE_LIFETIME_BOUND);
346+
347+
HugePageFiller(
348+
Clock clock, HugePageFillerSparseTrackerType sparse_tracker_type,
349+
MemoryModifyFunction& unback ABSL_ATTRIBUTE_LIFETIME_BOUND,
350+
MemoryModifyFunction& unback_without_lock ABSL_ATTRIBUTE_LIFETIME_BOUND,
351+
MemoryModifyFunction& collapse ABSL_ATTRIBUTE_LIFETIME_BOUND);
363352

364353
typedef TrackerType Tracker;
365354

@@ -580,7 +569,6 @@ class HugePageFiller {
580569
// n_used_partial_released_ is the number of pages which have been allocated
581570
// from the hugepages in the set regular_alloc_partial_released.
582571
Length n_used_partial_released_[AccessDensityPrediction::kPredictionCounts];
583-
const HugePageFillerDenseTrackerType dense_tracker_type_;
584572
const HugePageFillerSparseTrackerType sparse_tracker_type_;
585573

586574
// RemoveFromFillerList pt from the appropriate PageTrackerList.
@@ -797,24 +785,21 @@ inline Length PageTracker::free_pages() const {
797785

798786
template <class TrackerType>
799787
inline HugePageFiller<TrackerType>::HugePageFiller(
800-
HugePageFillerDenseTrackerType dense_tracker_type,
801788
HugePageFillerSparseTrackerType sparse_tracker_type,
802789
MemoryModifyFunction& unback, MemoryModifyFunction& unback_without_lock,
803790
MemoryModifyFunction& collapse)
804791
: HugePageFiller(Clock{.now = absl::base_internal::CycleClock::Now,
805792
.freq = absl::base_internal::CycleClock::Frequency},
806-
dense_tracker_type, sparse_tracker_type, unback,
807-
unback_without_lock, collapse) {}
793+
sparse_tracker_type, unback, unback_without_lock,
794+
collapse) {}
808795

809796
// For testing with mock clock
810797
template <class TrackerType>
811798
inline HugePageFiller<TrackerType>::HugePageFiller(
812-
Clock clock, HugePageFillerDenseTrackerType dense_tracker_type,
813-
HugePageFillerSparseTrackerType sparse_tracker_type,
799+
Clock clock, HugePageFillerSparseTrackerType sparse_tracker_type,
814800
MemoryModifyFunction& unback, MemoryModifyFunction& unback_without_lock,
815801
MemoryModifyFunction& collapse)
816-
: dense_tracker_type_(dense_tracker_type),
817-
sparse_tracker_type_(sparse_tracker_type),
802+
: sparse_tracker_type_(sparse_tracker_type),
818803
size_(NHugePages(0)),
819804
fillerstats_tracker_(clock, absl::Minutes(10), absl::Minutes(5)),
820805
clock_(clock),
@@ -826,9 +811,7 @@ template <class TrackerType>
826811
inline typename HugePageFiller<TrackerType>::TryGetResult
827812
HugePageFiller<TrackerType>::TryGet(Length n, SpanAllocInfo span_alloc_info) {
828813
TC_ASSERT_GT(n, Length(0));
829-
TC_ASSERT(dense_tracker_type_ ==
830-
HugePageFillerDenseTrackerType::kLongestFreeRangeAndChunks ||
831-
span_alloc_info.density == AccessDensityPrediction::kSparse ||
814+
TC_ASSERT(span_alloc_info.density == AccessDensityPrediction::kSparse ||
832815
n == Length(1));
833816

834817
// How do we choose which hugepage to allocate from (among those with
@@ -2311,14 +2294,6 @@ template <class TrackerType>
23112294
inline size_t HugePageFiller<TrackerType>::DenseListFor(const Length longest,
23122295
const size_t chunk,
23132296
size_t nallocs) const {
2314-
if (ABSL_PREDICT_TRUE(
2315-
dense_tracker_type_ ==
2316-
HugePageFillerDenseTrackerType::kLongestFreeRangeAndChunks)) {
2317-
TC_ASSERT_LT(longest, kPagesPerHugePage);
2318-
return longest.raw_num() * kChunks + chunk;
2319-
}
2320-
TC_ASSERT(dense_tracker_type_ ==
2321-
HugePageFillerDenseTrackerType::kSpansAllocated);
23222297
TC_ASSERT_LE(nallocs, kPagesPerHugePage.raw_num());
23232298
// For the dense tracker with hugepages sorted on allocs, the hugepages are
23242299
// placed only in lists that are multiples of kChunks. The in-between lists

tcmalloc/huge_page_filler_fuzz.cc

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "tcmalloc/common.h"
3131
#include "tcmalloc/huge_cache.h"
3232
#include "tcmalloc/huge_page_filler.h"
33+
#include "tcmalloc/huge_page_subrelease.h"
3334
#include "tcmalloc/huge_pages.h"
3435
#include "tcmalloc/internal/allocation_guard.h"
3536
#include "tcmalloc/internal/clock.h"
@@ -161,7 +162,7 @@ void FuzzFiller(const std::string& s) {
161162
// We interpret data as a small DSL for exploring the state space of
162163
// HugePageFiller.
163164
//
164-
// [0] - used for choosing dense tracker type.
165+
// [0] - Reserved.
165166
// [1] - used for choosing sparse tracker type.
166167
// [2] - (available)
167168
//
@@ -173,10 +174,6 @@ void FuzzFiller(const std::string& s) {
173174
// For example, this input can provide a Length to
174175
// allocate, or the index of the previous allocation to
175176
// deallocate.
176-
const HugePageFillerDenseTrackerType dense_tracker_type =
177-
static_cast<uint8_t>(data[0]) >= 128
178-
? HugePageFillerDenseTrackerType::kLongestFreeRangeAndChunks
179-
: HugePageFillerDenseTrackerType::kSpansAllocated;
180177
const HugePageFillerSparseTrackerType sparse_tracker_type =
181178
static_cast<uint8_t>(data[1]) >= 128
182179
? HugePageFillerSparseTrackerType::kExactLongestFreeRange
@@ -185,8 +182,8 @@ void FuzzFiller(const std::string& s) {
185182
size -= kInitBytes;
186183

187184
HugePageFiller<PageTracker> filler(Clock{.now = mock_clock, .freq = freq},
188-
dense_tracker_type, sparse_tracker_type,
189-
unback, unback, collapse);
185+
sparse_tracker_type, unback, unback,
186+
collapse);
190187

191188
std::vector<PageTracker*> trackers;
192189
absl::flat_hash_map<PageTracker*, std::vector<Range>> allocs;
@@ -224,9 +221,7 @@ void FuzzFiller(const std::string& s) {
224221
num_objects = 1;
225222
density = AccessDensityPrediction::kSparse;
226223
}
227-
if (dense_tracker_type ==
228-
HugePageFillerDenseTrackerType::kSpansAllocated &&
229-
density == AccessDensityPrediction::kDense) {
224+
if (density == AccessDensityPrediction::kDense) {
230225
n = Length(1);
231226
}
232227

0 commit comments

Comments
 (0)