Bug 1914578 - Remove EventTracer r=perftest-reviewers,geckoview-reviewers,win-reviewers,profiler-reviewers,mstange,sparky,gstoll,owlish

Differential Revision: https://phabricator.services.mozilla.com/D219955
This commit is contained in:
Gregory Pappas 2024-08-31 03:39:50 +00:00
Родитель 81d8385ecc
Коммит cf796e320f
31 изменённых файлов: 2 добавлений и 799 удалений

Просмотреть файл

@ -9305,7 +9305,6 @@ For the sample commands found below, note that the capitalization used is import
* mac_counters: []
* mainthread: False
* multidomain: True
* responsiveness: True
* timeout: 1800
* tpcycles: 1
* tpmanifest: ${talos}/fis/tp5n/tp5o.manifest
@ -10000,7 +9999,6 @@ For the sample commands found below, note that the capitalization used is import
* cycles: 20
* gecko_profile_startup: True
* mainthread: False
* responsiveness: False
* timeout: 150
* tpmozafterpaint: True
* unit: ms
@ -11202,28 +11200,6 @@ every 20 seconds. This metric is collected on linux only.
Cpu usage tracked during tp5 test runs. This metric is sampled every 20
seconds. This metric is collected on windows only.
Responsiveness
--------------
contact: :jimm, :overholt
Measures the delay for the event loop to process a `tracer
event <https://wiki.mozilla.org/Performance/Snappy#Current_Infrastructure>`__.
For more details, see `bug
631571 <https://bugzilla.mozilla.org/show_bug.cgi?id=631571>`__.
The score on this benchmark is proportional to the sum of squares of all
event delays that exceed a 20ms threshold. Lower is better.
We collect 8000+ data points from the browser during the test and apply
`this
formula <https://dxr.mozilla.org/mozilla-central/source/testing/talos/talos/output.py#l95>`__
to the results:
.. code-block:: python
return sum([float(x)*float(x) / 1000000.0 for x in val_list])
tpaint
======

Просмотреть файл

@ -267,9 +267,3 @@ def v8_subtest(series, name):
# pylint --py3k W1619
return reference[name] / geometric_mean(series)
@register_filter
@define_filter
def responsiveness_Metric(val_list):
return sum([float(x) * float(x) / 1000000.0 for x in val_list])

Просмотреть файл

@ -410,28 +410,6 @@ every 20 seconds. This metric is collected on linux only.
Cpu usage tracked during tp5 test runs. This metric is sampled every 20
seconds. This metric is collected on windows only.
Responsiveness
--------------
contact: :jimm, :overholt
Measures the delay for the event loop to process a `tracer
event <https://wiki.mozilla.org/Performance/Snappy#Current_Infrastructure>`__.
For more details, see `bug
631571 <https://bugzilla.mozilla.org/show_bug.cgi?id=631571>`__.
The score on this benchmark is proportional to the sum of squares of all
event delays that exceed a 20ms threshold. Lower is better.
We collect 8000+ data points from the browser during the test and apply
`this
formula <https://dxr.mozilla.org/mozilla-central/source/testing/talos/talos/output.py#l95>`__
to the results:
.. code-block:: python
return sum([float(x)*float(x) / 1000000.0 for x in val_list])
tpaint
======

Просмотреть файл

