Skip to content

Commit b343eb8

Browse files
ckennellycopybara-github
authored andcommitted
Delete tests redundant with fuzzers.
* `SpanTest.FreelistRandomized` is subsumed by `span_fuzz.cc`. * `HugePageAwareAllocatorTest.Fuzz` is subsumed by `huge_page_aware_allocator_fuzz.cc`. PiperOrigin-RevId: 955372671
1 parent 39021e6 commit b343eb8

3 files changed

Lines changed: 0 additions & 92 deletions

File tree

tcmalloc/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,6 @@ create_tcmalloc_testsuite(
12421242
srcs = ["span_test.cc"],
12431243
copts = TCMALLOC_DEFAULT_COPTS,
12441244
deps = [
1245-
":experiment",
12461245
"//tcmalloc/internal:logging",
12471246
"@com_github_google_benchmark//:benchmark",
12481247
"@com_google_absl//absl/base",

tcmalloc/huge_page_aware_allocator_test.cc

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -321,30 +321,6 @@ struct SpanInfo {
321321
SpanAllocInfo span_alloc_info;
322322
};
323323

324-
TEST_P(HugePageAwareAllocatorTest, Fuzz) {
325-
absl::BitGen rng;
326-
std::vector<SpanInfo> allocs;
327-
for (int i = 0; i < 1000; ++i) {
328-
auto [n, span_alloc_info] = RandomAllocSize(rng);
329-
Span* s = New(n, span_alloc_info);
330-
allocs.push_back(SpanInfo{s, span_alloc_info});
331-
}
332-
static const size_t kReps = 10 * 1000;
333-
for (int i = 0; i < kReps; ++i) {
334-
SCOPED_TRACE(absl::StrFormat("%d reps, %d pages", i, total_.raw_num()));
335-
size_t index = absl::Uniform<int32_t>(rng, 0, allocs.size());
336-
Span* old_span = allocs[index].span;
337-
size_t objects_per_span = allocs[index].span_alloc_info.objects_per_span;
338-
Delete(old_span, objects_per_span);
339-
auto [n, span_alloc_info] = RandomAllocSize(rng);
340-
allocs[index] = SpanInfo{New(n, span_alloc_info), span_alloc_info};
341-
}
342-
343-
for (auto s : allocs) {
344-
Delete(s.span, s.span_alloc_info.objects_per_span);
345-
}
346-
}
347-
348324
// Prevent regression of the fragmentation problem that was reported in
349325
// b/63301358, reproduced in CL/161345659 and (partially) fixed in CL/161305971.
350326
TEST_P(HugePageAwareAllocatorTest, JustUnderMultipleOfHugepages) {

tcmalloc/span_test.cc

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -250,73 +250,6 @@ TEST_P(SpanTest, AllocTime) {
250250
kSpanAllocTime & kAllocTimeMask);
251251
}
252252

253-
TEST_P(SpanTest, FreelistRandomized) {
254-
Span& span_ = raw_span_.span();
255-
256-
char* start = static_cast<char*>(span_.start_address());
257-
258-
// Do a bunch of random pushes/pops with random batch size.
259-
absl::BitGen rng;
260-
absl::flat_hash_set<void*> objects;
261-
void* batch[kMaxObjectsToMove];
262-
for (size_t x = 0; x < 10000; ++x) {
263-
if (!objects.empty() && absl::Bernoulli(rng, 1.0 / 2)) {
264-
void* p = *objects.begin();
265-
bool ok;
266-
if (absl::Bernoulli(rng, 0.5)) {
267-
Span::ObjIdx objidx;
268-
if (Span::UseBitmapForSize(size_)) {
269-
objidx = span_.BitmapPtrToIdx(p, size_, reciprocal_);
270-
} else {
271-
objidx = span_.PtrToIdx(p, size_);
272-
}
273-
ok = span_.FreelistPushBatch(absl::MakeSpan(&objidx, 1), size_,
274-
reciprocal_);
275-
} else {
276-
ok = span_.FreelistPushBatch(absl::MakeSpan(&p, 1), size_, reciprocal_);
277-
}
278-
279-
if (ok) {
280-
objects.erase(objects.begin());
281-
} else {
282-
EXPECT_EQ(objects.size(), 1);
283-
}
284-
EXPECT_EQ(span_.FreelistEmpty(size_, objects_per_span_),
285-
objects_per_span_ == 1);
286-
} else {
287-
size_t want = absl::Uniform<int32_t>(rng, 0, batch_size_) + 1;
288-
size_t n = span_.FreelistPopBatch(absl::MakeSpan(batch, want), size_);
289-
if (n < want) {
290-
EXPECT_TRUE(span_.FreelistEmpty(size_, objects_per_span_));
291-
}
292-
for (size_t i = 0; i < n; ++i) {
293-
EXPECT_TRUE(objects.insert(batch[i]).second);
294-
}
295-
}
296-
}
297-
298-
EXPECT_EQ(span_.AllocTime() & kAllocTimeMask,
299-
kSpanAllocTime & kAllocTimeMask);
300-
// Now pop everything what's there.
301-
for (;;) {
302-
size_t n =
303-
span_.FreelistPopBatch(absl::MakeSpan(batch, batch_size_), size_);
304-
for (size_t i = 0; i < n; ++i) {
305-
EXPECT_TRUE(objects.insert(batch[i]).second);
306-
}
307-
if (n < batch_size_) {
308-
break;
309-
}
310-
}
311-
// Check that we have collected all objects.
312-
EXPECT_EQ(objects.size(), objects_per_span_);
313-
for (void* p : objects) {
314-
uintptr_t off = reinterpret_cast<char*>(p) - start;
315-
EXPECT_LT(off, span_.bytes_in_span());
316-
EXPECT_EQ(off % size_, 0);
317-
}
318-
}
319-
320253
INSTANTIATE_TEST_SUITE_P(All, SpanTest, testing::Range(size_t(1), kNumClasses));
321254

322255
TEST(SpanAllocatorTest, Alignment) {

0 commit comments

Comments
 (0)