commit 85f3111cc20195b9bfbdb399e854b321c3dd0458
parent e4440d8be8ef99d6564abe702d79a2723ec34ff6
Author: Ryan Hunt <rhunt@eqrion.net>
Date: Thu, 18 Dec 2025 14:55:06 +0000
Bug 2002635 - Revert "Bug 1980396: Add a new probe that records 5 minutes of JS activity for documents with asm.js." r=smaug
We don't need this anymore.
This reverts commit 90af3b6a63d9035d59e2f818bdd2fdc2ab84f6fa.
Differential Revision: https://phabricator.services.mozilla.com/D275815
Diffstat:
3 files changed, 1 insertion(+), 117 deletions(-)
diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp
@@ -2058,91 +2058,6 @@ void Document::LoadEventFired() {
}
}
-static void RecordExecutionTimeForAsmJS(Document* aDoc) {
- if (aDoc->GetScopeObject()) {
- AutoJSAPI jsapi;
- if (!jsapi.Init(aDoc->GetScopeObject())) {
- return;
- }
-
- if (JSContext* cx = jsapi.cx()) {
- // Disable the execution timer.
- JS::SetMeasuringExecutionTimeEnabled(cx, false);
-
- // Get the execution time and accumulate it.
- JS::JSTimers timers = JS::GetJSTimers(cx);
- mozilla::glean::perf::js_exec_asm_js.AccumulateRawDuration(
- timers.executionTime);
- }
- }
-}
-
-class ASMJSExecutionTimeRecorder final : public nsITimerCallback,
- public nsINamed {
- public:
- NS_DECL_ISUPPORTS
- NS_DECL_NSITIMERCALLBACK
- NS_DECL_NSINAMED
-
- explicit ASMJSExecutionTimeRecorder(Document* aDocument)
- : mDocument(aDocument) {}
-
- private:
- ~ASMJSExecutionTimeRecorder() = default;
- WeakPtr<Document> mDocument;
-};
-
-NS_IMPL_ISUPPORTS(ASMJSExecutionTimeRecorder, nsITimerCallback, nsINamed)
-
-NS_IMETHODIMP
-ASMJSExecutionTimeRecorder::Notify(nsITimer* aTimer) {
- RefPtr<Document> doc(mDocument);
- if (!doc) {
- return NS_OK;
- }
-
- // Record the JS execution time to Glean.
- RecordExecutionTimeForAsmJS(doc);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-ASMJSExecutionTimeRecorder::GetName(nsACString& aName) {
- aName.AssignLiteral("ASMJSExecutionTimeRecorder");
- return NS_OK;
-}
-
-// If an asm.js use counter is set, then enable the JS execution
-// timer and record it after 5 minutes of activity.
-void Document::RecordASMJSExecutionTime() {
- // Skip if the document is being destroyed.
- if (mIsGoingAway) {
- return;
- }
-
- // If the timer has already fired, or the use counter is already set,
- // then nothing more needs to be done.
- if (mASMJSExecutionTimer || HasUseCounter(eUseCounter_custom_JS_use_asm)) {
- return;
- }
-
- AutoJSContext cx;
- if (static_cast<JSContext*>(cx)) {
- JS::SetMeasuringExecutionTimeEnabled(cx, true);
- }
-
- RefPtr<ASMJSExecutionTimeRecorder> callback =
- new ASMJSExecutionTimeRecorder(this);
- nsresult rv =
- NS_NewTimerWithCallback(getter_AddRefs(mASMJSExecutionTimer), callback,
- 5 * 60 * 1000, // 5min delay
- nsITimer::TYPE_ONE_SHOT);
-
- if (NS_FAILED(rv)) {
- mASMJSExecutionTimer = nullptr;
- }
-}
-
void Document::RecordPageLoadEventTelemetry() {
// If the page load time is empty, then the content wasn't something we want
// to report (i.e. not a top level document).
@@ -12326,11 +12241,6 @@ void Document::Destroy() {
mIsGoingAway = true;
- if (mASMJSExecutionTimer) {
- mASMJSExecutionTimer->Cancel();
- mASMJSExecutionTimer = nullptr;
- RecordExecutionTimeForAsmJS(this);
- }
if (mScriptLoader) {
mScriptLoader->Destroy();
}
@@ -20822,9 +20732,7 @@ void Document::RemoveToplevelLoadingDocument(Document* aDoc) {
}
// Stop the JS execution timer once the page is loaded.
- // If the asm.js counter is active, then continue the timer
- // for telemetry purposes.
- if (!aDoc->HasUseCounter(eUseCounter_custom_JS_use_asm)) {
+ {
AutoJSContext cx;
if (static_cast<JSContext*>(cx)) {
JS::SetMeasuringExecutionTimeEnabled(cx, false);
diff --git a/dom/base/Document.h b/dom/base/Document.h
@@ -3858,12 +3858,7 @@ class Document : public nsINode,
// call it just before the document loses its window.
void SendPageUseCounters();
- void RecordASMJSExecutionTime();
-
void SetUseCounter(UseCounter aUseCounter) {
- if (aUseCounter == eUseCounter_custom_JS_use_asm) {
- RecordASMJSExecutionTime();
- }
mUseCounters[aUseCounter] = true;
}
@@ -5349,9 +5344,6 @@ class Document : public nsINode,
// This only applies to error pages. Might be null.
nsCOMPtr<nsIChannel> mFailedChannel;
- // Timer for delayed ASMJS execution time recording
- nsCOMPtr<nsITimer> mASMJSExecutionTimer;
-
// if this document is part of a multipart document,
// the ID can be used to distinguish it from the other parts.
uint32_t mPartID;
diff --git a/dom/metrics.yaml b/dom/metrics.yaml
@@ -238,22 +238,6 @@ perf:
send_in_pings:
- pageload-base-domain
- js_exec_asm_js:
- type: timing_distribution
- description: >
- Time in milliseconds spent executing Javascript for top level
- documents that contain the asm.js use counter. Measures 5min
- of activity after the use counter is set then records
- the value in this histogram.
- time_unit: millisecond
- bugs:
- - https://bugzilla.mozilla.org/show_bug.cgi?id=1980396
- data_reviews:
- - https://phabricator.services.mozilla.com/D259436
- notification_emails:
- - perf-telemetry-alerts@mozilla.com
- expires: never
-
h3p_page_load_time:
type: labeled_timing_distribution
description: >