Commit f0061332 authored by Sara Tang's avatar Sara Tang Committed by Commit Bot

[diagnostics] Enable ETW stack-walking events build flag

Feedback from Microsoft partners indicates that it would be beneficial
to enable ETW stack-walking events by default.

This is difficult, because the --interpreted-frames-native-stack flag
comes with a significant perf degradation. Ideally, we would turn
this flag on dynamically, only when a ETW recorder is actively
triggering the provider. Unfortunately, the flag in its current state
cannot be enabled dynamically.

In light of this, we have decided to only flip the build flag.

Bug: v8:11043
Change-Id: Id883b9bcd635b41139450ab2d5c92511422525a3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2773792Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Sara Tang <sartang@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#73784}
parent 4ec2951e
...@@ -41,7 +41,7 @@ declare_args() { ...@@ -41,7 +41,7 @@ declare_args() {
v8_enable_future = false v8_enable_future = false
# Sets -DSYSTEM_INSTRUMENTATION. Enables OS-dependent event tracing # Sets -DSYSTEM_INSTRUMENTATION. Enables OS-dependent event tracing
v8_enable_system_instrumentation = false v8_enable_system_instrumentation = true
# Sets the GUID for the ETW provider # Sets the GUID for the ETW provider
v8_etw_guid = "" v8_etw_guid = ""
......
...@@ -4055,7 +4055,7 @@ bool Shell::SetOptions(int argc, char* argv[]) { ...@@ -4055,7 +4055,7 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strcmp(argv[i], "--fuzzy-module-file-extensions") == 0) { } else if (strcmp(argv[i], "--fuzzy-module-file-extensions") == 0) {
options.fuzzy_module_file_extensions = true; options.fuzzy_module_file_extensions = true;
argv[i] = nullptr; argv[i] = nullptr;
#ifdef V8_ENABLE_SYSTEM_INSTRUMENTATION #if defined(V8_OS_WIN) && defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
} else if (strcmp(argv[i], "--enable-system-instrumentation") == 0) { } else if (strcmp(argv[i], "--enable-system-instrumentation") == 0) {
options.enable_system_instrumentation = true; options.enable_system_instrumentation = true;
options.trace_enabled = true; options.trace_enabled = true;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "src/diagnostics/system-jit-win.h" #include "src/diagnostics/system-jit-win.h"
#include "src/base/lazy-instance.h"
#include "src/base/logging.h" #include "src/base/logging.h"
#include "src/diagnostics/system-jit-metadata-win.h" #include "src/diagnostics/system-jit-metadata-win.h"
#include "src/libplatform/tracing/recorder.h" #include "src/libplatform/tracing/recorder.h"
...@@ -21,7 +22,8 @@ TRACELOGGING_DECLARE_PROVIDER(g_v8Provider); ...@@ -21,7 +22,8 @@ TRACELOGGING_DECLARE_PROVIDER(g_v8Provider);
TRACELOGGING_DEFINE_PROVIDER(g_v8Provider, "V8.js", (V8_ETW_GUID)); TRACELOGGING_DEFINE_PROVIDER(g_v8Provider, "V8.js", (V8_ETW_GUID));
using ScriptMapType = std::unordered_set<int>; using ScriptMapType = std::unordered_set<int>;
ScriptMapType* script_map = new ScriptMapType(); static base::LazyInstance<ScriptMapType>::type script_map =
LAZY_INSTANCE_INITIALIZER;
void Register() { void Register() {
DCHECK(!TraceLoggingProviderEnabled(g_v8Provider, 0, 0)); DCHECK(!TraceLoggingProviderEnabled(g_v8Provider, 0, 0));
...@@ -53,8 +55,8 @@ void EventHandler(const JitCodeEvent* event) { ...@@ -53,8 +55,8 @@ void EventHandler(const JitCodeEvent* event) {
if (!script.IsEmpty()) { if (!script.IsEmpty()) {
// if the first time seeing this source file, log the SourceLoad event // if the first time seeing this source file, log the SourceLoad event
script_id = script->GetId(); script_id = script->GetId();
if (script_map->find(script_id) == script_map->end()) { if (script_map.Pointer()->find(script_id) == script_map.Pointer()->end()) {
script_map->insert(script_id); script_map.Pointer()->insert(script_id);
auto script_name = script->GetScriptName(); auto script_name = script->GetScriptName();
std::wstring wstr_name(0, L'\0'); std::wstring wstr_name(0, L'\0');
......
...@@ -17,24 +17,24 @@ namespace v8 { ...@@ -17,24 +17,24 @@ namespace v8 {
namespace platform { namespace platform {
namespace tracing { namespace tracing {
TRACELOGGING_DECLARE_PROVIDER(g_v8Provider); TRACELOGGING_DECLARE_PROVIDER(g_v8LibProvider);
TRACELOGGING_DEFINE_PROVIDER(g_v8Provider, "V8.js", (V8_ETW_GUID)); TRACELOGGING_DEFINE_PROVIDER(g_v8LibProvider, "V8.js", (V8_ETW_GUID));
Recorder::Recorder() { TraceLoggingRegister(g_v8Provider); } Recorder::Recorder() { TraceLoggingRegister(g_v8LibProvider); }
Recorder::~Recorder() { Recorder::~Recorder() {
if (g_v8Provider) { if (g_v8LibProvider) {
TraceLoggingUnregister(g_v8Provider); TraceLoggingUnregister(g_v8LibProvider);
} }
} }
bool Recorder::IsEnabled() { bool Recorder::IsEnabled() {
return TraceLoggingProviderEnabled(g_v8Provider, 0, 0); return TraceLoggingProviderEnabled(g_v8LibProvider, 0, 0);
} }
bool Recorder::IsEnabled(const uint8_t level) { bool Recorder::IsEnabled(const uint8_t level) {
return TraceLoggingProviderEnabled(g_v8Provider, level, 0); return TraceLoggingProviderEnabled(g_v8LibProvider, level, 0);
} }
void Recorder::AddEvent(TraceObject* trace_event) { void Recorder::AddEvent(TraceObject* trace_event) {
...@@ -49,7 +49,7 @@ void Recorder::AddEvent(TraceObject* trace_event) { ...@@ -49,7 +49,7 @@ void Recorder::AddEvent(TraceObject* trace_event) {
trace_event->category_enabled_flag()), trace_event->category_enabled_flag()),
-1, wCategoryGroupName, 4096); -1, wCategoryGroupName, 4096);
TraceLoggingWrite(g_v8Provider, "", TraceLoggingValue(wName, "Event Name"), TraceLoggingWrite(g_v8LibProvider, "", TraceLoggingValue(wName, "Event Name"),
TraceLoggingValue(trace_event->pid(), "pid"), TraceLoggingValue(trace_event->pid(), "pid"),
TraceLoggingValue(trace_event->tid(), "tid"), TraceLoggingValue(trace_event->tid(), "tid"),
TraceLoggingValue(trace_event->ts(), "ts"), TraceLoggingValue(trace_event->ts(), "ts"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment