Skip to content

Commit

Permalink
Speed up *Pbtxt() by dropping support for indentation and pretty-prin…
Browse files Browse the repository at this point in the history
…ting.

PiperOrigin-RevId: 424178173
Change-Id: I2a79de4f768d5291932086c1eadaf138e7e95c45
  • Loading branch information
EmployedRussian authored and copybara-github committed Jan 25, 2022
1 parent eb9a957 commit 46f6878
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 1,742 deletions.
2 changes: 1 addition & 1 deletion tcmalloc/cpu_cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ class CpuCacheEnvironment {
out.resize(128 << 10);
ANNOTATE_MEMORY_IS_UNINITIALIZED(out.data(), out.size());
Printer p(out.data(), out.size());
PbtxtRegion r(&p, kTop, 0);
PbtxtRegion r(&p, kTop);

cache_.PrintInPbtxt(&r);

Expand Down
14 changes: 7 additions & 7 deletions tcmalloc/huge_page_aware_allocator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ class HugePageAwareAllocatorTest : public ::testing::Test {
return ret;
}

std::string PrintInPbTxt() {
std::string PrintInPbtxt() {
std::string ret;
const size_t kSize = 1 << 20;
ret.resize(kSize);
Printer p(&ret[0], kSize);
{
PbtxtRegion region(&p, kNested, 0);
PbtxtRegion region(&p, kNested);
allocator_->PrintInPbtxt(&region);
}
ret.erase(p.SpaceRequired());
Expand Down Expand Up @@ -350,7 +350,7 @@ TEST_F(HugePageAwareAllocatorTest, DonatedHugePages) {
EXPECT_EQ(donated_huge_pages, NHugePages(1));

EXPECT_THAT(Print(), HasSubstr("filler donations 1"));
EXPECT_THAT(PrintInPbTxt(), HasSubstr("filler_donated_huge_pages: 1"));
EXPECT_THAT(PrintInPbtxt(), HasSubstr("filler_donated_huge_pages: 1"));

// Make a small allocation and then free the large allocation. Slack should
// fall, but we've kept alive our donation to the filler.
Expand All @@ -365,7 +365,7 @@ TEST_F(HugePageAwareAllocatorTest, DonatedHugePages) {
EXPECT_EQ(donated_huge_pages, NHugePages(1));

EXPECT_THAT(Print(), HasSubstr("filler donations 1"));
EXPECT_THAT(PrintInPbTxt(), HasSubstr("filler_donated_huge_pages: 1"));
EXPECT_THAT(PrintInPbtxt(), HasSubstr("filler_donated_huge_pages: 1"));

// Make another large allocation. The number of donated huge pages should
// continue to increase.
Expand All @@ -379,7 +379,7 @@ TEST_F(HugePageAwareAllocatorTest, DonatedHugePages) {
EXPECT_EQ(donated_huge_pages, NHugePages(2));

EXPECT_THAT(Print(), HasSubstr("filler donations 2"));
EXPECT_THAT(PrintInPbTxt(), HasSubstr("filler_donated_huge_pages: 2"));
EXPECT_THAT(PrintInPbtxt(), HasSubstr("filler_donated_huge_pages: 2"));

// Deallocating the small allocation does not reduce the number of donations,
// as we were unable to reassemble the VSS for large1.
Expand All @@ -393,7 +393,7 @@ TEST_F(HugePageAwareAllocatorTest, DonatedHugePages) {
EXPECT_EQ(donated_huge_pages, NHugePages(2));

EXPECT_THAT(Print(), HasSubstr("filler donations 2"));
EXPECT_THAT(PrintInPbTxt(), HasSubstr("filler_donated_huge_pages: 2"));
EXPECT_THAT(PrintInPbtxt(), HasSubstr("filler_donated_huge_pages: 2"));

// Deallocating everything should return slack to 0 and allow large2's
// contiguous VSS to be reassembled.
Expand All @@ -407,7 +407,7 @@ TEST_F(HugePageAwareAllocatorTest, DonatedHugePages) {
EXPECT_EQ(donated_huge_pages, NHugePages(1));

EXPECT_THAT(Print(), HasSubstr("filler donations 1"));
EXPECT_THAT(PrintInPbTxt(), HasSubstr("filler_donated_huge_pages: 1"));
EXPECT_THAT(PrintInPbtxt(), HasSubstr("filler_donated_huge_pages: 1"));
}

TEST_F(HugePageAwareAllocatorTest, PageMapInterference) {
Expand Down
Loading

0 comments on commit 46f6878

Please sign in to comment.