Commit ef13d782 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

service worker: Add trace events for renderer process initialization.

These could be useful to analyze performance, e.g., to see whether
renderer process initialization was slow vs the renderer was too
busy to receive the Start Worker IPC.

Bug: 968424
Change-Id: I46230c92cdc8f28e11730bfc04bdb427a3f35ac5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636993Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avataroysteine <oysteine@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664892}
parent 356b5659
...@@ -712,6 +712,7 @@ RenderThreadImpl::RenderThreadImpl( ...@@ -712,6 +712,7 @@ RenderThreadImpl::RenderThreadImpl(
void RenderThreadImpl::Init() { void RenderThreadImpl::Init() {
TRACE_EVENT0("startup", "RenderThreadImpl::Init"); TRACE_EVENT0("startup", "RenderThreadImpl::Init");
init_start_ = base::TimeTicks::Now();
GetContentClient()->renderer()->PostIOThreadCreated(GetIOTaskRunner().get()); GetContentClient()->renderer()->PostIOThreadCreated(GetIOTaskRunner().get());
...@@ -962,6 +963,8 @@ void RenderThreadImpl::Init() { ...@@ -962,6 +963,8 @@ void RenderThreadImpl::Init() {
compositing_mode_reporter_->AddCompositingModeWatcher( compositing_mode_reporter_->AddCompositingModeWatcher(
std::move(watcher_ptr)); std::move(watcher_ptr));
} }
init_end_ = base::TimeTicks::Now();
} }
RenderThreadImpl::~RenderThreadImpl() { RenderThreadImpl::~RenderThreadImpl() {
...@@ -2088,6 +2091,24 @@ void RenderThreadImpl::CreateFrameProxy( ...@@ -2088,6 +2091,24 @@ void RenderThreadImpl::CreateFrameProxy(
void RenderThreadImpl::SetUpEmbeddedWorkerChannelForServiceWorker( void RenderThreadImpl::SetUpEmbeddedWorkerChannelForServiceWorker(
blink::mojom::EmbeddedWorkerInstanceClientRequest client_request) { blink::mojom::EmbeddedWorkerInstanceClientRequest client_request) {
// This is a hack. Process creation and initialization occurs before tracing
// is setup, so trace events logged at that time get dropped. We want these
// trace events to analyze service worker performance, so log them here.
//
// TODO(crbug.com/968424): Remove this hack when trace events that happen
// early on are supported.
if (!init_start_.is_null()) {
TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(
"ServiceWorker", "RenderThreadImpl initialization", this,
0 /* thread_id */, init_start_);
TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(
"ServiceWorker", "RenderThreadImpl initialization", this,
0 /* thread_id */, init_end_);
// Clear to avoid double logging.
init_start_ = base::TimeTicks();
init_end_ = base::TimeTicks();
}
EmbeddedWorkerInstanceClientImpl::Create(std::move(client_request)); EmbeddedWorkerInstanceClientImpl::Create(std::move(client_request));
} }
......
...@@ -140,7 +140,7 @@ class StreamTextureFactory; ...@@ -140,7 +140,7 @@ class StreamTextureFactory;
#pragma warning(disable: 4250) #pragma warning(disable: 4250)
#endif #endif
// The RenderThreadImpl class represents a background thread where RenderView // The RenderThreadImpl class represents the main thread, where RenderView
// instances live. The RenderThread supports an API that is used by its // instances live. The RenderThread supports an API that is used by its
// consumer to talk indirectly to the RenderViews and supporting objects. // consumer to talk indirectly to the RenderViews and supporting objects.
// Likewise, it provides an API for the RenderViews to talk back to the main // Likewise, it provides an API for the RenderViews to talk back to the main
...@@ -728,6 +728,9 @@ class CONTENT_EXPORT RenderThreadImpl ...@@ -728,6 +728,9 @@ class CONTENT_EXPORT RenderThreadImpl
mojo::Binding<viz::mojom::CompositingModeWatcher> mojo::Binding<viz::mojom::CompositingModeWatcher>
compositing_mode_watcher_binding_; compositing_mode_watcher_binding_;
base::TimeTicks init_start_;
base::TimeTicks init_end_;
base::WeakPtrFactory<RenderThreadImpl> weak_factory_; base::WeakPtrFactory<RenderThreadImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl); DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl);
......
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