Commit c6a3190b authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

cppgc: Rename allocated_size to physical_size in statistics

Bug: chromium:1056170
Change-Id: I6fb5278dd1ef14faac13602cd28286d0e0d29054
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2689198
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Omer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72672}
parent 42409a2e
...@@ -51,7 +51,7 @@ struct HeapStatistics final { ...@@ -51,7 +51,7 @@ struct HeapStatistics final {
*/ */
struct PageStatistics { struct PageStatistics {
/** Overall amount of memory allocated for the page. */ /** Overall amount of memory allocated for the page. */
size_t allocated_size_bytes = 0; size_t physical_size_bytes = 0;
/** Amount of memory actually used on the page. */ /** Amount of memory actually used on the page. */
size_t used_size_bytes = 0; size_t used_size_bytes = 0;
}; };
...@@ -81,7 +81,7 @@ struct HeapStatistics final { ...@@ -81,7 +81,7 @@ struct HeapStatistics final {
/** The space name */ /** The space name */
std::string name; std::string name;
/** Overall amount of memory allocated for the space. */ /** Overall amount of memory allocated for the space. */
size_t allocated_size_bytes = 0; size_t physical_size_bytes = 0;
/** Amount of memory actually used on the space. */ /** Amount of memory actually used on the space. */
size_t used_size_bytes = 0; size_t used_size_bytes = 0;
/** Statistics for each of the pages in the space. */ /** Statistics for each of the pages in the space. */
...@@ -94,7 +94,7 @@ struct HeapStatistics final { ...@@ -94,7 +94,7 @@ struct HeapStatistics final {
}; };
/** Overall amount of memory allocated for the heap. */ /** Overall amount of memory allocated for the heap. */
size_t allocated_size_bytes = 0; size_t physical_size_bytes = 0;
/** Amount of memory actually used on the heap. */ /** Amount of memory actually used on the heap. */
size_t used_size_bytes = 0; size_t used_size_bytes = 0;
/** Detail level of this HeapStatistics. */ /** Detail level of this HeapStatistics. */
......
...@@ -51,7 +51,7 @@ void FinalizePage(HeapStatistics::SpaceStatistics* space_stats, ...@@ -51,7 +51,7 @@ void FinalizePage(HeapStatistics::SpaceStatistics* space_stats,
HeapStatistics::PageStatistics** page_stats) { HeapStatistics::PageStatistics** page_stats) {
if (*page_stats) { if (*page_stats) {
DCHECK_NOT_NULL(space_stats); DCHECK_NOT_NULL(space_stats);
space_stats->allocated_size_bytes += (*page_stats)->allocated_size_bytes; space_stats->physical_size_bytes += (*page_stats)->physical_size_bytes;
space_stats->used_size_bytes += (*page_stats)->used_size_bytes; space_stats->used_size_bytes += (*page_stats)->used_size_bytes;
} }
*page_stats = nullptr; *page_stats = nullptr;
...@@ -63,7 +63,7 @@ void FinalizeSpace(HeapStatistics* stats, ...@@ -63,7 +63,7 @@ void FinalizeSpace(HeapStatistics* stats,
FinalizePage(*space_stats, page_stats); FinalizePage(*space_stats, page_stats);
if (*space_stats) { if (*space_stats) {
DCHECK_NOT_NULL(stats); DCHECK_NOT_NULL(stats);
stats->allocated_size_bytes += (*space_stats)->allocated_size_bytes; stats->physical_size_bytes += (*space_stats)->physical_size_bytes;
stats->used_size_bytes += (*space_stats)->used_size_bytes; stats->used_size_bytes += (*space_stats)->used_size_bytes;
} }
*space_stats = nullptr; *space_stats = nullptr;
...@@ -94,7 +94,7 @@ HeapStatistics HeapStatisticsCollector::CollectStatistics(HeapBase* heap) { ...@@ -94,7 +94,7 @@ HeapStatistics HeapStatisticsCollector::CollectStatistics(HeapBase* heap) {
FinalizeSpace(current_stats_, &current_space_stats_, &current_page_stats_); FinalizeSpace(current_stats_, &current_space_stats_, &current_page_stats_);
DCHECK_EQ(heap->stats_collector()->allocated_memory_size(), DCHECK_EQ(heap->stats_collector()->allocated_memory_size(),
stats.allocated_size_bytes); stats.physical_size_bytes);
return stats; return stats;
} }
...@@ -135,7 +135,7 @@ bool HeapStatisticsCollector::VisitLargePage(LargePage* page) { ...@@ -135,7 +135,7 @@ bool HeapStatisticsCollector::VisitLargePage(LargePage* page) {
size_t object_size = page->PayloadSize(); size_t object_size = page->PayloadSize();
RecordObjectType(current_space_stats_, object_header, object_size); RecordObjectType(current_space_stats_, object_header, object_size);
size_t allocated_size = LargePage::AllocationSize(object_size); size_t allocated_size = LargePage::AllocationSize(object_size);
current_space_stats_->allocated_size_bytes += allocated_size; current_space_stats_->physical_size_bytes += allocated_size;
current_space_stats_->used_size_bytes += object_size; current_space_stats_->used_size_bytes += object_size;
current_space_stats_->page_stats.emplace_back( current_space_stats_->page_stats.emplace_back(
HeapStatistics::PageStatistics{allocated_size, object_size}); HeapStatistics::PageStatistics{allocated_size, object_size});
......
...@@ -69,24 +69,24 @@ TEST_F(HeapStatisticsCollectorTest, NonEmptyNormalPage) { ...@@ -69,24 +69,24 @@ TEST_F(HeapStatisticsCollectorTest, NonEmptyNormalPage) {
HeapStatistics::DetailLevel::kDetailed); HeapStatistics::DetailLevel::kDetailed);
EXPECT_EQ(HeapStatistics::DetailLevel::kDetailed, EXPECT_EQ(HeapStatistics::DetailLevel::kDetailed,
detailed_stats.detail_level); detailed_stats.detail_level);
EXPECT_EQ(kPageSize, detailed_stats.allocated_size_bytes); EXPECT_EQ(kPageSize, detailed_stats.physical_size_bytes);
EXPECT_EQ(used_size, detailed_stats.used_size_bytes); EXPECT_EQ(used_size, detailed_stats.used_size_bytes);
EXPECT_EQ(RawHeap::kNumberOfRegularSpaces, detailed_stats.space_stats.size()); EXPECT_EQ(RawHeap::kNumberOfRegularSpaces, detailed_stats.space_stats.size());
bool found_non_empty_space = false; bool found_non_empty_space = false;
for (const HeapStatistics::SpaceStatistics& space_stats : for (const HeapStatistics::SpaceStatistics& space_stats :
detailed_stats.space_stats) { detailed_stats.space_stats) {
if (space_stats.page_stats.empty()) { if (space_stats.page_stats.empty()) {
EXPECT_EQ(0u, space_stats.allocated_size_bytes); EXPECT_EQ(0u, space_stats.physical_size_bytes);
EXPECT_EQ(0u, space_stats.used_size_bytes); EXPECT_EQ(0u, space_stats.used_size_bytes);
continue; continue;
} }
EXPECT_NE("LargePageSpace", space_stats.name); EXPECT_NE("LargePageSpace", space_stats.name);
EXPECT_FALSE(found_non_empty_space); EXPECT_FALSE(found_non_empty_space);
found_non_empty_space = true; found_non_empty_space = true;
EXPECT_EQ(kPageSize, space_stats.allocated_size_bytes); EXPECT_EQ(kPageSize, space_stats.physical_size_bytes);
EXPECT_EQ(used_size, space_stats.used_size_bytes); EXPECT_EQ(used_size, space_stats.used_size_bytes);
EXPECT_EQ(1u, space_stats.page_stats.size()); EXPECT_EQ(1u, space_stats.page_stats.size());
EXPECT_EQ(kPageSize, space_stats.page_stats.back().allocated_size_bytes); EXPECT_EQ(kPageSize, space_stats.page_stats.back().physical_size_bytes);
EXPECT_EQ(used_size, space_stats.page_stats.back().used_size_bytes); EXPECT_EQ(used_size, space_stats.page_stats.back().used_size_bytes);
} }
EXPECT_TRUE(found_non_empty_space); EXPECT_TRUE(found_non_empty_space);
...@@ -97,31 +97,30 @@ TEST_F(HeapStatisticsCollectorTest, NonEmptyLargePage) { ...@@ -97,31 +97,30 @@ TEST_F(HeapStatisticsCollectorTest, NonEmptyLargePage) {
GetHeap()->GetAllocationHandle()); GetHeap()->GetAllocationHandle());
static constexpr size_t used_size = RoundUp<kAllocationGranularity>( static constexpr size_t used_size = RoundUp<kAllocationGranularity>(
kLargeObjectSizeThreshold + sizeof(HeapObjectHeader)); kLargeObjectSizeThreshold + sizeof(HeapObjectHeader));
static constexpr size_t allocated_size = static constexpr size_t physical_size =
RoundUp<kAllocationGranularity>(used_size + sizeof(LargePage)); RoundUp<kAllocationGranularity>(used_size + sizeof(LargePage));
HeapStatistics detailed_stats = Heap::From(GetHeap())->CollectStatistics( HeapStatistics detailed_stats = Heap::From(GetHeap())->CollectStatistics(
HeapStatistics::DetailLevel::kDetailed); HeapStatistics::DetailLevel::kDetailed);
EXPECT_EQ(HeapStatistics::DetailLevel::kDetailed, EXPECT_EQ(HeapStatistics::DetailLevel::kDetailed,
detailed_stats.detail_level); detailed_stats.detail_level);
EXPECT_EQ(allocated_size, detailed_stats.allocated_size_bytes); EXPECT_EQ(physical_size, detailed_stats.physical_size_bytes);
EXPECT_EQ(used_size, detailed_stats.used_size_bytes); EXPECT_EQ(used_size, detailed_stats.used_size_bytes);
EXPECT_EQ(RawHeap::kNumberOfRegularSpaces, detailed_stats.space_stats.size()); EXPECT_EQ(RawHeap::kNumberOfRegularSpaces, detailed_stats.space_stats.size());
bool found_non_empty_space = false; bool found_non_empty_space = false;
for (const HeapStatistics::SpaceStatistics& space_stats : for (const HeapStatistics::SpaceStatistics& space_stats :
detailed_stats.space_stats) { detailed_stats.space_stats) {
if (space_stats.page_stats.empty()) { if (space_stats.page_stats.empty()) {
EXPECT_EQ(0u, space_stats.allocated_size_bytes); EXPECT_EQ(0u, space_stats.physical_size_bytes);
EXPECT_EQ(0u, space_stats.used_size_bytes); EXPECT_EQ(0u, space_stats.used_size_bytes);
continue; continue;
} }
EXPECT_EQ("LargePageSpace", space_stats.name); EXPECT_EQ("LargePageSpace", space_stats.name);
EXPECT_FALSE(found_non_empty_space); EXPECT_FALSE(found_non_empty_space);
found_non_empty_space = true; found_non_empty_space = true;
EXPECT_EQ(allocated_size, space_stats.allocated_size_bytes); EXPECT_EQ(physical_size, space_stats.physical_size_bytes);
EXPECT_EQ(used_size, space_stats.used_size_bytes); EXPECT_EQ(used_size, space_stats.used_size_bytes);
EXPECT_EQ(1u, space_stats.page_stats.size()); EXPECT_EQ(1u, space_stats.page_stats.size());
EXPECT_EQ(allocated_size, EXPECT_EQ(physical_size, space_stats.page_stats.back().physical_size_bytes);
space_stats.page_stats.back().allocated_size_bytes);
EXPECT_EQ(used_size, space_stats.page_stats.back().used_size_bytes); EXPECT_EQ(used_size, space_stats.page_stats.back().used_size_bytes);
} }
EXPECT_TRUE(found_non_empty_space); EXPECT_TRUE(found_non_empty_space);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment