[inspector] Add "disabled-by-default-v8.inspector" events.
This sprinkles some more trace events in the disabled by default "v8.inspector" category, to help with understanding performance impact of stack trace capturing better. Bug: chromium:1283162 Change-Id: I6085d587f241635fbb6934bef3adc95f58c5d2aa Doc: https://bit.ly/v8-cheaper-inspector-stack-traces Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3364085 Reviewed-by: Yang Guo <yangguo@chromium.org> Auto-Submit: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/main@{#78477}
This commit is contained in:
parent
e9440c45fa
commit
e3f48a766f
@ -21,6 +21,7 @@
|
||||
#include "src/inspector/v8-runtime-agent-impl.h"
|
||||
#include "src/inspector/v8-stack-trace-impl.h"
|
||||
#include "src/inspector/v8-value-utils.h"
|
||||
#include "src/tracing/trace-event.h"
|
||||
|
||||
namespace v8_inspector {
|
||||
|
||||
@ -188,54 +189,63 @@ V8Console::V8Console(V8InspectorImpl* inspector) : m_inspector(inspector) {}
|
||||
|
||||
void V8Console::Debug(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Debug");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCall(ConsoleAPIType::kDebug);
|
||||
}
|
||||
|
||||
void V8Console::Error(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Error");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCall(ConsoleAPIType::kError);
|
||||
}
|
||||
|
||||
void V8Console::Info(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Info");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCall(ConsoleAPIType::kInfo);
|
||||
}
|
||||
|
||||
void V8Console::Log(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Log");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCall(ConsoleAPIType::kLog);
|
||||
}
|
||||
|
||||
void V8Console::Warn(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Warn");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCall(ConsoleAPIType::kWarning);
|
||||
}
|
||||
|
||||
void V8Console::Dir(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Dir");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCall(ConsoleAPIType::kDir);
|
||||
}
|
||||
|
||||
void V8Console::DirXml(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::DirXml");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCall(ConsoleAPIType::kDirXML);
|
||||
}
|
||||
|
||||
void V8Console::Table(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Table");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCall(ConsoleAPIType::kTable);
|
||||
}
|
||||
|
||||
void V8Console::Trace(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Trace");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCallWithDefaultArgument(ConsoleAPIType::kTrace,
|
||||
String16("console.trace"));
|
||||
@ -243,6 +253,7 @@ void V8Console::Trace(const v8::debug::ConsoleCallArguments& info,
|
||||
|
||||
void V8Console::Group(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Group");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCallWithDefaultArgument(ConsoleAPIType::kStartGroup,
|
||||
String16("console.group"));
|
||||
@ -251,6 +262,8 @@ void V8Console::Group(const v8::debug::ConsoleCallArguments& info,
|
||||
void V8Console::GroupCollapsed(
|
||||
const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8Console::GroupCollapsed");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCallWithDefaultArgument(ConsoleAPIType::kStartGroupCollapsed,
|
||||
String16("console.groupCollapsed"));
|
||||
@ -258,6 +271,8 @@ void V8Console::GroupCollapsed(
|
||||
|
||||
void V8Console::GroupEnd(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8Console::GroupEnd");
|
||||
ConsoleHelper(info, consoleContext, m_inspector)
|
||||
.reportCallWithDefaultArgument(ConsoleAPIType::kEndGroup,
|
||||
String16("console.groupEnd"));
|
||||
@ -265,6 +280,7 @@ void V8Console::GroupEnd(const v8::debug::ConsoleCallArguments& info,
|
||||
|
||||
void V8Console::Clear(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Clear");
|
||||
ConsoleHelper helper(info, consoleContext, m_inspector);
|
||||
if (!helper.groupId()) return;
|
||||
m_inspector->client()->consoleClear(helper.groupId());
|
||||
@ -295,6 +311,8 @@ static String16 identifierFromTitleOrStackTrace(
|
||||
|
||||
void V8Console::Count(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8Console::Count");
|
||||
ConsoleHelper helper(info, consoleContext, m_inspector);
|
||||
String16 title = helper.firstArgToString(String16("default"), false);
|
||||
String16 identifier = identifierFromTitleOrStackTrace(
|
||||
@ -306,10 +324,15 @@ void V8Console::Count(const v8::debug::ConsoleCallArguments& info,
|
||||
helper.reportCallWithArgument(
|
||||
ConsoleAPIType::kCount,
|
||||
title.isEmpty() ? countString : (title + ": " + countString));
|
||||
TRACE_EVENT_END2(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8Console::Count", "title",
|
||||
TRACE_STR_COPY(title.utf8().c_str()), "count", count);
|
||||
}
|
||||
|
||||
void V8Console::CountReset(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8Console::CountReset");
|
||||
ConsoleHelper helper(info, consoleContext, m_inspector);
|
||||
String16 title = helper.firstArgToString(String16("default"), false);
|
||||
String16 identifier = identifierFromTitleOrStackTrace(
|
||||
@ -320,10 +343,14 @@ void V8Console::CountReset(const v8::debug::ConsoleCallArguments& info,
|
||||
helper.reportCallWithArgument(ConsoleAPIType::kWarning,
|
||||
"Count for '" + title + "' does not exist");
|
||||
}
|
||||
TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8Console::CountReset", "title",
|
||||
TRACE_STR_COPY(title.utf8().c_str()));
|
||||
}
|
||||
|
||||
void V8Console::Assert(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Assert");
|
||||
ConsoleHelper helper(info, consoleContext, m_inspector);
|
||||
DCHECK(!helper.firstArgToBoolean(false));
|
||||
|
||||
@ -338,20 +365,30 @@ void V8Console::Assert(const v8::debug::ConsoleCallArguments& info,
|
||||
|
||||
void V8Console::Profile(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8Console::Profile");
|
||||
ConsoleHelper helper(info, consoleContext, m_inspector);
|
||||
helper.forEachSession([&helper](V8InspectorSessionImpl* session) {
|
||||
session->profilerAgent()->consoleProfile(
|
||||
helper.firstArgToString(String16()));
|
||||
String16 title = helper.firstArgToString(String16());
|
||||
helper.forEachSession([&title](V8InspectorSessionImpl* session) {
|
||||
session->profilerAgent()->consoleProfile(title);
|
||||
});
|
||||
TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8Console::Profile", "title",
|
||||
TRACE_STR_COPY(title.utf8().c_str()));
|
||||
}
|
||||
|
||||
void V8Console::ProfileEnd(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8Console::ProfileEnd");
|
||||
ConsoleHelper helper(info, consoleContext, m_inspector);
|
||||
helper.forEachSession([&helper](V8InspectorSessionImpl* session) {
|
||||
session->profilerAgent()->consoleProfileEnd(
|
||||
helper.firstArgToString(String16()));
|
||||
String16 title = helper.firstArgToString(String16());
|
||||
helper.forEachSession([&title](V8InspectorSessionImpl* session) {
|
||||
session->profilerAgent()->consoleProfileEnd(title);
|
||||
});
|
||||
TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8Console::ProfileEnd", "title",
|
||||
TRACE_STR_COPY(title.utf8().c_str()));
|
||||
}
|
||||
|
||||
static void timeFunction(const v8::debug::ConsoleCallArguments& info,
|
||||
@ -408,21 +445,26 @@ static void timeEndFunction(const v8::debug::ConsoleCallArguments& info,
|
||||
|
||||
void V8Console::Time(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Time");
|
||||
timeFunction(info, consoleContext, false, m_inspector);
|
||||
}
|
||||
|
||||
void V8Console::TimeLog(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::TimeLog");
|
||||
timeEndFunction(info, consoleContext, true, m_inspector);
|
||||
}
|
||||
|
||||
void V8Console::TimeEnd(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::TimeEnd");
|
||||
timeEndFunction(info, consoleContext, false, m_inspector);
|
||||
}
|
||||
|
||||
void V8Console::TimeStamp(const v8::debug::ConsoleCallArguments& info,
|
||||
const v8::debug::ConsoleContext& consoleContext) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8Console::TimeStamp");
|
||||
ConsoleHelper helper(info, consoleContext, m_inspector);
|
||||
String16 title = helper.firstArgToString(String16());
|
||||
m_inspector->client()->consoleTimeStamp(toStringView(title));
|
||||
|
@ -499,6 +499,10 @@ Response V8RuntimeAgentImpl::setMaxCallStackSizeToCapture(int size) {
|
||||
return Response::ServerError(
|
||||
"maxCallStackSizeToCapture should be non-negative");
|
||||
}
|
||||
TRACE_EVENT_WITH_FLOW1(
|
||||
TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8RuntimeAgentImpl::setMaxCallStackSizeToCapture", this,
|
||||
TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, "size", size);
|
||||
V8StackTraceImpl::maxCallStackSizeToCapture = size;
|
||||
return Response::Success();
|
||||
}
|
||||
@ -846,6 +850,9 @@ void V8RuntimeAgentImpl::restore() {
|
||||
|
||||
Response V8RuntimeAgentImpl::enable() {
|
||||
if (m_enabled) return Response::Success();
|
||||
TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8RuntimeAgentImpl::enable", this,
|
||||
TRACE_EVENT_FLAG_FLOW_OUT);
|
||||
m_inspector->client()->beginEnsureAllContextsInGroup(
|
||||
m_session->contextGroupId());
|
||||
m_enabled = true;
|
||||
@ -862,6 +869,9 @@ Response V8RuntimeAgentImpl::enable() {
|
||||
|
||||
Response V8RuntimeAgentImpl::disable() {
|
||||
if (!m_enabled) return Response::Success();
|
||||
TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"),
|
||||
"V8RuntimeAgentImpl::disable", this,
|
||||
TRACE_EVENT_FLAG_FLOW_IN);
|
||||
m_enabled = false;
|
||||
m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, false);
|
||||
m_state->remove(V8RuntimeAgentImplState::bindings);
|
||||
|
@ -42,8 +42,10 @@ std::vector<std::shared_ptr<StackFrame>> toFramesVector(
|
||||
DCHECK(debugger->isolate()->InContext());
|
||||
int frameCount = std::min(v8StackTrace->GetFrameCount(), maxStackSize);
|
||||
|
||||
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"),
|
||||
"SymbolizeStackTrace", "frameCount", frameCount);
|
||||
TRACE_EVENT1(
|
||||
TRACE_DISABLED_BY_DEFAULT("v8.inspector") "," TRACE_DISABLED_BY_DEFAULT(
|
||||
"v8.stack_trace"),
|
||||
"toFramesVector", "frameCount", frameCount);
|
||||
|
||||
std::vector<std::shared_ptr<StackFrame>> frames(frameCount);
|
||||
for (int i = 0; i < frameCount; ++i) {
|
||||
@ -257,8 +259,10 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture(
|
||||
V8Debugger* debugger, int maxStackSize) {
|
||||
DCHECK(debugger);
|
||||
|
||||
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"),
|
||||
"V8StackTraceImpl::capture", "maxFrameCount", maxStackSize);
|
||||
TRACE_EVENT1(
|
||||
TRACE_DISABLED_BY_DEFAULT("v8.inspector") "," TRACE_DISABLED_BY_DEFAULT(
|
||||
"v8.stack_trace"),
|
||||
"V8StackTraceImpl::capture", "maxFrameCount", maxStackSize);
|
||||
|
||||
v8::Isolate* isolate = debugger->isolate();
|
||||
v8::HandleScope handleScope(isolate);
|
||||
@ -402,8 +406,10 @@ std::shared_ptr<AsyncStackTrace> AsyncStackTrace::capture(
|
||||
bool skipTopFrame) {
|
||||
DCHECK(debugger);
|
||||
|
||||
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"),
|
||||
"AsyncStackTrace::capture", "maxFrameCount", maxStackSize);
|
||||
TRACE_EVENT1(
|
||||
TRACE_DISABLED_BY_DEFAULT("v8.inspector") "," TRACE_DISABLED_BY_DEFAULT(
|
||||
"v8.stack_trace"),
|
||||
"AsyncStackTrace::capture", "maxFrameCount", maxStackSize);
|
||||
|
||||
v8::Isolate* isolate = debugger->isolate();
|
||||
v8::HandleScope handleScope(isolate);
|
||||
|
Loading…
Reference in New Issue
Block a user