Skip to content
Merged
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
13 changes: 7 additions & 6 deletions tcmalloc/testing/profile_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,10 @@ TEST(ProfileTest, EventTraceTruncation) {

// Set a small memory limit to force truncation.
// Note: A single matched allocation produces 2 records (alloc + dealloc),
// each ~600B, requiring at least ~1.3kB to *admit* the first pair.
constexpr int64_t kEventTraceMemoryLimit = 2048;
// each ~600B. A limit of 8192 allows initial allocations (including any
// background activity) to be recorded while ensuring late allocations are
// truncated by filler allocations.
constexpr int64_t kEventTraceMemoryLimit = 8192;
constexpr size_t kApproximateDeallocationSampleRecordSize = 600;
constexpr int kExpectedSampleCount =
kEventTraceMemoryLimit / kApproximateDeallocationSampleRecordSize;
Expand All @@ -554,13 +556,13 @@ TEST(ProfileTest, EventTraceTruncation) {
const absl::Time test_start = absl::Now();
auto token = MallocExtension::StartEventTracing();

// Sleep slightly to guarantee a non-zero, measurable duration.
absl::SleepFor(absl::Milliseconds(20));

// Early allocations (should be captured in the trace).
void* early_ptr = ::operator new(kEarlySize);
::operator delete(early_ptr);

// Sleep slightly to guarantee a non-zero, measurable duration.
absl::SleepFor(absl::Milliseconds(20));

// Trigger enough allocations to exceed the memory limit.
constexpr int kNumFillerAllocs = 50;
for (int i = 0; i < kNumFillerAllocs; ++i) {
Expand Down Expand Up @@ -608,7 +610,6 @@ TEST(ProfileTest, EventTraceTruncation) {
}
}
EXPECT_TRUE(requested_size_id.has_value());

int sample_count = 0;
bool contains_early = false;
bool contains_late = false;
Expand Down
Loading