@ -29,7 +29,6 @@ DEFAULTS = dict(
basetest=dict(
cycles=1,
profile_path="${talos}/base_profile",
responsiveness=False,
gecko_profile=False,
gecko_profile_interval=1,
gecko_profile_entries=100000,

Просмотреть файл

@ -256,9 +256,3 @@ def v8_subtest(series, name):
# pylint --py3k W1619
return reference[name] / geometric_mean(series)
@register_filter
@define_filter
def responsiveness_Metric(val_list):
return sum([float(x) * float(x) / 1000000.0 for x in val_list])

Просмотреть файл

@ -160,16 +160,6 @@ class Output(object):
if "mainthreadio" in name:
continue
# responsiveness has it's own metric, not the mean
# TODO: consider doing this for all counters
if "responsiveness" == name:
subtest = {
"name": name,
"value": filter.responsiveness_Metric(vals),
}
counter_subtests.append(subtest)
continue
subtest = {
"name": name,
"value": 0.0,
@ -333,9 +323,7 @@ class Output(object):
return 100
def construct_results(self, vals, testname):
if "responsiveness" in testname:
return filter.responsiveness_Metric([val for (val, page) in vals])
elif testname.startswith("v8_7"):
if testname.startswith("v8_7"):
return self.v8_Metric(vals)
elif testname.startswith("kraken"):
return self.JS_Metric(vals)

Просмотреть файл

@ -309,11 +309,6 @@ class BrowserLogResults(object):
# regular expression for failure case if we can't parse the tokens
RESULTS_REGEX_FAIL = re.compile("__FAIL(.*?)__FAIL", re.DOTALL | re.MULTILINE)
# regular expression for responsiveness results
RESULTS_RESPONSIVENESS_REGEX = re.compile(
r"MOZ_EVENT_TRACE\ssample\s\d*?\s(\d*\.?\d*)$", re.DOTALL | re.MULTILINE
)
# classes for results types
classes = {"tsformat": TsResults, "tpformat": PageloaderResults}
@ -430,8 +425,6 @@ class BrowserLogResults(object):
"""accumulate all counters"""
if global_counters is not None:
if "responsiveness" in global_counters:
global_counters["responsiveness"].extend(self.responsiveness())
self.xperf(global_counters)
def xperf(self, counter_results):
@ -551,6 +544,3 @@ class BrowserLogResults(object):
except Exception:
# silent failure is fine here as we will only see this on tp5n runs
pass
def responsiveness(self):
return self.RESULTS_RESPONSIVENESS_REGEX.findall(self.results_raw)

Просмотреть файл

@ -177,7 +177,6 @@ class ts_paint(TsBase):
filters = filter.ignore_first.prepare(1) + filter.median.prepare()
tpmozafterpaint = True
mainthread = False
responsiveness = False
unit = "ms"
@ -350,7 +349,6 @@ class PageloaderTest(Test):
"tpscrolltest",
"xperf_counters",
"timeout",
"responsiveness",
"profile_path",
"xperf_providers",
"xperf_user_providers",
@ -1059,7 +1057,6 @@ class tp5o(PageloaderTest):
win_counters = ["% Processor Time"]
linux_counters = ["XRes"]
mac_counters = []
responsiveness = True
gecko_profile_interval = 2
filters = filter.ignore_first.prepare(5) + filter.median.prepare()
timeout = 1800

Просмотреть файл

@ -99,13 +99,6 @@ class TTest(object):
for c in test_config.get("xperf_counters", []):
global_counters[c] = []
if test_config.get("responsiveness") and platform.system() != "Darwin":
# ignore osx for now as per bug 1245793
setup.env["MOZ_INSTRUMENT_EVENT_LOOP"] = "1"
setup.env["MOZ_INSTRUMENT_EVENT_LOOP_THRESHOLD"] = "20"
setup.env["MOZ_INSTRUMENT_EVENT_LOOP_INTERVAL"] = "10"
global_counters["responsiveness"] = []
setup.env["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "1"
# instantiate an object to hold test results

Просмотреть файл

@ -50,7 +50,6 @@ class mock_test(PageloaderTest):
"xperf_counters",
"timeout",
"shutdown",
"responsiveness",
"profile_path",
"xperf_providers",
"xperf_user_providers",
@ -364,7 +363,6 @@ class Test_get_config(object):
assert test_config["filters"] is not None
assert test_config["tpmozafterpaint"] is True
# assert test_config['mainthread'] is False
# assert test_config['responsiveness'] is False
# assert test_config['unit'] == 'ms'
def test_ts_paint_webext_has_expected_attributes(self):
@ -385,7 +383,6 @@ class Test_get_config(object):
assert test_config["filters"] is not None
assert test_config["tpmozafterpaint"] is True
# assert test_config['mainthread'] is False
# assert test_config['responsiveness'] is False
# assert test_config['unit'] == 'ms'
# TODO: this isn't overriden
# assert test_config['webextensions'] != '${talos}/webextensions/dummy/dummy-signed.xpi'
@ -409,7 +406,6 @@ class Test_get_config(object):
assert test_config["filters"] is not None
assert test_config["tpmozafterpaint"] is True
# assert test_config['mainthread'] is False
# assert test_config['responsiveness'] is False
# assert test_config['unit'] == 'ms'
assert test_config["profile"] == "simple"
@ -984,7 +980,6 @@ class Test_get_config(object):
assert test_config["win_counters"] == ["% Processor Time"]
assert test_config["linux_counters"] == ["XRes"]
assert test_config["mac_counters"] == []
assert test_config["responsiveness"] is True
assert test_config["gecko_profile_interval"] == 2
assert test_config["gecko_profile_entries"] == 4000000
assert test_config["filters"] is not None
@ -1007,7 +1002,6 @@ class Test_get_config(object):
assert test_config["win_counters"] == ["% Processor Time"]
assert test_config["linux_counters"] == ["XRes"]
assert test_config["mac_counters"] == []
assert test_config["responsiveness"] is True
assert test_config["gecko_profile_interval"] == 2
assert test_config["gecko_profile_entries"] == 4000000
assert test_config["filters"] is not None

Просмотреть файл

@ -1 +1 @@
{'remote_counters': [], 'filters': [['ignore_first', [5]], ['median', []]], 'xperf_user_providers': ['Mozilla Generic Provider', 'Microsoft-Windows-TCPIP'], 'tpcycles': 1, 'browser_log': 'browser_output.txt', 'shutdown': False, 'fennecIDs': False, 'responsiveness': False, 'tpmozafterpaint': True, 'cleanup': 'pathtofile', 'tprender': False, 'xperf_counters': ['main_startup_fileio', 'main_startup_netio', 'main_normal_fileio', 'main_normal_netio', 'nonmain_startup_fileio', 'nonmain_normal_fileio', 'nonmain_normal_netio', 'mainthread_readcount', 'mainthread_readbytes', 'mainthread_writecount', 'mainthread_writebytes'], 'mac_counters': [], 'tpnoisy': True, 'tppagecycles': 1, 'tploadaboutblank': False, 'xperf_providers': ['PROC_THREAD', 'LOADER', 'HARD_FAULTS', 'FILENAME', 'FILE_IO', 'FILE_IO_INIT'], 'rss': True, 'profile_path': 'path', 'name': 'tp5n', 'url': '-tp pathtotp5n.manifest -tpchrome -tpmozafterpaint -tpnoisy -rss -tpcycles 1 -tppagecycles 1', 'setup': 'pathtosetup', 'linux_counters': [], 'tpmanifest': 'pathtotp5n.manifest', 'w7_counters': [], 'timeout': 1800, 'xperf_stackwalk': ['FileCreate', 'FileRead', 'FileWrite', 'FileFlush', 'FileClose'], 'win_counters': [], 'cycles': 1, 'resolution': 20, 'tpchrome': True}
{'remote_counters': [], 'filters': [['ignore_first', [5]], ['median', []]], 'xperf_user_providers': ['Mozilla Generic Provider', 'Microsoft-Windows-TCPIP'], 'tpcycles': 1, 'browser_log': 'browser_output.txt', 'shutdown': False, 'fennecIDs': False, 'tpmozafterpaint': True, 'cleanup': 'pathtofile', 'tprender': False, 'xperf_counters': ['main_startup_fileio', 'main_startup_netio', 'main_normal_fileio', 'main_normal_netio', 'nonmain_startup_fileio', 'nonmain_normal_fileio', 'nonmain_normal_netio', 'mainthread_readcount', 'mainthread_readbytes', 'mainthread_writecount', 'mainthread_writebytes'], 'mac_counters': [], 'tpnoisy': True, 'tppagecycles': 1, 'tploadaboutblank': False, 'xperf_providers': ['PROC_THREAD', 'LOADER', 'HARD_FAULTS', 'FILENAME', 'FILE_IO', 'FILE_IO_INIT'], 'rss': True, 'profile_path': 'path', 'name': 'tp5n', 'url': '-tp pathtotp5n.manifest -tpchrome -tpmozafterpaint -tpnoisy -rss -tpcycles 1 -tppagecycles 1', 'setup': 'pathtosetup', 'linux_counters': [], 'tpmanifest': 'pathtotp5n.manifest', 'w7_counters': [], 'timeout': 1800, 'xperf_stackwalk': ['FileCreate', 'FileRead', 'FileWrite', 'FileFlush', 'FileClose'], 'win_counters': [], 'cycles': 1, 'resolution': 20, 'tpchrome': True}

Просмотреть файл

@ -742,24 +742,6 @@ def pdf_printing(toolkit):
set_config("MOZ_PDF_PRINTING", pdf_printing)
set_define("MOZ_PDF_PRINTING", pdf_printing)
# Event loop instrumentation
# ==============================================================
option(env="MOZ_INSTRUMENT_EVENT_LOOP", help="Force-enable event loop instrumentation")
@depends("MOZ_INSTRUMENT_EVENT_LOOP", toolkit)
def instrument_event_loop(value, toolkit):
if value or (
toolkit in ("windows", "gtk", "cocoa", "android") and value.origin == "default"
):
return True
set_config("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
set_define("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
# Fontconfig Freetype
# ==============================================================
option(env="USE_FC_FREETYPE", help="Force-enable the use of fontconfig freetype")

Просмотреть файл

@ -1,219 +0,0 @@
/* 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/. */
/*
* Event loop instrumentation. This code attempts to measure the
* latency of the UI-thread event loop by firing native events at it from
* a background thread, and measuring how long it takes for them
* to be serviced. The measurement interval (kMeasureInterval, below)
* is also used as the upper bound of acceptable response time.
* When an event takes longer than that interval to be serviced,
* a sample will be written to the log.
*
* Usage:
*
* Set MOZ_INSTRUMENT_EVENT_LOOP=1 in the environment to enable
* this instrumentation. Currently only the UI process is instrumented.
*
* Set MOZ_INSTRUMENT_EVENT_LOOP_OUTPUT in the environment to a
* file path to contain the log output, the default is to log to stdout.
*
* Set MOZ_INSTRUMENT_EVENT_LOOP_THRESHOLD in the environment to an
* integer number of milliseconds to change the threshold for reporting.
* The default is 20 milliseconds. Unresponsive periods shorter than this
* threshold will not be reported.
*
* Set MOZ_INSTRUMENT_EVENT_LOOP_INTERVAL in the environment to an
* integer number of milliseconds to change the maximum sampling frequency.
* This variable controls how often events will be sent to the main
* thread's event loop to sample responsiveness. The sampler will not
* send events twice within LOOP_INTERVAL milliseconds.
* The default is 10 milliseconds.
*
* All logged output lines start with MOZ_EVENT_TRACE. All timestamps
* output are milliseconds since the epoch (PRTime / 1000).
*
* On startup, a line of the form:
* MOZ_EVENT_TRACE start <timestamp>
* will be output.
*
* On shutdown, a line of the form:
* MOZ_EVENT_TRACE stop <timestamp>
* will be output.
*
* When an event servicing time exceeds the threshold, a line of the form:
* MOZ_EVENT_TRACE sample <timestamp> <duration>
* will be output, where <duration> is the number of milliseconds that
* it took for the event to be serviced. Duration may contain a fractional
* component.
*/
#include "GeckoProfiler.h"
#include "EventTracer.h"
#include <stdio.h>
#include "mozilla/Preferences.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/WidgetTraceEvent.h"
#include "nsDebug.h"
#include <limits.h>
#include <prenv.h>
#include <prinrval.h>
#include <prthread.h>
#include <prtime.h>
#include "nsThreadUtils.h"
using mozilla::FireAndWaitForTracerEvent;
using mozilla::TimeDuration;
using mozilla::TimeStamp;
namespace {
PRThread* sTracerThread = nullptr;
bool sExit = false;
struct TracerStartClosure {
bool mLogTracing;
int32_t mThresholdInterval;
};
/*
* The tracer thread fires events at the native event loop roughly
* every kMeasureInterval. It will sleep to attempt not to send them
* more quickly, but if the response time is longer than kMeasureInterval
* it will not send another event until the previous response is received.
*
* The output defaults to stdout, but can be redirected to a file by
* settting the environment variable MOZ_INSTRUMENT_EVENT_LOOP_OUTPUT
* to the name of a file to use.
*/
void TracerThread(void* arg) {
AUTO_PROFILER_REGISTER_THREAD("Event Tracer");
NS_SetCurrentThreadName("Event Tracer");
TracerStartClosure* threadArgs = static_cast<TracerStartClosure*>(arg);
// These are the defaults. They can be overridden by environment vars.
// This should be set to the maximum latency we'd like to allow
// for responsiveness.
int32_t thresholdInterval = threadArgs->mThresholdInterval;
PRIntervalTime threshold = PR_MillisecondsToInterval(thresholdInterval);
// This is the sampling interval.
PRIntervalTime interval = PR_MillisecondsToInterval(thresholdInterval / 2);
sExit = false;
FILE* log = nullptr;
char* envfile = PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP_OUTPUT");
if (envfile) {
log = fopen(envfile, "w");
}
if (log == nullptr) log = stdout;
char* thresholdenv = PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP_THRESHOLD");
if (thresholdenv && *thresholdenv) {
int val = atoi(thresholdenv);
if (val != 0 && val != INT_MAX && val != INT_MIN) {
threshold = PR_MillisecondsToInterval(val);
}
}
char* intervalenv = PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP_INTERVAL");
if (intervalenv && *intervalenv) {
int val = atoi(intervalenv);
if (val != 0 && val != INT_MAX && val != INT_MIN) {
interval = PR_MillisecondsToInterval(val);
}
}
if (threadArgs->mLogTracing) {
long long now = PR_Now() / PR_USEC_PER_MSEC;
fprintf(log, "MOZ_EVENT_TRACE start %llu\n", now);
}
while (!sExit) {
TimeStamp start(TimeStamp::Now());
PRIntervalTime next_sleep = interval;
// TODO: only wait up to a maximum of interval; return
// early if that threshold is exceeded and dump a stack trace
// or do something else useful.
if (FireAndWaitForTracerEvent()) {
TimeDuration duration = TimeStamp::Now() - start;
// Only report samples that exceed our measurement threshold.
long long now = PR_Now() / PR_USEC_PER_MSEC;
if (threadArgs->mLogTracing && duration.ToMilliseconds() > threshold) {
fprintf(log, "MOZ_EVENT_TRACE sample %llu %lf\n", now,
duration.ToMilliseconds());
}
if (next_sleep > duration.ToMilliseconds()) {
next_sleep -= int(duration.ToMilliseconds());
} else {
// Don't sleep at all if this event took longer than the measure
// interval to deliver.
next_sleep = 0;
}
}
if (next_sleep != 0 && !sExit) {
PR_Sleep(next_sleep);
}
}
if (threadArgs->mLogTracing) {
long long now = PR_Now() / PR_USEC_PER_MSEC;
fprintf(log, "MOZ_EVENT_TRACE stop %llu\n", now);
}
if (log != stdout) fclose(log);
delete threadArgs;
}
} // namespace
namespace mozilla {
bool InitEventTracing(bool aLog) {
if (sTracerThread) return true;
// Initialize the widget backend.
if (!InitWidgetTracing()) return false;
// The tracer thread owns the object and will delete it.
TracerStartClosure* args = new TracerStartClosure();
args->mLogTracing = aLog;
// Pass the default threshold interval.
int32_t thresholdInterval = 20;
Preferences::GetInt("devtools.eventlooplag.threshold", &thresholdInterval);
args->mThresholdInterval = thresholdInterval;
// Create a thread that will fire events back at the
// main thread to measure responsiveness.
MOZ_ASSERT(!sTracerThread, "Event tracing already initialized!");
sTracerThread =
PR_CreateThread(PR_USER_THREAD, TracerThread, args, PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
return sTracerThread != nullptr;
}
void ShutdownEventTracing() {
if (!sTracerThread) return;
sExit = true;
// Ensure that the tracer thread doesn't hang.
SignalTracerThread();
if (sTracerThread) PR_JoinThread(sTracerThread);
sTracerThread = nullptr;
// Allow the widget backend to clean up.
CleanUpWidgetTracing();
}
} // namespace mozilla

Просмотреть файл

@ -1,23 +0,0 @@
/* 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/. */
#ifndef XRE_EVENTTRACER_H_
#define XRE_EVENTTRACER_H_
namespace mozilla {
// Create a thread that will fire events back at the
// main thread to measure responsiveness. Return true
// if the thread was created successfully.
// aLog If the tracing results should be printed to
// the console.
bool InitEventTracing(bool aLog);
// Signal the background thread to stop, and join it.
// Must be called from the same thread that called InitEventTracing.
void ShutdownEventTracing();
} // namespace mozilla
#endif /* XRE_EVENTTRACER_H_ */

Просмотреть файл

@ -42,9 +42,6 @@ EXPORTS.mozilla += [
"SafeMode.h",
]
if CONFIG["MOZ_INSTRUMENT_EVENT_LOOP"]:
EXPORTS += ["EventTracer.h"]
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
EXPORTS.mozilla += [
"AssembleCmdLine.h",
@ -157,11 +154,6 @@ SOURCES += [
"ProfileReset.cpp",
]
if CONFIG["MOZ_INSTRUMENT_EVENT_LOOP"]:
UNIFIED_SOURCES += [
"EventTracer.cpp",
]
if CONFIG["MOZ_UPDATER"]:
if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android":
UNIFIED_SOURCES += [

Просмотреть файл

@ -51,10 +51,6 @@
#endif
#include "ProfileReset.h"
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
# include "EventTracer.h"
#endif
#ifdef XP_MACOSX
# include "nsVersionComparator.h"
# include "MacLaunchHelper.h"
@ -5749,13 +5745,6 @@ nsresult XREMain::XRE_mainRun() {
mNativeApp->Enable();
}
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
if (PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP")) {
bool logToConsole = true;
mozilla::InitEventTracing(logToConsole);
}
#endif /* MOZ_INSTRUMENT_EVENT_LOOP */
// Send Telemetry about Gecko version and buildid
mozilla::glean::gecko::version.Set(nsDependentCString(gAppData->version));
mozilla::glean::gecko::build_id.Set(nsDependentCString(gAppData->buildID));
@ -6062,10 +6051,6 @@ int XREMain::XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig) {
XRE_CleanupX11ErrorHandler();
#endif
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
mozilla::ShutdownEventTracing();
#endif
gAbsoluteArgv0Path.Truncate();
#if defined(MOZ_HAS_REMOTE)

Просмотреть файл

@ -1,27 +0,0 @@
/* 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/. */
#ifndef WIDGET_PUBLIC_WIDGETTRACEEVENT_H_
#define WIDGET_PUBLIC_WIDGETTRACEEVENT_H_
namespace mozilla {
// Perform any required initialization in the widget backend for
// event tracing. Return true if initialization was successful.
bool InitWidgetTracing();
// Perform any required cleanup in the widget backend for event tracing.
void CleanUpWidgetTracing();
// Fire a tracer event at the UI-thread event loop, and block until
// the event is processed. This should only be called by
// a thread that's not the UI thread.
bool FireAndWaitForTracerEvent();
// Signal that the event has been received by the event loop.
void SignalTracerThread();
} // namespace mozilla
#endif // WIDGET_PUBLIC_WIDGETTRACEEVENT_H_

Просмотреть файл

@ -229,71 +229,6 @@ void AndroidBridge::GetIconForExtension(const nsACString& aFileExt,
env->ReleaseByteArrayElements(arr.Get(), elements, 0);
}
namespace mozilla {
class TracerRunnable : public Runnable {
public:
TracerRunnable() : Runnable("TracerRunnable") {
mTracerLock = new Mutex("TracerRunnable");
mTracerCondVar = new CondVar(*mTracerLock, "TracerRunnable");
mMainThread = do_GetMainThread();
}
~TracerRunnable() {
delete mTracerCondVar;
delete mTracerLock;
mTracerLock = nullptr;
mTracerCondVar = nullptr;
}
virtual nsresult Run() {
MutexAutoLock lock(*mTracerLock);
if (!AndroidBridge::Bridge()) return NS_OK;
mHasRun = true;
mTracerCondVar->Notify();
return NS_OK;
}
bool Fire() {
if (!mTracerLock || !mTracerCondVar) return false;
MutexAutoLock lock(*mTracerLock);
mHasRun = false;
mMainThread->Dispatch(this, NS_DISPATCH_NORMAL);
while (!mHasRun) mTracerCondVar->Wait();
return true;
}
void Signal() {
MutexAutoLock lock(*mTracerLock);
mHasRun = true;
mTracerCondVar->Notify();
}
private:
Mutex* mTracerLock;
CondVar* mTracerCondVar;
bool mHasRun;
nsCOMPtr<nsIThread> mMainThread;
};
StaticRefPtr<TracerRunnable> sTracerRunnable;
bool InitWidgetTracing() {
if (!sTracerRunnable) sTracerRunnable = new TracerRunnable();
return true;
}
void CleanUpWidgetTracing() { sTracerRunnable = nullptr; }
bool FireAndWaitForTracerEvent() {
if (sTracerRunnable) return sTracerRunnable->Fire();
return false;
}
void SignalTracerThread() {
if (sTracerRunnable) return sTracerRunnable->Signal();
}
} // namespace mozilla
void AndroidBridge::GetCurrentBatteryInformation(
hal::BatteryInformation* aBatteryInfo) {
ALOG_BRIDGE("AndroidBridge::GetCurrentBatteryInformation");

Просмотреть файл

@ -12,7 +12,5 @@
// Empty event, just used for prodding the event loop into responding.
const short kEventSubtypeNone = 0;
// Tracer event, used for timing the event loop responsiveness.
const short kEventSubtypeTrace = 1;
#endif /* WIDGET_COCOA_CUSTOMCOCOAEVENTS_H_ */

Просмотреть файл

@ -1,79 +0,0 @@
/* 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/. */
#include <Cocoa/Cocoa.h>
#include "CustomCocoaEvents.h"
#include <Foundation/NSAutoreleasePool.h>
#include <mozilla/CondVar.h>
#include <mozilla/Mutex.h>
#include "mozilla/WidgetTraceEvent.h"
using mozilla::CondVar;
using mozilla::Mutex;
using mozilla::MutexAutoLock;
namespace {
Mutex* sMutex = NULL;
CondVar* sCondVar = NULL;
bool sTracerProcessed = false;
} // namespace
namespace mozilla {
bool InitWidgetTracing() {
sMutex = new Mutex("Event tracer thread mutex");
sCondVar = new CondVar(*sMutex, "Event tracer thread condvar");
return sMutex && sCondVar;
}
void CleanUpWidgetTracing() {
delete sMutex;
delete sCondVar;
sMutex = NULL;
sCondVar = NULL;
}
// This function is called from the main (UI) thread.
void SignalTracerThread() {
if (!sMutex || !sCondVar) return;
MutexAutoLock lock(*sMutex);
if (!sTracerProcessed) {
sTracerProcessed = true;
sCondVar->Notify();
}
}
// This function is called from the background tracer thread.
bool FireAndWaitForTracerEvent() {
MOZ_ASSERT(sMutex && sCondVar, "Tracing not initialized!");
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
MutexAutoLock lock(*sMutex);
if (sTracerProcessed) {
// Things are out of sync. This is likely because we're in
// the middle of shutting down. Just return false and hope the
// tracer thread is quitting anyway.
return false;
}
// Post an application-defined event to the main thread's event queue
// and wait for it to get processed.
[NSApp postEvent:[NSEvent otherEventWithType:NSEventTypeApplicationDefined
location:NSMakePoint(0, 0)
modifierFlags:0
timestamp:0
windowNumber:0
context:NULL
subtype:kEventSubtypeTrace
data1:0
data2:0]
atStart:NO];
while (!sTracerProcessed) sCondVar->Wait();
sTracerProcessed = false;
[pool release];
return true;
}
} // namespace mozilla

Просмотреть файл

@ -71,7 +71,6 @@ UNIFIED_SOURCES += [
"TextRecognition.mm",
"VibrancyManager.mm",
"ViewRegion.mm",
"WidgetTraceEvent.mm",
]
# These files cannot be built in unified mode because they cause symbol conflicts

Просмотреть файл

@ -15,7 +15,6 @@
#include "mozilla/AvailableMemoryWatcher.h"
#include "CustomCocoaEvents.h"
#include "mozilla/WidgetTraceEvent.h"
#include "nsAppShell.h"
#include "gfxPlatform.h"
#include "nsCOMPtr.h"
@ -176,12 +175,6 @@ void OnUncaughtException(NSException* aException) {
- (void)sendEvent:(NSEvent*)anEvent {
mozilla::BackgroundHangMonitor().NotifyActivity();
if ([anEvent type] == NSEventTypeApplicationDefined &&
[anEvent subtype] == kEventSubtypeTrace) {
mozilla::SignalTracerThread();
return;
}
[super sendEvent:anEvent];
}

Просмотреть файл

@ -1,68 +0,0 @@
/* 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/. */
#include "mozilla/WidgetTraceEvent.h"
#include <glib.h>
#include <mozilla/CondVar.h>
#include <mozilla/Mutex.h>
#include <stdio.h>
using mozilla::CondVar;
using mozilla::Mutex;
using mozilla::MutexAutoLock;
namespace {
Mutex* sMutex = nullptr;
CondVar* sCondVar = nullptr;
bool sTracerProcessed = false;
// This function is called from the main (UI) thread.
gboolean TracerCallback(gpointer data) {
mozilla::SignalTracerThread();
return FALSE;
}
} // namespace
namespace mozilla {
bool InitWidgetTracing() {
sMutex = new Mutex("Event tracer thread mutex");
sCondVar = new CondVar(*sMutex, "Event tracer thread condvar");
return true;
}
void CleanUpWidgetTracing() {
delete sMutex;
delete sCondVar;
sMutex = nullptr;
sCondVar = nullptr;
}
// This function is called from the background tracer thread.
bool FireAndWaitForTracerEvent() {
MOZ_ASSERT(sMutex && sCondVar, "Tracing not initialized!");
// Send a default-priority idle event through the
// event loop, and wait for it to finish.
MutexAutoLock lock(*sMutex);
MOZ_ASSERT(!sTracerProcessed, "Tracer synchronization state is wrong");
g_idle_add_full(G_PRIORITY_DEFAULT, TracerCallback, nullptr, nullptr);
while (!sTracerProcessed) sCondVar->Wait();
sTracerProcessed = false;
return true;
}
void SignalTracerThread() {
if (!sMutex || !sCondVar) return;
MutexAutoLock lock(*sMutex);
if (!sTracerProcessed) {
sTracerProcessed = true;
sCondVar->Notify();
}
}
} // namespace mozilla

Просмотреть файл

@ -95,7 +95,6 @@ UNIFIED_SOURCES += [
"TaskbarProgress.cpp",
"WakeLockListener.cpp",
"WidgetStyleCache.cpp",
"WidgetTraceEvent.cpp",
"WidgetUtilsGtk.cpp",
"WindowSurfaceProvider.cpp",
]

Просмотреть файл

@ -310,11 +310,6 @@ SOURCES += [
"ScreenManager.cpp",
]
if CONFIG["MOZ_INSTRUMENT_EVENT_LOOP"]:
EXPORTS.mozilla += [
"WidgetTraceEvent.h",
]
EXPORTS.ipc = [
"nsGUIEventIPC.h",
]

Просмотреть файл

@ -1,121 +0,0 @@
/* 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/. */
/*
* Windows widget support for event loop instrumentation.
* See toolkit/xre/EventTracer.cpp for more details.
*/
#include <stdio.h>
#include <windows.h>
#include "mozilla/RefPtr.h"
#include "mozilla/WidgetTraceEvent.h"
#include "nsAppShellCID.h"
#include "nsComponentManagerUtils.h"
#include "nsCOMPtr.h"
#include "nsIAppShellService.h"
#include "nsIBaseWindow.h"
#include "nsIDocShell.h"
#include "nsISupportsImpl.h"
#include "nsIWidget.h"
#include "nsIAppWindow.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "nsWindowDefs.h"
namespace {
// Used for signaling the background thread from the main thread.
HANDLE sEventHandle = nullptr;
// We need a runnable in order to find the hidden window on the main
// thread.
class HWNDGetter : public mozilla::Runnable {
public:
HWNDGetter() : Runnable("HWNDGetter"), hidden_window_hwnd(nullptr) {}
HWND hidden_window_hwnd;
NS_IMETHOD Run() override {
// Jump through some hoops to locate the hidden window.
nsCOMPtr<nsIAppShellService> appShell(
do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
nsCOMPtr<nsIAppWindow> hiddenWindow;
nsresult rv = appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIDocShell> docShell;
rv = hiddenWindow->GetDocShell(getter_AddRefs(docShell));
if (NS_FAILED(rv) || !docShell) {
return rv;
}
nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(docShell));
if (!baseWindow) return NS_ERROR_FAILURE;
nsCOMPtr<nsIWidget> widget;
baseWindow->GetMainWidget(getter_AddRefs(widget));
if (!widget) return NS_ERROR_FAILURE;
hidden_window_hwnd = (HWND)widget->GetNativeData(NS_NATIVE_WINDOW);
return NS_OK;
}
};
HWND GetHiddenWindowHWND() {
// Need to dispatch this to the main thread because plenty of
// the things it wants to access are main-thread-only.
RefPtr<HWNDGetter> getter = new HWNDGetter();
NS_DispatchAndSpinEventLoopUntilComplete(
"GetHiddenWindowHWND"_ns, mozilla::GetMainThreadSerialEventTarget(),
do_AddRef(getter));
return getter->hidden_window_hwnd;
}
} // namespace
namespace mozilla {
bool InitWidgetTracing() {
sEventHandle = CreateEventW(nullptr, FALSE, FALSE, nullptr);
return sEventHandle != nullptr;
}
void CleanUpWidgetTracing() {
CloseHandle(sEventHandle);
sEventHandle = nullptr;
}
// This function is called from the main (UI) thread.
void SignalTracerThread() {
if (sEventHandle != nullptr) SetEvent(sEventHandle);
}
// This function is called from the background tracer thread.
bool FireAndWaitForTracerEvent() {
MOZ_ASSERT(sEventHandle, "Tracing not initialized!");
// First, try to find the hidden window.
static HWND hidden_window = nullptr;
if (hidden_window == nullptr) {
hidden_window = GetHiddenWindowHWND();
}
if (hidden_window == nullptr) return false;
// Post the tracer message into the hidden window's message queue,
// and then block until it's processed.
PostMessage(hidden_window, MOZ_WM_TRACE, 0, 0);
WaitForSingleObject(sEventHandle, INFINITE);
return true;
}
} // namespace mozilla

Просмотреть файл

@ -13,8 +13,6 @@
// A magic APP message that can be sent to quit, sort of like a
// QUERYENDSESSION/ENDSESSION, but without the query.
#define MOZ_WM_APP_QUIT (WM_APP + 0x0300)
// Used as a "tracer" event to probe event loop latency.
#define MOZ_WM_TRACE (WM_APP + 0x0301)
// accessibility priming
#define MOZ_WM_STARTA11Y (WM_APP + 0x0302)
// Our internal message for WM_MOUSEWHEEL, WM_MOUSEHWHEEL, WM_VSCROLL and

Просмотреть файл

@ -106,7 +106,6 @@ UNIFIED_SOURCES += [
"TaskbarPreviewButton.cpp",
"TaskbarTabPreview.cpp",
"TaskbarWindowPreview.cpp",
"WidgetTraceEvent.cpp",
"WinCompositorWindowThread.cpp",
"WindowHook.cpp",
"WindowsConsole.cpp",

Просмотреть файл

@ -99,7 +99,6 @@
#include "prtime.h"
#include "prenv.h"
#include "mozilla/WidgetTraceEvent.h"
#include "nsContentUtils.h"
#include "nsISupportsPrimitives.h"
#include "nsITheme.h"
@ -4699,13 +4698,6 @@ LRESULT CALLBACK nsWindow::WindowProcInternal(HWND hWnd, UINT msg,
}
}
if (msg == MOZ_WM_TRACE) {
// This is a tracer event for measuring event loop latency.
// See WidgetTraceEvent.cpp for more details.
mozilla::SignalTracerThread();
return 0;
}
// Get the window which caused the event and ask it to process the message
nsWindow* targetWindow = WinUtils::GetNSWindowPtr(hWnd);
NS_ASSERTION(targetWindow, "nsWindow* is null!");

Просмотреть файл

@ -46,10 +46,6 @@
#include "nsDocShell.h"
#include "nsDocShellLoadState.h"
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
# include "EventTracer.h"
#endif
using namespace mozilla;
using mozilla::dom::BrowsingContext;
using mozilla::intl::LocaleService;
@ -835,19 +831,3 @@ nsAppShellService::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
NS_IMETHODIMP
nsAppShellService::StartEventLoopLagTracking(bool* aResult) {
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
*aResult = mozilla::InitEventTracing(true);
#endif
return NS_OK;
}
NS_IMETHODIMP
nsAppShellService::StopEventLoopLagTracking() {
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
mozilla::ShutdownEventTracing();
#endif
return NS_OK;
}

Просмотреть файл

@ -115,14 +115,4 @@ interface nsIAppShellService : nsISupports
* Whether the hidden window has been lazily created.
*/
readonly attribute boolean hasHiddenWindow;
/**
* Start/stop tracking lags in the event loop.
* If the event loop gets unresponsive, a "event-loop-lag" notification
* is sent. Note that calling `startEventLoopLagTracking` when tracking
* is already enabled has no effect.
* @return true if tracking succeeded.
*/
boolean startEventLoopLagTracking();
void stopEventLoopLagTracking();
};