Bug 1935420 - Migrate histograms to use Glean APIs in nsCycleCollector.cpp, r=chutten.

Differential Revision: https://phabricator.services.mozilla.com/D233844
This commit is contained in:
Florian Quèze committed 2025-01-24 14:36:18 +00:00
1 parent 1286b1f91a
commit 15587550e8
2 files changed
+231 -18

No files matched your search

+32 -18
View File
@@ -177,7 +177,7 @@
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/SegmentedVector.h"
#include "mozilla/Telemetry.h"
#include "mozilla/glean/XpcomMetrics.h"
#include "mozilla/ThreadLocal.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/Unused.h"
@@ -562,15 +562,6 @@ class EdgePool {
# define CC_GRAPH_ASSERT(b)
#endif
#define CC_TELEMETRY(_name, _value) \
do { \
if (NS_IsMainThread()) { \
Telemetry::Accumulate(Telemetry::CYCLE_COLLECTOR##_name, _value); \
} else { \
Telemetry::Accumulate(Telemetry::CYCLE_COLLECTOR_WORKER##_name, _value); \
} \
} while (0)
enum NodeColor { black, white, grey };
// This structure should be kept as small as possible; we may expect
@@ -3464,7 +3455,17 @@ void nsCycleCollector::FixGrayBits(bool aIsShutdown, TimeLog& aTimeLog) {
bool needGC = !mCCJSRuntime->AreGCGrayBitsValid();
// Only do a telemetry ping for non-shutdown CCs.
CC_TELEMETRY(_NEED_GC, needGC);
if (NS_IsMainThread()) {
glean::cycle_collector::need_gc
.EnumGet(static_cast<glean::cycle_collector::NeedGcLabel>(needGC))
.Add();
} else {
glean::cycle_collector::worker_need_gc
.EnumGet(
static_cast<glean::cycle_collector::WorkerNeedGcLabel>(needGC))
.Add();
}
if (!needGC) {
return;
}
@@ -3518,10 +3519,10 @@ void nsCycleCollector::CleanupAfterCollection() {
timeLog.Checkpoint("Collect::FreeSnowWhite");
TimeStamp endTime = TimeStamp::Now();
uint32_t interval = (uint32_t)((endTime - mCollectionStart).ToMilliseconds());
TimeDuration interval = endTime - mCollectionStart;
#ifdef COLLECT_TIME_DEBUG
printf("cc: total cycle collector time was %ums in %u slices\n", interval,
mResults.mNumSlices);
printf("cc: total cycle collector time was %ums in %u slices\n",
(uint32_t)interval.ToMilliseconds(), mResults.mNumSlices);
printf(
"cc: visited %u ref counted and %u GCed objects, freed %d ref counted "
"and %d GCed objects",
@@ -3535,10 +3536,23 @@ void nsCycleCollector::CleanupAfterCollection() {
printf(".\ncc: \n");
#endif
CC_TELEMETRY(, interval);
CC_TELEMETRY(_VISITED_REF_COUNTED, mResults.mVisitedRefCounted);
CC_TELEMETRY(_VISITED_GCED, mResults.mVisitedGCed);
CC_TELEMETRY(_COLLECTED, mWhiteNodeCount);
if (NS_IsMainThread()) {
glean::cycle_collector::time.AccumulateRawDuration(interval);
glean::cycle_collector::visited_ref_counted.AccumulateSingleSample(
mResults.mVisitedRefCounted);
glean::cycle_collector::visited_gced.AccumulateSingleSample(
mResults.mVisitedGCed);
glean::cycle_collector::collected.AccumulateSingleSample(mWhiteNodeCount);
} else {
glean::cycle_collector::worker_time.AccumulateRawDuration(interval);
glean::cycle_collector::worker_visited_ref_counted.AccumulateSingleSample(
mResults.mVisitedRefCounted);
glean::cycle_collector::worker_visited_gced.AccumulateSingleSample(
mResults.mVisitedGCed);
glean::cycle_collector::worker_collected.AccumulateSingleSample(
mWhiteNodeCount);
}
timeLog.Checkpoint("CleanupAfterCollection::telemetry");
PROFILER_MARKER(
+199
View File
@@ -125,3 +125,202 @@ memory_phc:
- [email protected]
expires: 142
telemetry_mirror: MEMORY_PHC_SLOTS_FREED
cycle_collector:
time:
type: timing_distribution
description: >
Time spent on one cycle collection (ms)
This metric was generated to correspond to the Legacy Telemetry
exponential histogram CYCLE_COLLECTOR.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
notification_emails:
- [email protected]
expires: never
telemetry_mirror: CYCLE_COLLECTOR
worker_time:
type: timing_distribution
description: >
Time spent on one cycle collection in a worker (ms)
This metric was generated to correspond to the Legacy Telemetry
exponential histogram CYCLE_COLLECTOR_WORKER.
time_unit: millisecond
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
notification_emails:
- [email protected]
expires: never
telemetry_mirror: CYCLE_COLLECTOR_WORKER
visited_ref_counted:
type: custom_distribution
description: >
Number of ref counted objects visited by the cycle collector
This metric was generated to correspond to the Legacy Telemetry
exponential histogram CYCLE_COLLECTOR_VISITED_REF_COUNTED.
range_min: 1
range_max: 300000
bucket_count: 50
histogram_type: exponential
unit: ref counted objects
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
notification_emails:
- [email protected]
expires: never
telemetry_mirror: CYCLE_COLLECTOR_VISITED_REF_COUNTED
worker_visited_ref_counted:
type: custom_distribution
description: >
Number of ref counted objects visited by the cycle collector in a worker
This metric was generated to correspond to the Legacy Telemetry
exponential histogram CYCLE_COLLECTOR_WORKER_VISITED_REF_COUNTED.
range_min: 1
range_max: 300000
bucket_count: 50
histogram_type: exponential
unit: ref counted objects
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
notification_emails:
- [email protected]
expires: never
telemetry_mirror: CYCLE_COLLECTOR_WORKER_VISITED_REF_COUNTED
visited_gced:
type: custom_distribution
description: >
Number of JS objects visited by the cycle collector
This metric was generated to correspond to the Legacy Telemetry
exponential histogram CYCLE_COLLECTOR_VISITED_GCED.
range_min: 1
range_max: 300000
bucket_count: 50
histogram_type: exponential
unit: JS objects
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
notification_emails:
- [email protected]
expires: never
telemetry_mirror: CYCLE_COLLECTOR_VISITED_GCED
worker_visited_gced:
type: custom_distribution
description: >
Number of JS objects visited by the cycle collector in a worker
This metric was generated to correspond to the Legacy Telemetry
exponential histogram CYCLE_COLLECTOR_WORKER_VISITED_GCED.
range_min: 1
range_max: 300000
bucket_count: 50
histogram_type: exponential
unit: JS objects
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
notification_emails:
- [email protected]
expires: never
telemetry_mirror: CYCLE_COLLECTOR_WORKER_VISITED_GCED
collected:
type: custom_distribution
description: >
Number of objects collected by the cycle collector
This metric was generated to correspond to the Legacy Telemetry
exponential histogram CYCLE_COLLECTOR_COLLECTED.
range_min: 1
range_max: 100000
bucket_count: 50
histogram_type: exponential
unit: JS objects
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
notification_emails:
- [email protected]
expires: never
telemetry_mirror: CYCLE_COLLECTOR_COLLECTED
worker_collected:
type: custom_distribution
description: >
Number of objects collected by the cycle collector in a worker
This metric was generated to correspond to the Legacy Telemetry
exponential histogram CYCLE_COLLECTOR_WORKER_COLLECTED.
range_min: 1
range_max: 100000
bucket_count: 50
histogram_type: exponential
unit: JS objects
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
notification_emails:
- [email protected]
expires: never
telemetry_mirror: CYCLE_COLLECTOR_WORKER_COLLECTED
need_gc:
type: labeled_counter
description: >
Needed garbage collection before cycle collection.
This metric was generated to correspond to the Legacy Telemetry boolean
histogram CYCLE_COLLECTOR_NEED_GC.
labels:
- "false"
- "true"
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
notification_emails:
- [email protected]
expires: never
telemetry_mirror: h#CYCLE_COLLECTOR_NEED_GC
worker_need_gc:
type: labeled_counter
description: >
Needed garbage collection before cycle collection in a worker.
This metric was generated to correspond to the Legacy Telemetry boolean
histogram CYCLE_COLLECTOR_WORKER_NEED_GC.
labels:
- "false"
- "true"
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1935420
notification_emails:
- [email protected]
expires: never
telemetry_mirror: h#CYCLE_COLLECTOR_WORKER_NEED_GC