tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 45faaf0ca3708954443548a1866904b2618a5e78
parent 0ec5b7dd75f1108e641c3af22ec24b7092a71148
Author: Bas Schouten <bschouten@mozilla.com>
Date:   Tue,  7 Oct 2025 16:20:00 +0000

Bug 1988716 - Part 3: Make numerous memory probes labeled with their process. r=mccr8,toolkit-telemetry-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D264979

Diffstat:
Mtoolkit/components/telemetry/Histograms.json | 54------------------------------------------------------
Mtoolkit/components/telemetry/histogram-allowlists.json | 2--
Mxpcom/base/MemoryTelemetry.cpp | 10++++++----
Mxpcom/metrics.yaml | 20++++++++------------
4 files changed, 14 insertions(+), 72 deletions(-)

diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json @@ -721,35 +721,6 @@ "n_buckets": 100, "description": "GPU process initialization (excluding XPCOM and fork time) time in milliseconds" }, - "MEMORY_RESIDENT_FAST": { - "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec"], - "alert_emails": ["memshrink-telemetry-alerts@mozilla.com"], - "expires_in_version": "never", - "kind": "exponential", - "low": 32768, - "high": 16777216, - "n_buckets": 100, - "bug_numbers": [1226196, 1870550], - "description": "Resident memory size (KB)", - "releaseChannelCollection": "opt-out" - }, - "MEMORY_RESIDENT_PEAK": { - "record_in_processes": ["main", "content"], - "products": ["firefox"], - "alert_emails": [ - "memshrink-telemetry-alerts@mozilla.com", - "amccreight@mozilla.com" - ], - "expires_in_version": "never", - "kind": "exponential", - "low": 32768, - "high": 16777216, - "n_buckets": 100, - "bug_numbers": [1551648, 1870550], - "description": "Peak resident memory size (KB)", - "releaseChannelCollection": "opt-out" - }, "MEMORY_TOTAL": { "record_in_processes": ["main"], "products": ["firefox", "fennec", "thunderbird"], @@ -778,19 +749,6 @@ "n_buckets": 100, "description": "Absolute difference of each content process' USS and the mean of USS's, normalized by the mean, in percentage. It will be recorded with the rest of the memory probes when gatherMemory is called, if at least 2 content processes are alive. Example: in case of 4 content processes with USS's: 1G, 500MB, 1G, 1.5G, the reported numbers will be: 0, 50, 0, 50. Which indicates that 2 processes used 50% more or 50% less memory than the avarage and 2 used exactly as much as the avarage." }, - "MEMORY_UNIQUE": { - "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec"], - "alert_emails": ["memshrink-telemetry-alerts@mozilla.com"], - "bug_numbers": [1198209, 1870550], - "expires_in_version": "never", - "kind": "exponential", - "low": 32768, - "high": 16777216, - "n_buckets": 100, - "description": "Unique Set Size (KB)", - "releaseChannelCollection": "opt-out" - }, "MEMORY_UNIQUE_CONTENT_STARTUP": { "record_in_processes": ["content"], "products": ["firefox", "fennec"], @@ -888,18 +846,6 @@ "n_buckets": 50, "description": "Total JavaScript realms used for web pages." }, - "MEMORY_JS_GC_HEAP": { - "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec", "thunderbird"], - "alert_emails": ["memshrink-telemetry-alerts@mozilla.com"], - "expires_in_version": "never", - "releaseChannelCollection": "opt-out", - "kind": "exponential", - "low": 1024, - "high": 16777216, - "n_buckets": 200, - "description": "Memory used by the garbage-collected JavaScript heap (KB)" - }, "MEMORY_STORAGE_SQLITE": { "record_in_processes": ["main", "content"], "products": ["firefox", "fennec"], diff --git a/toolkit/components/telemetry/histogram-allowlists.json b/toolkit/components/telemetry/histogram-allowlists.json @@ -285,7 +285,6 @@ "MEMORY_IMAGES_CONTENT_USED_UNCOMPRESSED", "MEMORY_JS_COMPARTMENTS_SYSTEM", "MEMORY_JS_COMPARTMENTS_USER", - "MEMORY_JS_GC_HEAP", "MEMORY_STORAGE_SQLITE", "MEMORY_VSIZE", "MEMORY_VSIZE_MAX_CONTIGUOUS", @@ -441,7 +440,6 @@ "XMLHTTPREQUEST_ASYNC_OR_SYNC" ], "n_buckets": [ - "MEMORY_JS_GC_HEAP", "MEMORY_HEAP_ALLOCATED", "HTTP_REQUEST_PER_PAGE_FROM_CACHE", "SSL_TIME_UNTIL_READY", diff --git a/xpcom/base/MemoryTelemetry.cpp b/xpcom/base/MemoryTelemetry.cpp @@ -267,6 +267,8 @@ nsresult MemoryTelemetry::GatherReports( RECORD_OUTER(metric, glean::memory::id.AccumulateSingleSample(amt);) #define RECORD_BYTES(id, metric) \ RECORD_OUTER(metric, glean::memory::id.Accumulate(amt / 1024);) +#define RECORD_BYTES_PER_PROCESS(id, metric) \ + RECORD_OUTER(metric, glean::memory::id.ProcessGet().Accumulate(amt / 1024);) #define RECORD_PERCENTAGE(id, metric) \ RECORD_OUTER(metric, glean::memory::id.AccumulateSingleSample(amt / 100);) #define RECORD_COUNT_CUMULATIVE(id, metric) \ @@ -313,7 +315,7 @@ nsresult MemoryTelemetry::GatherReports( // Collect cheap or main-thread only metrics synchronously, on the main // thread. - RECORD_BYTES(js_gc_heap, JSMainRuntimeGCHeap); + RECORD_BYTES_PER_PROCESS(js_gc_heap, JSMainRuntimeGCHeap); RECORD_COUNT(js_compartments_system, JSMainRuntimeCompartmentsSystem); RECORD_COUNT(js_compartments_user, JSMainRuntimeCompartmentsUser); RECORD_COUNT(js_realms_system, JSMainRuntimeRealmsSystem); @@ -358,12 +360,12 @@ nsresult MemoryTelemetry::GatherReports( #if !defined(HAVE_64BIT_BUILD) || !defined(XP_WIN) RECORD_BYTES(vsize_max_contiguous, VsizeMaxContiguous); #endif - RECORD_BYTES(resident_fast, ResidentFast); - RECORD_BYTES(resident_peak, ResidentPeak); + RECORD_BYTES_PER_PROCESS(resident_fast, ResidentFast); + RECORD_BYTES_PER_PROCESS(resident_peak, ResidentPeak); // Although we can measure unique memory on MacOS we choose not to, because // doing so is too slow for telemetry. #ifndef XP_MACOSX - RECORD_BYTES(unique, ResidentUnique); + RECORD_BYTES_PER_PROCESS(unique, ResidentUnique); #endif if (completionRunnable) { diff --git a/xpcom/metrics.yaml b/xpcom/metrics.yaml @@ -492,9 +492,9 @@ cycle_collector: memory: resident_fast: - type: memory_distribution + type: labeled_memory_distribution description: > - Resident memory size (KB) + Resident memory size (KB) by process type This metric was generated to correspond to the Legacy Telemetry exponential histogram MEMORY_RESIDENT_FAST. @@ -508,12 +508,11 @@ memory: notification_emails: - memshrink-telemetry-alerts@mozilla.com expires: never - telemetry_mirror: MEMORY_RESIDENT_FAST resident_peak: - type: memory_distribution + type: labeled_memory_distribution description: > - Peak resident memory size (KB) + Peak resident memory size (KB) by process type This metric was generated to correspond to the Legacy Telemetry exponential histogram MEMORY_RESIDENT_PEAK. @@ -528,7 +527,6 @@ memory: - memshrink-telemetry-alerts@mozilla.com - amccreight@mozilla.com expires: never - telemetry_mirror: MEMORY_RESIDENT_PEAK total: type: memory_distribution @@ -579,9 +577,9 @@ memory: telemetry_mirror: MEMORY_DISTRIBUTION_AMONG_CONTENT unique: - type: memory_distribution + type: labeled_memory_distribution description: > - Unique Set Size (KB) + Unique Set Size (KB) by process type This metric was generated to correspond to the Legacy Telemetry exponential histogram MEMORY_UNIQUE. @@ -595,7 +593,6 @@ memory: notification_emails: - memshrink-telemetry-alerts@mozilla.com expires: never - telemetry_mirror: MEMORY_UNIQUE vsize: type: memory_distribution @@ -718,9 +715,9 @@ memory: telemetry_mirror: MEMORY_JS_REALMS_USER js_gc_heap: - type: memory_distribution + type: labeled_memory_distribution description: > - Memory used by the garbage-collected JavaScript heap (KB) + Memory used by the garbage-collected JavaScript heap (KB) by process type This metric was generated to correspond to the Legacy Telemetry exponential histogram MEMORY_JS_GC_HEAP. @@ -732,7 +729,6 @@ memory: notification_emails: - memshrink-telemetry-alerts@mozilla.com expires: never - telemetry_mirror: MEMORY_JS_GC_HEAP storage_sqlite: type: memory_distribution