Add UMA metrics to evaluate tab discard decisions [chromium/src : main]

0 views
Skip to first unread message

Alex Attar (Gerrit)

unread,
Jan 6, 2026, 1:17:31 PM (11 days ago) Jan 6
to Chromium LUCI CQ, Chromium Metrics Reviews, chromium...@chromium.org, asvitkine...@chromium.org, chrome-gr...@chromium.org

Alex Attar voted and added 1 comment

Votes added by Alex Attar

Auto-Submit+1
Commit-Queue+1

1 comment

Patchset-level comments
File-level comment, Patchset 6:
Alex Attar . resolved

Please take a look,
Thanks

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I93679a6e17dca68703ab39a7eb1a53d82769971c
Gerrit-Change-Number: 7399856
Gerrit-PatchSet: 7
Gerrit-Owner: Alex Attar <aat...@google.com>
Gerrit-Reviewer: Alex Attar <aat...@google.com>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-Comment-Date: Tue, 06 Jan 2026 18:17:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Alex Attar (Gerrit)

unread,
Jan 6, 2026, 1:17:56 PM (11 days ago) Jan 6
to Chromium LUCI CQ, Chromium Metrics Reviews, chromium...@chromium.org, asvitkine...@chromium.org, chrome-gr...@chromium.org
Attention needed from Joe Mason

Alex Attar added 1 comment

Patchset-level comments
File-level comment, Patchset 7 (Latest):
Alex Attar . resolved

Please take a look,
thanks

Open in Gerrit

Related details

Attention is currently required from:
  • Joe Mason
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I93679a6e17dca68703ab39a7eb1a53d82769971c
Gerrit-Change-Number: 7399856
Gerrit-PatchSet: 7
Gerrit-Owner: Alex Attar <aat...@google.com>
Gerrit-Reviewer: Alex Attar <aat...@google.com>
Gerrit-Reviewer: Joe Mason <joenot...@google.com>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-Attention: Joe Mason <joenot...@google.com>
Gerrit-Comment-Date: Tue, 06 Jan 2026 18:17:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Joe Mason (Gerrit)

unread,
Jan 6, 2026, 3:23:34 PM (11 days ago) Jan 6
to Alex Attar, Chromium LUCI CQ, Chromium Metrics Reviews, chromium...@chromium.org, asvitkine...@chromium.org, chrome-gr...@chromium.org
Attention needed from Alex Attar

Joe Mason voted and added 3 comments

Votes added by Joe Mason

Code-Review+1

3 comments

Patchset-level comments
Joe Mason . resolved

LGTM with nits

File chrome/browser/resource_coordinator/tab_lifecycle_unit.h
Line 194, Patchset 7 (Latest): uint64_t last_discard_memory_estimate_ = 0;
Joe Mason . unresolved

Nit: prefer `ByteSize` for this. No need to change the API - you can convert `tab_memory_footprint_estimate` to a ByteSize at the start of Discard().

File chrome/browser/resource_coordinator/tab_lifecycle_unit.cc
Line 444, Patchset 7 (Latest): const int memory_freed_mb = last_discard_memory_estimate_ / 1024 / 1024;
Open in Gerrit

Related details

Attention is currently required from:
  • Alex Attar
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I93679a6e17dca68703ab39a7eb1a53d82769971c
Gerrit-Change-Number: 7399856
Gerrit-PatchSet: 7
Gerrit-Owner: Alex Attar <aat...@google.com>
Gerrit-Reviewer: Alex Attar <aat...@google.com>
Gerrit-Reviewer: Joe Mason <joenot...@google.com>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-Attention: Alex Attar <aat...@google.com>
Gerrit-Comment-Date: Tue, 06 Jan 2026 20:23:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Alex Attar (Gerrit)

unread,
Jan 6, 2026, 4:01:55 PM (11 days ago) Jan 6
to Chromium LUCI CQ, Chromium Metrics Reviews, chromium...@chromium.org, asvitkine...@chromium.org, chrome-gr...@chromium.org

Alex Attar voted and added 2 comments

Votes added by Alex Attar

Auto-Submit+1

2 comments

File chrome/browser/resource_coordinator/tab_lifecycle_unit.h
Line 194, Patchset 7: uint64_t last_discard_memory_estimate_ = 0;
Joe Mason . resolved

Nit: prefer `ByteSize` for this. No need to change the API - you can convert `tab_memory_footprint_estimate` to a ByteSize at the start of Discard().

Alex Attar

Done

File chrome/browser/resource_coordinator/tab_lifecycle_unit.cc
Line 444, Patchset 7: const int memory_freed_mb = last_discard_memory_estimate_ / 1024 / 1024;
Joe Mason . resolved
Alex Attar

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I93679a6e17dca68703ab39a7eb1a53d82769971c
    Gerrit-Change-Number: 7399856
    Gerrit-PatchSet: 8
    Gerrit-Owner: Alex Attar <aat...@google.com>
    Gerrit-Reviewer: Alex Attar <aat...@google.com>
    Gerrit-Reviewer: Joe Mason <joenot...@google.com>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-Comment-Date: Tue, 06 Jan 2026 21:01:47 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Joe Mason <joenot...@google.com>
    satisfied_requirement
    open
    diffy

    Alex Attar (Gerrit)

    unread,
    Jan 8, 2026, 10:59:13 AM (9 days ago) Jan 8
    to Chromium LUCI CQ, Chromium Metrics Reviews, chromium...@chromium.org, asvitkine...@chromium.org, chrome-gr...@chromium.org

    Alex Attar voted Commit-Queue+2

    Commit-Queue+2
    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I93679a6e17dca68703ab39a7eb1a53d82769971c
    Gerrit-Change-Number: 7399856
    Gerrit-PatchSet: 9
    Gerrit-Owner: Alex Attar <aat...@google.com>
    Gerrit-Reviewer: Alex Attar <aat...@google.com>
    Gerrit-Reviewer: Joe Mason <joenot...@google.com>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-Comment-Date: Thu, 08 Jan 2026 15:59:05 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Chromium LUCI CQ (Gerrit)

    unread,
    Jan 8, 2026, 11:02:59 AM (9 days ago) Jan 8
    to Alex Attar, Chromium Metrics Reviews, chromium...@chromium.org, asvitkine...@chromium.org, chrome-gr...@chromium.org

    Chromium LUCI CQ submitted the change with unreviewed changes

    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
    Reviewed-by: Joe Mason <joenot...@google.com>
    Commit-Queue: Alex Attar <aat...@google.com>
    Auto-Submit: Alex Attar <aat...@google.com>
    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:
    • requirement satisfiedCode-Review: +1 by Joe Mason
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I93679a6e17dca68703ab39a7eb1a53d82769971c
    Gerrit-Change-Number: 7399856
    Gerrit-PatchSet: 10
    Gerrit-Owner: Alex Attar <aat...@google.com>
    Gerrit-Reviewer: Alex Attar <aat...@google.com>
    Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
    Gerrit-Reviewer: Joe Mason <joenot...@google.com>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages