From 0ff05a607d8f39b721a9abae56c50001f6d9c105 Mon Sep 17 00:00:00 2001 From: Colin Liang Date: Mon, 13 Apr 2026 14:02:42 -0700 Subject: [PATCH 1/2] Bug: 488465561 Change-Id: If0e6d33b3906f3964f888d1e2c7388e4c01f57ec --- .../storage/dom_storage/local_storage_impl.cc | 12 ++ .../histograms/metadata/cobalt/histograms.xml | 161 ++++++++++-------- 2 files changed, 103 insertions(+), 70 deletions(-) diff --git a/components/services/storage/dom_storage/local_storage_impl.cc b/components/services/storage/dom_storage/local_storage_impl.cc index 8a4cf174108e..ea7df4788a61 100644 --- a/components/services/storage/dom_storage/local_storage_impl.cc +++ b/components/services/storage/dom_storage/local_storage_impl.cc @@ -671,6 +671,9 @@ void LocalStorageImpl::OnDatabaseOpened(leveldb::Status status) { leveldb_env::LEVELDB_STATUS_MAX); if (!status.ok()) { + base::UmaHistogramEnumeration("Cobalt.LocalStorage.DatabaseOpenError", + leveldb_env::GetLevelDBStatusUMAValue(status), + leveldb_env::LEVELDB_STATUS_MAX); // If we failed to open the database, try to delete and recreate the // database, or ultimately fallback to an in-memory database. DeleteAndRecreateDatabase(); @@ -708,6 +711,9 @@ void LocalStorageImpl::OnGotDatabaseVersion(leveldb::Status status, &db_version) || db_version < kMinSchemaVersion || db_version > kCurrentLocalStorageSchemaVersion) { + base::UmaHistogramEnumeration("Cobalt.LocalStorage.VersionMismatch", + leveldb_env::GetLevelDBStatusUMAValue(status), + leveldb_env::LEVELDB_STATUS_MAX); DeleteAndRecreateDatabase(); return; } @@ -715,6 +721,9 @@ void LocalStorageImpl::OnGotDatabaseVersion(leveldb::Status status, database_initialized_ = true; } else { // Other read error. Possibly database corruption. + base::UmaHistogramEnumeration("Cobalt.LocalStorage.DatabaseReadError", + leveldb_env::GetLevelDBStatusUMAValue(status), + leveldb_env::LEVELDB_STATUS_MAX); DeleteAndRecreateDatabase(); return; } @@ -971,6 +980,9 @@ void LocalStorageImpl::OnCommitResult(leveldb::Status status) { // Deleting StorageAreas in here could cause more commits (and commit // errors), but those commits won't reach OnCommitResult because the area // will have been deleted before the commit finishes. + base::UmaHistogramEnumeration("Cobalt.LocalStorage.DatabaseCommitError", + leveldb_env::GetLevelDBStatusUMAValue(status), + leveldb_env::LEVELDB_STATUS_MAX); DeleteAndRecreateDatabase(); } } diff --git a/tools/metrics/histograms/metadata/cobalt/histograms.xml b/tools/metrics/histograms/metadata/cobalt/histograms.xml index b7b9201c9ff4..650988d52f8f 100644 --- a/tools/metrics/histograms/metadata/cobalt/histograms.xml +++ b/tools/metrics/histograms/metadata/cobalt/histograms.xml @@ -81,6 +81,30 @@ Always run the pretty print utility on this file after editing: + + colinliang@google.com + + Records the leveldb error when a commit fails in Local Storage. + + + + + colinliang@google.com + + Records the leveldb error when opening the Local Storage database fails. + + + + + colinliang@google.com + + Records the leveldb error when a read fails in Local Storage. + + + charleykim@google.com @@ -89,6 +113,15 @@ Always run the pretty print utility on this file after editing: + + colinliang@google.com + + Records the leveldb status when a version mismatch is detected in Local + Storage. + + + charleykim@google.com @@ -96,11 +129,12 @@ Always run the pretty print utility on this file after editing: Records the number of times a platform error was raised due to a navigation timeout or other network error. This is logged every time RaisePlatformError is called; each logged count is the cumulative number of times the error has - been raised. The actual number of sessions with a specific number of platform - errors raised can be raised by subtracting the values of counts larger than - said number. For example, sessions with 2 calls to RaisePlatformError would be - (count for 2 calls) - (count for 3 calls) - ... (count for max calls). - This value is reset to 0 on a successful navigation/app load. + been raised. The actual number of sessions with a specific number of + platform errors raised can be raised by subtracting the values of counts + larger than said number. For example, sessions with 2 calls to + RaisePlatformError would be (count for 2 calls) - (count for 3 calls) - ... + (count for max calls). This value is reset to 0 on a successful + navigation/app load. @@ -158,20 +192,8 @@ Always run the pretty print utility on this file after editing: - - charleykim@google.com - - Records the time it takes to initiate the flush of local storage during a - graceful application exit (e.g., via window.h5vcc.system.exit()). As - `Flush()` is an asynchronous operation, this metric captures the time until - the commit is scheduled, not the completion of the data write to persistent - storage. - - - - + charleykim@google.com Records the time it takes to initiate the flush of local storage during a @@ -193,37 +215,6 @@ Always run the pretty print utility on this file after editing: - - charleykim@google.com - - For every navigation in the primary main frame, this boolean is recorded to - indicate whether the navigation resulted in a network error. This is used to - track the navigation success rate. Aborted navigations are not included. - - - - - tasunny@google.com - - The Percentage of total CPU resources utilized for Cobalt over an interval. - 100% indicates all available cores are fully utilized. This metric is - recorded periodically (default 5 minutes for Android). - - - - - antonlunev@google.com - - Every 10 seconds, a boolean is recorded to this histogram to indicate - whether the RendererThread of a Browser process was hung. The thread is hung - if the current work unit started running more than 10 seconds ago. This is - emitted only in single process mode(when renderer is a thread inside - BrowserProcess). - - - haozheng@google.com @@ -244,32 +235,22 @@ Always run the pretty print utility on this file after editing: - - colinliang@google.com + haozheng@google.com + yijiazhang@google.com - Records the total time taken to check for the migration fast path during - startup. + Records the total time taken to migrate data from the legacy Starboard + storage record to the new Chromium-based storage. - colinliang@google.com - Records the final outcome of the storage migration process. Tracks whether - the migration took the fast path, skipped due to no data, fully succeeded, - or failed during read/injection. - - - - - haozheng@google.com - yijiazhang@google.com - - Records the total time taken to migrate data from the legacy Starboard - storage record to the new Chromium-based storage. + Records the total time taken to check for the migration fast path during + startup. @@ -294,6 +275,16 @@ Always run the pretty print utility on this file after editing: + + colinliang@google.com + + Records the final outcome of the storage migration process. Tracks whether + the migration took the fast path, skipped due to no data, fully succeeded, + or failed during read/injection. + + + haozheng@google.com @@ -312,8 +303,38 @@ Always run the pretty print utility on this file after editing: - + + charleykim@google.com + + For every navigation in the primary main frame, this boolean is recorded to + indicate whether the navigation resulted in a network error. This is used to + track the navigation success rate. Aborted navigations are not included. + + + + + tasunny@google.com + + The Percentage of total CPU resources utilized for Cobalt over an interval. + 100% indicates all available cores are fully utilized. This metric is + recorded periodically (default 5 minutes for Android). + + + + + antonlunev@google.com + + Every 10 seconds, a boolean is recorded to this histogram to indicate + whether the RendererThread of a Browser process was hung. The thread is hung + if the current work unit started running more than 10 seconds ago. This is + emitted only in single process mode(when renderer is a thread inside + BrowserProcess). + + + + tasunny@google.com Records the memory allocated by media decoder buffer for video and audio. From 5589729562c5ea2721c654aba99682849461f0b1 Mon Sep 17 00:00:00 2001 From: Colin Liang Date: Tue, 14 Apr 2026 12:22:16 -0700 Subject: [PATCH 2/2] cobalt macro Change-Id: Iebdc64f9aeccd244a2ebfde747f72ced63b7361c --- .../storage/dom_storage/local_storage_impl.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/services/storage/dom_storage/local_storage_impl.cc b/components/services/storage/dom_storage/local_storage_impl.cc index ba4531367210..e6269fc09f2e 100644 --- a/components/services/storage/dom_storage/local_storage_impl.cc +++ b/components/services/storage/dom_storage/local_storage_impl.cc @@ -671,11 +671,13 @@ void LocalStorageImpl::OnDatabaseOpened(leveldb::Status status) { leveldb_env::LEVELDB_STATUS_MAX); if (!status.ok()) { + // If we failed to open the database, try to delete and recreate the + // database, or ultimately fallback to an in-memory database. +#if BUILDFLAG(IS_COBALT) base::UmaHistogramEnumeration("Cobalt.LocalStorage.DatabaseOpenError", leveldb_env::GetLevelDBStatusUMAValue(status), leveldb_env::LEVELDB_STATUS_MAX); - // If we failed to open the database, try to delete and recreate the - // database, or ultimately fallback to an in-memory database. +#endif DeleteAndRecreateDatabase(); return; } @@ -711,9 +713,11 @@ void LocalStorageImpl::OnGotDatabaseVersion(leveldb::Status status, &db_version) || db_version < kMinSchemaVersion || db_version > kCurrentLocalStorageSchemaVersion) { +#if BUILDFLAG(IS_COBALT) base::UmaHistogramEnumeration("Cobalt.LocalStorage.DatabaseVersionMismatch", leveldb_env::GetLevelDBStatusUMAValue(status), leveldb_env::LEVELDB_STATUS_MAX); +#endif DeleteAndRecreateDatabase(); return; } @@ -721,9 +725,11 @@ void LocalStorageImpl::OnGotDatabaseVersion(leveldb::Status status, database_initialized_ = true; } else { // Other read error. Possibly database corruption. +#if BUILDFLAG(IS_COBALT) base::UmaHistogramEnumeration("Cobalt.LocalStorage.DatabaseReadError", leveldb_env::GetLevelDBStatusUMAValue(status), leveldb_env::LEVELDB_STATUS_MAX); +#endif DeleteAndRecreateDatabase(); return; } @@ -980,9 +986,11 @@ void LocalStorageImpl::OnCommitResult(leveldb::Status status) { // Deleting StorageAreas in here could cause more commits (and commit // errors), but those commits won't reach OnCommitResult because the area // will have been deleted before the commit finishes. +#if BUILDFLAG(IS_COBALT) base::UmaHistogramEnumeration("Cobalt.LocalStorage.DatabaseCommitError", leveldb_env::GetLevelDBStatusUMAValue(status), leveldb_env::LEVELDB_STATUS_MAX); +#endif DeleteAndRecreateDatabase(); } }