Bug 1817965 - Add telemetry to monitor how quickly GC tasks run after being queued r=jandem

I initially tried to do this for all helper thread tasks but most of them don't
have any associated runtime to send the telemetry to and this resulted in a
much larger set of changes.

What do you think?

Differential Revision: https://phabricator.services.mozilla.com/D171597
This commit is contained in:
Jon Coppeard 2023-03-06 15:41:40 +00:00
parent cdf729cb6b
commit 8da9dfe9d8
5 changed files with 35 additions and 1 deletions

View File

@ -66,7 +66,8 @@ class JS_PUBLIC_API JSObject;
_(GC_EFFECTIVENESS, MemoryDistribution) \
_(GC_PARALLEL_MARK_SPEEDUP, Integer) \
_(GC_PARALLEL_MARK_UTILIZATION, Percentage) \
_(GC_PARALLEL_MARK_INTERRUPTIONS, Integer)
_(GC_PARALLEL_MARK_INTERRUPTIONS, Integer) \
_(GC_TASK_START_DELAY_US, TimeDuration_US)
// clang-format off
#define ENUM_DEF(NAME, _) NAME,

View File

@ -35,11 +35,22 @@ js::GCParallelTask::~GCParallelTask() {
assertIdle();
}
static bool ShouldMeasureTaskStartDelay() {
// We use many tasks during GC so randomly sample a small fraction for the
// purposes of recording telemetry.
return (rand() % 100) == 0;
}
void js::GCParallelTask::startWithLockHeld(AutoLockHelperThreadState& lock) {
MOZ_ASSERT(CanUseExtraThreads());
MOZ_ASSERT(HelperThreadState().isInitialized(lock));
assertIdle();
maybeQueueTime_ = TimeStamp();
if (ShouldMeasureTaskStartDelay()) {
maybeQueueTime_ = TimeStamp::Now();
}
setDispatched(lock);
HelperThreadState().submitTask(this, lock);
}
@ -197,6 +208,11 @@ void GCParallelTask::runTask(JS::GCContext* gcx,
TimeStamp timeStart = TimeStamp::Now();
run(lock);
duration_ = TimeSince(timeStart);
if (maybeQueueTime_) {
TimeDuration delay = timeStart - maybeQueueTime_;
gc->rt->metrics().GC_TASK_START_DELAY_US(delay);
}
}
bool js::GCParallelTask::isIdle() const {

View File

@ -114,6 +114,9 @@ class GCParallelTask : private mozilla::LinkedListElement<GCParallelTask>,
UnprotectedData<State> state_;
// May be set to the time this task was queued to collect telemetry.
mozilla::TimeStamp maybeQueueTime_;
// Amount of time this task took to execute.
MainThreadOrGCTaskData<mozilla::TimeDuration> duration_;

View File

@ -7,6 +7,8 @@
#ifndef vm_HelperThreadTask_h
#define vm_HelperThreadTask_h
#include "mozilla/TimeStamp.h"
#include "js/Utility.h"
namespace js {

View File

@ -1164,6 +1164,18 @@
"bug_numbers": [1817741],
"description": "Number of interruptions/donations per slice during parallel marking."
},
"GC_TASK_START_DELAY_US": {
"record_in_processes": ["main", "content"],
"products": ["firefox"],
"alert_emails": ["dev-telemetry-gc-alerts@mozilla.org", "jcoppeard@mozilla.com"],
"expires_in_version": "never",
"kind": "exponential",
"low": 1,
"high": 2000,
"n_buckets": 50,
"bug_numbers": [1817965],
"description": "Delay between queuing a GC task and the task starting."
},
"DESERIALIZE_BYTES": {
"record_in_processes": ["main", "content"],
"products": ["firefox"],