Commit eb0622c9 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

heap: Only emit compaction freed bytes when compacting

Avoid biasing the metric with many 0-samples and only emit the sample
when the GC was actually compacting memory.

Bug: 1056170
Change-Id: I906b7b639fa96b53acc6f3b7235a015f6322123f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2098625Reviewed-by: default avatarOmer Katz <omerkatz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749598}
parent 3b974d90
...@@ -14,11 +14,13 @@ namespace blink { ...@@ -14,11 +14,13 @@ namespace blink {
void ThreadHeapStatsCollector::IncreaseCompactionFreedSize(size_t bytes) { void ThreadHeapStatsCollector::IncreaseCompactionFreedSize(size_t bytes) {
DCHECK(is_started_); DCHECK(is_started_);
current_.compaction_freed_bytes += bytes; current_.compaction_freed_bytes += bytes;
current_.compaction_recorded_events = true;
} }
void ThreadHeapStatsCollector::IncreaseCompactionFreedPages(size_t pages) { void ThreadHeapStatsCollector::IncreaseCompactionFreedPages(size_t pages) {
DCHECK(is_started_); DCHECK(is_started_);
current_.compaction_freed_pages += pages; current_.compaction_freed_pages += pages;
current_.compaction_recorded_events = true;
} }
void ThreadHeapStatsCollector::IncreaseAllocatedObjectSize(size_t bytes) { void ThreadHeapStatsCollector::IncreaseAllocatedObjectSize(size_t bytes) {
......
...@@ -259,6 +259,7 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector { ...@@ -259,6 +259,7 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector {
size_t marked_bytes = 0; size_t marked_bytes = 0;
size_t compaction_freed_bytes = 0; size_t compaction_freed_bytes = 0;
size_t compaction_freed_pages = 0; size_t compaction_freed_pages = 0;
bool compaction_recorded_events = false;
base::TimeDelta scope_data[kNumScopeIds]; base::TimeDelta scope_data[kNumScopeIds];
base::subtle::Atomic32 concurrent_scope_data[kNumConcurrentScopeIds]{0}; base::subtle::Atomic32 concurrent_scope_data[kNumConcurrentScopeIds]{0};
BlinkGC::GCReason reason = static_cast<BlinkGC::GCReason>(0); BlinkGC::GCReason reason = static_cast<BlinkGC::GCReason>(0);
......
...@@ -969,8 +969,10 @@ void UpdateHistograms(const ThreadHeapStatsCollector::Event& event) { ...@@ -969,8 +969,10 @@ void UpdateHistograms(const ThreadHeapStatsCollector::Event& event) {
DEFINE_STATIC_LOCAL( DEFINE_STATIC_LOCAL(
CustomCountHistogram, object_size_freed_by_heap_compaction, CustomCountHistogram, object_size_freed_by_heap_compaction,
("BlinkGC.ObjectSizeFreedByHeapCompaction", 1, 4 * 1024 * 1024, 50)); ("BlinkGC.ObjectSizeFreedByHeapCompaction", 1, 4 * 1024 * 1024, 50));
if (event.compaction_recorded_events) {
object_size_freed_by_heap_compaction.Count( object_size_freed_by_heap_compaction.Count(
CappedSizeInKB(event.compaction_freed_bytes)); CappedSizeInKB(event.compaction_freed_bytes));
}
DEFINE_STATIC_LOCAL(CustomCountHistogram, object_size_before_gc_histogram, DEFINE_STATIC_LOCAL(CustomCountHistogram, object_size_before_gc_histogram,
("BlinkGC.ObjectSizeBeforeGC", 1, 4 * 1024 * 1024, 50)); ("BlinkGC.ObjectSizeBeforeGC", 1, 4 * 1024 * 1024, 50));
......
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