Skip to content

Commit

Permalink
Fix ReducedMemoryUsage for OomIntervention
Browse files Browse the repository at this point in the history
Currently ReducedMemoryUsage metrics in OomIntervention reports negative
numbers when intervention reduces memory. This is confusing and thus
this CL renames the metrics.

Bug: 939702
Change-Id: I5bd7e8ba4d7ffb682ea4565a39964cce74b84c67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1510704
Commit-Queue: Yuzu Saijo <[email protected]>
Reviewed-by: Mark Pearson <[email protected]>
Reviewed-by: Keishi Hattori <[email protected]>
Reviewed-by: Kentaro Hara <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#639824}(cherry picked from commit 6e17ab4916fbbe43806300bd716df18c69cbefd0)
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1522487
Reviewed-by: Yuzu Saijo <[email protected]>
Cr-Commit-Position: refs/branch-heads/3729@{#111}
Cr-Branched-From: d4a8972-refs/heads/master@{#638880}
  • Loading branch information
Yuzu Saijo committed Mar 14, 2019
1 parent d716a8f commit 11b9b75
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 27 deletions.
16 changes: 8 additions & 8 deletions third_party/blink/renderer/controller/oom_intervention_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ void OomInterventionImpl::ReportMemoryStats(
}

int ToMemoryUsageDeltaSample(uint64_t after_kb, uint64_t before_kb) {
int delta_mb = (base::saturated_cast<int>(after_kb) -
base::saturated_cast<int>(before_kb)) /
int delta_mb = (base::saturated_cast<int>(before_kb) -
base::saturated_cast<int>(after_kb)) /
1024;
return std::min(std::max(delta_mb, -500), 500);
}
Expand All @@ -207,26 +207,26 @@ void OomInterventionImpl::TimerFiredUMAReport(TimerBase*) {
switch (number_of_report_needed_--) {
case 3:
base::UmaHistogramSparse(
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter10secs",
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter10secs2",
blink_usage_delta);
base::UmaHistogramSparse(
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter10secs",
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter10secs2",
private_footprint_delta);
break;
case 2:
base::UmaHistogramSparse(
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter20secs",
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter20secs2",
blink_usage_delta);
base::UmaHistogramSparse(
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter20secs",
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter20secs2",
private_footprint_delta);
break;
case 1:
base::UmaHistogramSparse(
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter30secs",
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter30secs2",
blink_usage_delta);
base::UmaHistogramSparse(
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter30secs",
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter30secs2",
private_footprint_delta);
delayed_report_timer_.Stop();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,21 @@ TEST_F(OomInterventionImplTest, ReducedMemoryMetricReporting) {
intervention_->mock_memory_usage_monitor()->SetMockMemoryUsage(usage);
test::RunDelayedTasks(TimeDelta::FromSeconds(10));
histogram_tester.ExpectUniqueSample(
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter10secs", -2,
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter10secs2", 2,
1);
histogram_tester.ExpectUniqueSample(
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter10secs", 2,
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter10secs2", -2,
1);

usage.v8_bytes = initial_blink_usage_bytes - 1;
usage.private_footprint_bytes = initial_private_footprint_bytes + 1;
intervention_->mock_memory_usage_monitor()->SetMockMemoryUsage(usage);
test::RunDelayedTasks(TimeDelta::FromSeconds(10));
histogram_tester.ExpectUniqueSample(
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter20secs", 0, 1);
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter20secs2", 0,
1);
histogram_tester.ExpectUniqueSample(
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter20secs", 0,
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter20secs2", 0,
1);

usage.v8_bytes = initial_blink_usage_bytes - 800 * 1024 * 1024;
Expand All @@ -353,11 +354,11 @@ TEST_F(OomInterventionImplTest, ReducedMemoryMetricReporting) {
intervention_->mock_memory_usage_monitor()->SetMockMemoryUsage(usage);
test::RunDelayedTasks(TimeDelta::FromSeconds(10));
histogram_tester.ExpectUniqueSample(
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter30secs", -500,
"Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter30secs2", 500,
1);
histogram_tester.ExpectUniqueSample(
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter30secs", 500,
1);
"Memory.Experimental.OomIntervention.ReducedRendererPMFAfter30secs2",
-500, 1);
}

} // namespace blink
114 changes: 102 additions & 12 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53227,55 +53227,145 @@ uploading your change for review.

<histogram
name="Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter10secs"
units="MB">
units="MB" expires_after="2019-5-31">
<obsolete>
Replaced by ReducedBlinkUsageAfter10secs2 in 03/2019.
</obsolete>
<owner>[email protected]</owner>
<summary>
Reduced amount of blink usage after 10 seconds of intervention.
Reduced amount of blink usage after 10 seconds of intervention. This reports
negative numbers when reduced.
</summary>
</histogram>

<histogram
name="Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter10secs2"
units="MB" expires_after="2019-7-31">
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Reduced amount of blink usage after 10 seconds of intervention. This reports
positive numbers when reduced.
</summary>
</histogram>

<histogram
name="Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter20secs"
units="MB">
units="MB" expires_after="2019-5-31">
<obsolete>
Replaced by ReducedBlinkUsageAfter20secs2 in 03/2019.
</obsolete>
<owner>[email protected]</owner>
<summary>
Reduced amount of blink usage after 20 seconds of intervention. This reports
negative numbers when reduced.
</summary>
</histogram>

<histogram
name="Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter20secs2"
units="MB" expires_after="2019-7-31">
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Reduced amount of blink usage after 20 seconds of intervention.
Reduced amount of blink usage after 20 seconds of intervention. This reports
positive numbers when reduced.
</summary>
</histogram>

<histogram
name="Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter30secs"
units="MB">
units="MB" expires_after="2019-5-31">
<obsolete>
Replaced by ReducedBlinkUsageAfter30secs2 in 03/2019.
</obsolete>
<owner>[email protected]</owner>
<summary>
Reduced amount of blink usage after 30 seconds of intervention.
Reduced amount of blink usage after 30 seconds of intervention. This reports
negative numbers when reduced.
</summary>
</histogram>

<histogram
name="Memory.Experimental.OomIntervention.ReducedBlinkUsageAfter30secs2"
units="MB" expires_after="2019-7-31">
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Reduced amount of blink usage after 30 seconds of intervention. This reports
positive numbers when reduced.
</summary>
</histogram>

<histogram
name="Memory.Experimental.OomIntervention.ReducedRendererPMFAfter10secs"
units="MB">
units="MB" expires_after="2019-5-31">
<obsolete>
Replaced by ReducedRendererPMFAfter10secs2 in 03/2019.
</obsolete>
<owner>[email protected]</owner>
<summary>
Reduced amount of renderer pmf after 10 seconds of intervention.
Reduced amount of renderer pmf after 10 seconds of intervention. This
reports negative numbers when reduced.
</summary>
</histogram>

<histogram
name="Memory.Experimental.OomIntervention.ReducedRendererPMFAfter10secs2"
units="MB" expires_after="2019-7-31">
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Reduced amount of renderer pmf after 10 seconds of intervention. This
reports positive numbers when reduced.
</summary>
</histogram>

<histogram
name="Memory.Experimental.OomIntervention.ReducedRendererPMFAfter20secs"
units="MB">
units="MB" expires_after="2019-5-31">
<obsolete>
Replaced by ReducedRendererPMFAfter20secs2 in 03/2019.
</obsolete>
<owner>[email protected]</owner>
<summary>
Reduced amount of renderer pmf after 20 seconds of intervention. This
reports negative numbers when reduced.
</summary>
</histogram>

<histogram
name="Memory.Experimental.OomIntervention.ReducedRendererPMFAfter20secs2"
units="MB" expires_after="2019-7-31">
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Reduced amount of renderer pmf after 20 seconds of intervention.
Reduced amount of renderer pmf after 20 seconds of intervention. This
reports positive numbers when reduced.
</summary>
</histogram>

<histogram
name="Memory.Experimental.OomIntervention.ReducedRendererPMFAfter30secs"
units="MB">
units="MB" expires_after="2019-5-31">
<obsolete>
Replaced by ReducedRendererPMFAfter30secs2 in 03/2019.
</obsolete>
<owner>[email protected]</owner>
<summary>
Reduced amount of renderer pmf after 30 seconds of intervention.
Reduced amount of renderer pmf after 30 seconds of intervention. This
reports negative numbers when reduced.
</summary>
</histogram>

<histogram
name="Memory.Experimental.OomIntervention.ReducedRendererPMFAfter30secs2"
units="MB" expires_after="2019-7-31">
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Reduced amount of renderer pmf after 30 seconds of intervention. This
reports positive numbers when reduced.
</summary>
</histogram>

Expand Down

0 comments on commit 11b9b75

Please sign in to comment.