Bug 1814718 - Added telemetry for number of timers fired per Timer Thread wake-up. r=smaug,florian

Differential Revision: https://phabricator.services.mozilla.com/D168915
This commit is contained in:
Justin Link 2023-02-15 10:07:44 +00:00
parent aaea911dc4
commit 82f9e26e63
3 changed files with 39 additions and 0 deletions

View File

@ -26,6 +26,7 @@ gecko_metrics = [
"toolkit/components/glean/metrics.yaml",
"toolkit/components/pdfjs/metrics.yaml",
"toolkit/components/processtools/metrics.yaml",
"xpcom/metrics.yaml",
]
# Metrics that are sent by Firefox Desktop

30
xpcom/metrics.yaml Normal file
View File

@ -0,0 +1,30 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Adding a new metric? We have docs for that!
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html
---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
$tags:
- "Core :: XPCOM"
timer_thread:
timers_fired_per_wakeup:
type: custom_distribution
description: >
How many timers were processed in a single wake-up of the Timer Thread.
range_min: 0
range_max: 80
bucket_count: 20
histogram_type: exponential
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1814718
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1814718
data_sensitivity:
- technical
notification_emails:
- jlink@mozilla.com
expires: never

View File

@ -20,6 +20,8 @@
#include "mozilla/OperatorNewExtensions.h"
#include "mozilla/StaticPrefs_timer.h"
#include "mozilla/glean/GleanMetrics.h"
#include <math.h>
using namespace mozilla;
@ -539,6 +541,7 @@ TimerThread::Run() {
mAllowedEarlyFiringMicroseconds = usIntervalResolution / 2;
bool forceRunNextTimer = false;
uint64_t timersFiredThisWakeup = 0;
while (!mShutdown) {
// Have to use PRIntervalTime here, since PR_WaitCondVar takes it
TimeDuration waitFor;
@ -581,6 +584,7 @@ TimerThread::Run() {
// release of the timer so that we don't end up releasing the timer
// on the TimerThread instead of on the thread it targets.
{
++timersFiredThisWakeup;
LogTimerEvent::Run run(timerRef.get());
PostTimerEvent(timerRef.forget());
}
@ -643,6 +647,10 @@ TimerThread::Run() {
mWaiting = true;
mNotified = false;
{
// About to sleep - let's make note of how many timers we processed.
glean::timer_thread::timers_fired_per_wakeup.AccumulateSamples(
{timersFiredThisWakeup});
timersFiredThisWakeup = 0;
AUTO_PROFILER_TRACING_MARKER("TimerThread", "Wait", OTHER);
mMonitor.Wait(waitFor);
}