Bug 1957331 - QM: Add telemetry for shutdown time excluding suspend; r=dom-storage-reviewers,jstutte
This patch adds a new Glean timing_distribution metric, to measure the duration of QuotaManager shutdown. The measurement runs on the PBackground thread and uses NowExcludingSuspendMs to exclude any system suspend time (e.g. sleep or hibernation), providing a more accurate view of active runtime cost. This helps monitor shutdown performance and detect improvements or regressions, especially for users with significant storage data. Telemetry metadata was added under dom/quota/metrics.yaml. Differential Revision: https://phabricator.services.mozilla.com/D243625
This commit is contained in:
@@ -1840,8 +1840,32 @@ void QuotaManager::ShutdownInstance() {
|
||||
|
||||
recordTimeDeltaHelper->Start();
|
||||
|
||||
// Glean SDK recommends using its own timing APIs where possible. In this
|
||||
// case, we use NowExcludingSuspendMs() directly to manually calculate a
|
||||
// duration that excludes suspend time. This is a valid exception because
|
||||
// our use case is sensitive to suspend, and we need full control over the
|
||||
// timing logic.
|
||||
//
|
||||
// We are currently recording both this and the older helper-based
|
||||
// measurement. The results are not directly comparable, since the new API
|
||||
// uses monotonic time. If this approach proves more reliable, we'll retire
|
||||
// the old telemetry, change the expiration of the new metric to never,
|
||||
// and add a matching "including suspend" version.
|
||||
|
||||
const auto startExcludingSuspendMs = NowExcludingSuspendMs();
|
||||
|
||||
gInstance->Shutdown();
|
||||
|
||||
const auto endExcludingSuspendMs = NowExcludingSuspendMs();
|
||||
|
||||
if (startExcludingSuspendMs && endExcludingSuspendMs) {
|
||||
const auto duration = TimeDuration::FromMilliseconds(
|
||||
*endExcludingSuspendMs - *startExcludingSuspendMs);
|
||||
|
||||
glean::quotamanager_shutdown::total_time_excluding_suspend
|
||||
.AccumulateRawDuration(duration);
|
||||
}
|
||||
|
||||
recordTimeDeltaHelper->End();
|
||||
|
||||
gInstance = nullptr;
|
||||
|
||||
@@ -129,6 +129,34 @@ quotamanager.initialize.temporarystorage:
|
||||
- jvarga@mozilla.com
|
||||
- storage-telemetry@mozilla.com
|
||||
expires: 141
|
||||
quotamanager.shutdown:
|
||||
total_time_excluding_suspend:
|
||||
type: timing_distribution
|
||||
time_unit: millisecond
|
||||
description: >
|
||||
This metric logs the total time required to shut down the QuotaManager
|
||||
instance on the PBackground thread. The duration excludes any periods
|
||||
when the system was suspended (system sleep or hibernation), to better
|
||||
reflect actual time spent performing shutdown.
|
||||
While the shutdown process is measured on the PBackground thread, it
|
||||
involves spinning the event loop and thus waiting for operations on other
|
||||
threads (especially I/O threads) to complete.
|
||||
The primary goal is to measure the actual runtime cost of shutdown under
|
||||
typical conditions, without distortion from system-level suspension
|
||||
delays.
|
||||
This data can help detect performance regressions or improvements related
|
||||
to QuotaManager shutdown behavior, especially in scenarios involving
|
||||
large amounts of user storage data.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1590635
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1590635
|
||||
data_sensitivity:
|
||||
- technical
|
||||
notification_emails:
|
||||
- jvarga@mozilla.com
|
||||
- storage-telemetry@mozilla.com
|
||||
expires: 141
|
||||
|
||||
dom.quota:
|
||||
info_load_time:
|
||||
|
||||
Reference in New Issue
Block a user