Bug 1429623: Report tracing events and thread registration to VTune when --enable-vtune is enabled. r=mstange r=ted

MozReview-Commit-ID: I47OIX16ibf
This commit is contained in:
Bas Schouten 2018-01-19 17:19:29 +01:00
Родитель d673a75c4b
Коммит 3143ad47f1
4 изменённых файлов: 34 добавлений и 11 удалений

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

@ -1,4 +1,4 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<!-- 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/. -->
@ -6789,7 +6789,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<h1><a id="vtune"></a>VTune License</h1>
<p>This license applies to certain files in the directory
<code>js/src/vtune</code>.</p>
<code>js/src/vtune</code> and <code>tools/profiler/core/vtune</code>.</p>
<pre>
Copyright (c) 2011 Intel Corporation.
All rights reserved.

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

@ -4,6 +4,11 @@
* 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/. */
#ifdef XP_WIN
#undef UNICODE
#undef _UNICODE
#endif
#include "VTuneProfiler.h"
#include "mozilla/Bootstrap.h"
#include <memory>
@ -18,8 +23,8 @@ VTuneProfiler::Initialize()
// This is just a 'dirty trick' to find out if the ittnotify DLL was found.
// If it wasn't this function always returns 0, otherwise it returns incrementing
// numbers, if the library was found this wastes 2 events but that should be okay.
__itt_event testEvent = __itt_event_createA("Test event", strlen("Test event"));
testEvent = __itt_event_createA("Test event 2", strlen("Test event 2"));
__itt_event testEvent = __itt_event_create("Test event", strlen("Test event"));
testEvent = __itt_event_create("Test event 2", strlen("Test event 2"));
if (testEvent) {
mInstance = new VTuneProfiler();
@ -46,7 +51,7 @@ VTuneProfiler::TraceInternal(const char* aName, TracingKind aKind)
if (iter != mStrings.end()) {
event = iter->second;
} else {
event = __itt_event_createA(aName, str.length());
event = __itt_event_create(aName, str.length());
mStrings.insert({ str, event });
}
@ -66,21 +71,21 @@ VTuneProfiler::RegisterThreadInternal(const char* aName)
// Process main thread.
switch (XRE_GetProcessType()) {
case GeckoProcessType::GeckoProcessType_Default:
__itt_thread_set_nameA("Main Process");
__itt_thread_set_name("Main Process");
break;
case GeckoProcessType::GeckoProcessType_Content:
__itt_thread_set_nameA("Content Process");
__itt_thread_set_name("Content Process");
break;
case GeckoProcessType::GeckoProcessType_GMPlugin:
__itt_thread_set_nameA("Plugin Process");
__itt_thread_set_name("Plugin Process");
break;
case GeckoProcessType::GeckoProcessType_GPU:
__itt_thread_set_nameA("GPU Process");
__itt_thread_set_name("GPU Process");
break;
default:
__itt_thread_set_nameA("Unknown Process");
__itt_thread_set_name("Unknown Process");
}
return;
}
__itt_thread_set_nameA(aName);
__itt_thread_set_name(aName);
}

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

@ -39,6 +39,7 @@
#include "mozilla/UniquePtr.h"
#include "mozilla/Vector.h"
#include "GeckoProfiler.h"
#include "VTuneProfiler.h"
#include "GeckoProfilerReporter.h"
#include "ProfilerIOInterposeObserver.h"
#include "mozilla/AutoProfilerLabel.h"
@ -2182,6 +2183,8 @@ locked_register_thread(PSLockRef aLock, const char* aName, void* aStackTop)
MOZ_RELEASE_ASSERT(!FindLiveThreadInfo(aLock));
VTUNE_REGISTER_THREAD(aName);
if (!TLSInfo::Init(aLock)) {
return;
}
@ -2297,6 +2300,8 @@ profiler_init(void* aStackTop)
{
LOG("profiler_init");
VTUNE_INIT();
MOZ_RELEASE_ASSERT(!CorePS::Exists());
if (getenv("MOZ_PROFILER_HELP")) {
@ -2445,6 +2450,8 @@ profiler_shutdown()
{
LOG("profiler_shutdown");
VTUNE_SHUTDOWN();
MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists());
@ -3329,6 +3336,8 @@ profiler_tracing(const char* aCategory, const char* aMarkerName,
{
MOZ_RELEASE_ASSERT(CorePS::Exists());
VTUNE_TRACING(aMarkerName, aKind);
// This function is hot enough that we use RacyFeatures, notActivePS.
if (!RacyFeatures::IsActiveWithoutPrivacy()) {
return;
@ -3344,6 +3353,8 @@ profiler_tracing(const char* aCategory, const char* aMarkerName,
{
MOZ_RELEASE_ASSERT(CorePS::Exists());
VTUNE_TRACING(aMarkerName, aKind);
// This function is hot enough that we use RacyFeatures, notActivePS.
if (!RacyFeatures::IsActiveWithoutPrivacy()) {
return;

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

@ -121,6 +121,13 @@ EXPORTS += [
'public/GeckoProfiler.h',
]
if CONFIG['MOZ_VTUNE']:
DEFINES['MOZ_VTUNE_INSTRUMENTATION'] = True
UNIFIED_SOURCES += [
'core/VTuneProfiler.cpp',
]
if CONFIG['MOZ_TASK_TRACER']:
EXPORTS += [
'tasktracer/GeckoTaskTracer.h',