Commit a875acbb authored by Ben Kelly's avatar Ben Kelly Committed by Commit Bot

Measure mojo::DataPipe creation time on the ServiceWorker thread.

We've seen some anecdotal evidence in local testing that mojo::DataPipe
creation can sometimes take milliseconds to complete.  Currently there
is a pipe created on the ServiceWorker thread for certain FetchEvent
respondWith() code paths.  This histogram will help us determine if
this is introducing jank on the service worker thread.

Bug: 888045
Change-Id: I5f36da2dfbde4bd561c605336949e475f45ecb43
Reviewed-on: https://chromium-review.googlesource.com/1239274Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Ben Kelly <wanderview@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593302}
parent c861964b
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "base/metrics/histogram_macros.h"
#include "services/network/public/mojom/fetch_api.mojom-blink.h" #include "services/network/public/mojom/fetch_api.mojom-blink.h"
#include "services/network/public/mojom/request_context_frame_type.mojom-blink.h" #include "services/network/public/mojom/request_context_frame_type.mojom-blink.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_response.h" #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_response.h"
...@@ -287,12 +288,15 @@ void FetchRespondWithObserver::OnResponseFulfilled( ...@@ -287,12 +288,15 @@ void FetchRespondWithObserver::OnResponseFulfilled(
return; return;
} }
// Handle the stream response body. // Handle the stream response body.
base::TimeTicks start_pipe_creation = base::TimeTicks::Now();
mojo::DataPipe pipe; mojo::DataPipe pipe;
if (!pipe.consumer_handle.is_valid()) { if (!pipe.consumer_handle.is_valid()) {
OnResponseRejected(ServiceWorkerResponseError::kDataPipeCreationFailed); OnResponseRejected(ServiceWorkerResponseError::kDataPipeCreationFailed);
return; return;
} }
DCHECK(pipe.producer_handle.is_valid()); DCHECK(pipe.producer_handle.is_valid());
UMA_HISTOGRAM_TIMES("ServiceWorker.FetchRespondWithDataPipeCreation.Time",
base::TimeTicks::Now() - start_pipe_creation);
std::unique_ptr<WebServiceWorkerStreamHandle> body_stream_handle = std::unique_ptr<WebServiceWorkerStreamHandle> body_stream_handle =
std::make_unique<WebServiceWorkerStreamHandle>( std::make_unique<WebServiceWorkerStreamHandle>(
......
...@@ -93990,6 +93990,15 @@ uploading your change for review. ...@@ -93990,6 +93990,15 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="ServiceWorker.FetchRespondWithDataPipeCreation.Time"
units="ms">
<owner>wanderview@chromium.org</owner>
<summary>
Measures how long the service worker thread is blocked creating a
mojo::DataPipe during FetchEvent.respondWith() processing.
</summary>
</histogram>
<histogram name="ServiceWorker.ForeignFetch.OriginCount"> <histogram name="ServiceWorker.ForeignFetch.OriginCount">
<obsolete> <obsolete>
Deprecated April 2018. Deprecated April 2018.
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