зеркало из https://github.com/mozilla/gecko-dev.git
Bug 853896 - Turn off MOZ_EVENT_TRACE when profiling. r=ted
--HG-- extra : rebase_source : 2ae36f2f4be730528b0f18154377fa32ee25b49a
This commit is contained in:
Родитель
8c4df9efa0
Коммит
8a70878243
|
@ -71,6 +71,10 @@ namespace {
|
|||
PRThread* sTracerThread = NULL;
|
||||
bool sExit = false;
|
||||
|
||||
struct TracerStartClosure {
|
||||
bool mLogTracing;
|
||||
};
|
||||
|
||||
/*
|
||||
* The tracer thread fires events at the native event loop roughly
|
||||
* every kMeasureInterval. It will sleep to attempt not to send them
|
||||
|
@ -85,6 +89,8 @@ void TracerThread(void *arg)
|
|||
{
|
||||
PR_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.
|
||||
|
@ -117,7 +123,9 @@ void TracerThread(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
fprintf(log, "MOZ_EVENT_TRACE start %llu\n", PR_Now() / PR_USEC_PER_MSEC);
|
||||
if (threadArgs->mLogTracing) {
|
||||
fprintf(log, "MOZ_EVENT_TRACE start %llu\n", PR_Now() / PR_USEC_PER_MSEC);
|
||||
}
|
||||
|
||||
while (!sExit) {
|
||||
TimeStamp start(TimeStamp::Now());
|
||||
|
@ -130,7 +138,7 @@ void TracerThread(void *arg)
|
|||
if (FireAndWaitForTracerEvent()) {
|
||||
TimeDuration duration = TimeStamp::Now() - start;
|
||||
// Only report samples that exceed our measurement threshold.
|
||||
if (duration.ToMilliseconds() > threshold) {
|
||||
if (threadArgs->mLogTracing && duration.ToMilliseconds() > threshold) {
|
||||
fprintf(log, "MOZ_EVENT_TRACE sample %llu %d\n",
|
||||
PR_Now() / PR_USEC_PER_MSEC,
|
||||
int(duration.ToSecondsSigDigits() * 1000));
|
||||
|
@ -151,17 +159,21 @@ void TracerThread(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
fprintf(log, "MOZ_EVENT_TRACE stop %llu\n", PR_Now() / PR_USEC_PER_MSEC);
|
||||
if (threadArgs->mLogTracing) {
|
||||
fprintf(log, "MOZ_EVENT_TRACE stop %llu\n", PR_Now() / PR_USEC_PER_MSEC);
|
||||
}
|
||||
|
||||
if (log != stdout)
|
||||
fclose(log);
|
||||
|
||||
delete threadArgs;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
bool InitEventTracing()
|
||||
bool InitEventTracing(bool aLog)
|
||||
{
|
||||
if (sTracerThread)
|
||||
return true;
|
||||
|
@ -170,12 +182,16 @@ bool InitEventTracing()
|
|||
if (!InitWidgetTracing())
|
||||
return false;
|
||||
|
||||
// The tracer thread owns the object and will delete it.
|
||||
TracerStartClosure* args = new TracerStartClosure();
|
||||
args->mLogTracing = aLog;
|
||||
|
||||
// Create a thread that will fire events back at the
|
||||
// main thread to measure responsiveness.
|
||||
NS_ABORT_IF_FALSE(!sTracerThread, "Event tracing already initialized!");
|
||||
sTracerThread = PR_CreateThread(PR_USER_THREAD,
|
||||
TracerThread,
|
||||
NULL,
|
||||
args,
|
||||
PR_PRIORITY_NORMAL,
|
||||
PR_GLOBAL_THREAD,
|
||||
PR_JOINABLE_THREAD,
|
||||
|
|
|
@ -10,7 +10,9 @@ 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.
|
||||
bool InitEventTracing();
|
||||
// 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.
|
||||
|
|
|
@ -3872,7 +3872,8 @@ XREMain::XRE_mainRun()
|
|||
|
||||
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
|
||||
if (PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP") || profiler_is_active()) {
|
||||
mozilla::InitEventTracing();
|
||||
bool logToConsole = !!PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP");
|
||||
mozilla::InitEventTracing(logToConsole);
|
||||
}
|
||||
#endif /* MOZ_INSTRUMENT_EVENT_LOOP */
|
||||
|
||||
|
|
|
@ -79,7 +79,8 @@ nsProfiler::StartProfiler(uint32_t aEntries, uint32_t aInterval,
|
|||
|
||||
profiler_start(aEntries, aInterval, aFeatures, aFeatureCount);
|
||||
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
|
||||
mozilla::InitEventTracing();
|
||||
bool printToConsole = false;
|
||||
mozilla::InitEventTracing(printToConsole);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче