Commit 628b622d authored by Jan Scheffler's avatar Jan Scheffler Committed by Commit Bot

Improve tracing of streaming compilation in v8

This patch adds a couple of tracing events to show how much time is
spent waiting on network vs. actually parsing and compiling JavaScript
when doing streaming compilation

Bug: chromium:939275
Change-Id: I7deb7ad3e2fcf35fe0f8852d1debb198d166a571
Fixed: 939275
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1886896
Commit-Queue: Jan Scheffler <janscheffler@chromium.org>
Reviewed-by: default avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713385}
parent 0a7a534c
...@@ -114,11 +114,24 @@ class SourceStream : public v8::ScriptCompiler::ExternalSourceStream { ...@@ -114,11 +114,24 @@ class SourceStream : public v8::ScriptCompiler::ExternalSourceStream {
case MOJO_RESULT_SHOULD_WAIT: { case MOJO_RESULT_SHOULD_WAIT: {
{ {
TRACE_EVENT_END0(
"v8,devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"v8.parseOnBackgroundParsing");
TRACE_EVENT_BEGIN0(
"v8,devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"v8.parseOnBackgroundWaiting");
base::ScopedAllowBaseSyncPrimitives base::ScopedAllowBaseSyncPrimitives
scoped_allow_base_sync_primitives; scoped_allow_base_sync_primitives;
base::ScopedBlockingCall scoped_blocking_call( base::ScopedBlockingCall scoped_blocking_call(
FROM_HERE, base::BlockingType::WILL_BLOCK); FROM_HERE, base::BlockingType::WILL_BLOCK);
result = mojo::Wait(data_pipe_.get(), MOJO_HANDLE_SIGNAL_READABLE); result = mojo::Wait(data_pipe_.get(), MOJO_HANDLE_SIGNAL_READABLE);
TRACE_EVENT_END0(
"v8,devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"v8.parseOnBackgroundWaiting");
TRACE_EVENT_BEGIN0(
"v8,devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"v8.parseOnBackgroundParsing");
} }
if (result != MOJO_RESULT_OK) { if (result != MOJO_RESULT_OK) {
...@@ -333,12 +346,16 @@ void RunScriptStreamingTask( ...@@ -333,12 +346,16 @@ void RunScriptStreamingTask(
std::unique_ptr<v8::ScriptCompiler::ScriptStreamingTask> task, std::unique_ptr<v8::ScriptCompiler::ScriptStreamingTask> task,
ScriptStreamer* streamer, ScriptStreamer* streamer,
SourceStream* stream) { SourceStream* stream) {
TRACE_EVENT_WITH_FLOW1( // TODO(leszeks): Add flow event data again
TRACE_EVENT_BEGIN1(
"v8,devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.compile"), "v8,devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"v8.parseOnBackground", streamer, "v8.parseOnBackground", "data",
TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, "data",
inspector_parse_script_event::Data(streamer->ScriptResourceIdentifier(), inspector_parse_script_event::Data(streamer->ScriptResourceIdentifier(),
streamer->ScriptURLString())); streamer->ScriptURLString()));
TRACE_EVENT_BEGIN0(
"v8,devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"v8.parseOnBackgroundParsing");
// Running the task can and will block: SourceStream::GetSomeData will get // Running the task can and will block: SourceStream::GetSomeData will get
// called and it will block and wait for data from the network. // called and it will block and wait for data from the network.
task->Run(); task->Run();
...@@ -348,7 +365,21 @@ void RunScriptStreamingTask( ...@@ -348,7 +365,21 @@ void RunScriptStreamingTask(
// TODO(leszeks): This could be done asynchronously, using a mojo watcher. // TODO(leszeks): This could be done asynchronously, using a mojo watcher.
stream->DrainRemainingDataWithoutStreaming(); stream->DrainRemainingDataWithoutStreaming();
TRACE_EVENT_END0(
"v8,devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"v8.parseOnBackgroundParsing");
streamer->StreamingCompleteOnBackgroundThread(); streamer->StreamingCompleteOnBackgroundThread();
TRACE_EVENT_END0(
"v8,devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"v8.parseOnBackground");
// TODO(crbug.com/1021571); Remove this once the last event stops being
// dropped.
TRACE_EVENT_END0(
"v8,devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"v8.parseOnBackground2");
} }
} // namespace } // namespace
......
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