Unreviewed changes
7 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: chrome/browser/resource_coordinator/tab_lifecycle_unit.h
Insertions: 3, Deletions: 2.
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_LIFECYCLE_UNIT_H_
#define CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_LIFECYCLE_UNIT_H_
+#include "base/byte_size.h"
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "chrome/browser/resource_coordinator/lifecycle_unit_base.h"
@@ -190,8 +191,8 @@
// The timestamp when the tab was last discarded.
base::TimeTicks last_discard_time_;
- // The estimated memory saved (in bytes) during the last discard.
- uint64_t last_discard_memory_estimate_ = 0;
+ // The estimated memory saved during the last discard.
+ base::ByteSize last_discard_memory_estimate_;
// Timestamps to measure the efficiency of the reload.
base::TimeTicks reload_start_time_;
```
```
The name of the file: chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc
Insertions: 2, Deletions: 1.
@@ -379,7 +379,8 @@
// Advance the clock to avoid null timestamps.
test_tick_clock_.Advance(base::Seconds(10));
- const uint64_t kMemoryEstimateBytes = 100 * 1024 * 1024; // 100 MiB.
+ // Define memory in KiB, because that's what Discard() expects.
+ const uint64_t kMemoryEstimateBytes = 100 * 1024;
EXPECT_TRUE(tab_lifecycle_unit->Discard(LifecycleUnitDiscardReason::URGENT,
kMemoryEstimateBytes));
```
```
The name of the file: chrome/browser/resource_coordinator/tab_lifecycle_unit.cc
Insertions: 7, Deletions: 6.
@@ -308,7 +308,7 @@
const base::TimeTicks discard_start_time = NowTicks();
last_discard_time_ = discard_start_time;
- last_discard_memory_estimate_ = tab_memory_footprint_estimate;
+ last_discard_memory_estimate_ = base::KiBU(tab_memory_footprint_estimate);
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
@@ -440,11 +440,12 @@
// Record the estimated memory savings from the original discard. This serves
// as the "resource benefit" metric.
- // Convert the estimate from bytes to MiB for readability in the histogram.
- const int memory_freed_mb = last_discard_memory_estimate_ / 1024 / 1024;
- base::UmaHistogramCounts1000("Tab.Discarding.Reload.FreedMemoryMB",
- memory_freed_mb);
-
+ // Convert the estimate to MiB for readability in the histogram.
+ if (last_discard_memory_estimate_ != base::ByteSize()) {
+ base::UmaHistogramMemoryMB(
+ "Tab.Discarding.Reload.FreedMemoryMB",
+ static_cast<int>(last_discard_memory_estimate_.InMiB()));
+ }
// Reset the flag to ensure metrics are not recorded for subsequent
// in-page navigations or loading events that are not related to the
// discard restoration.
```
Change information
Commit message:
Add UMA metrics to evaluate tab discard decisions
Adds histograms to TabLifecycleUnit to measure the effectiveness of tab
discarding. This captures "user regret" (time between discard and
reload), user intent (was the reload triggered by focus), and efficiency
(reload duration vs. memory freed).
These signals will help quantify false positives in the current
discarding logic and serve as a baseline for future improvements.
New Histograms:
- Tab.Discarding.Reload.TimeSinceDiscard
- Tab.Discarding.Reload.CausedByFocus
- Tab.Discarding.Reload.LoadTime
- Tab.Discarding.Reload.FreedMemoryMB
Change-Id: I93679a6e17dca68703ab39a7eb1a53d82769971c
Cr-Commit-Position: refs/heads/main@{#1566308}
Files:
- M chrome/browser/resource_coordinator/tab_lifecycle_unit.cc
- M chrome/browser/resource_coordinator/tab_lifecycle_unit.h
- M chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc
- M tools/metrics/histograms/metadata/tab/histograms.xml
Change size: M
Delta: 4 files changed, 202 insertions(+), 1 deletion(-)
Branch: refs/heads/main
Submit Requirements:
Code-Review: +1 by Joe Mason