New issue
Advanced search Search tips

Issue 690795 link

Starred by 4 users

Issue metadata

Status: Fixed
Owner:
Closed: May 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Feature



Sign in to add a comment

Use mojo::DataPipe in FetchEvent.respondWith() instead of BlobRegistry Stream.

Project Member Reported by horo@chromium.org, Feb 10 2017

Issue description

BlobRegistry Stream sends the IPC from the main thread of the renderer process.
So FetchEvent.respondWith() is blocked by the main thread.


We should use mojo::DataPipe instead.
 

Comment 1 by horo@chromium.org, Feb 10 2017

I created a proof-of-concept patch: https://codereview.chromium.org/2684533002/

Comment 2 by horo@chromium.org, Feb 10 2017

Owner: shimazu@chromium.org
Status: Assigned (was: Untriaged)
As we talked offline, shimazu@ will take this issue.

Comment 3 by n...@fb.com, Feb 13 2017

Labels: DevRel-Facebook
Status: Started (was: Assigned)

Comment 5 by mek@chromium.org, Apr 5 2017

I'm curious if the change this issue is describing would still make sense in a world where blobs were mojo-ifyied in such a way as to no longer requiring going through the main thread? I don't know how exactly blobs are involved with respondWith, but it seems unfortunate if we end up working around a short-coming in the blob system, rather than fixing that short-coming (And we are beginning to really look into how to mojo-ify the blob system).
Current problem is "respondWith(stream) is using Stream provided by BlobRegistry.
BlobRegistry is living on the main thread and respondWith on the service
worker's thread contains a thread hop implicitly.".
I'm not familiar with the blob mechanism, but if you can separate it out from the main thread, we'll no longer have the threading problem. 

I've created a patch for this issue (https://crrev.com/2703343002), and I'm happy if you would added comments to it.

Comment 7 by mek@chromium.org, Apr 6 2017

Actually doesn't seem like this has anything do with blobs at all, it's just that streams are for whatever reason piped through BlobRegistry? So not sure if the blob mojo-ification would necessarily help you.

But still the same question remains: if there is a performance issue with streams in workers, isn't the correct approach to change the way all streams are handled to use mojo datapipes (if that is possible), rather than changing how streams are dealt with in this specific case? I.e. getting rid of the streams related methods from BlobRegister, and mojo-ifying them in some way that avoids the threading issues?

Comment 8 by mek@chromium.org, Apr 6 2017

But I don't really know anything about this code whatsoever, or why it was using streams in the first place. And I have no idea what the relative effort is of mojoifying streams to use datapipes, vs only changing the way service workers stream data to use datapipes. So I'm not saying that your current approach is wrong, it just seems potentially sub-optimal.

Comment 9 by horo@chromium.org, Apr 6 2017

The mechanism of blink::Stream was introduced by tyoshino@ in 2013 when he was implementing (old) Streams API that is different one from the current spec.
And when I implemented .respondWith(stream) feature, I reused the mechanism of blink::Stream.

But the old Streams API was removed from the code base, and respondWith is the only user of blink::Stream.

So when we will use mojo::DataPipe for respondWith(stream), we can remove the current mechanism of blink::Stream.

Comment 10 by horo@chromium.org, Apr 6 2017

The bug of the old Streams API:  issue 169957 

Comment 11 by mek@chromium.org, Apr 6 2017

Ah, that sounds good to me.
Project Member

Comment 12 by bugdroid1@chromium.org, Apr 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210

commit 1ac68cf90fa046d3e9c1418aee7cd14b8ec38210
Author: shimazu <shimazu@chromium.org>
Date: Thu Apr 20 06:03:46 2017

ServiceWorker: Use mojo's data pipe for respondWith(stream)

Currently respondWith(fetch(...)) is using Stream provided by BlobRegistry.
BlobRegistry is living on the main thread and any respondWith using the
BlobRegistry like 'respondWith(fetch(...))' or
'respondWith(new Response('body'))' on the service worker thread contain a
thread hop implicitly. This patch is to use mojo's data pipe instead of Stream
to avoid the thread hop.

Proof-of-Concept patch: https://crrev.com/2684533002

BUG= 690795 

Review-Url: https://codereview.chromium.org/2703343002
Cr-Commit-Position: refs/heads/master@{#465909}

[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/BUILD.gn
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/DEPS
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/cache_storage/cache_storage_cache.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/cache_storage/cache_storage_cache_unittest.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/cache_storage/cache_storage_manager_unittest.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/embedded_worker_test_helper.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/embedded_worker_test_helper.h
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/service_worker_browsertest.cc
[add] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/service_worker_data_pipe_reader.cc
[add] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/service_worker_data_pipe_reader.h
[add] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/service_worker_data_pipe_reader_unittest.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/service_worker_fetch_dispatcher.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/service_worker_fetch_dispatcher.h
[delete] https://crrev.com/f9f882493c6285711f95b88648974e1641168c28/content/browser/service_worker/service_worker_stream_reader.cc
[delete] https://crrev.com/f9f882493c6285711f95b88648974e1641168c28/content/browser/service_worker/service_worker_stream_reader.h
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/service_worker_url_request_job.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/service_worker_url_request_job.h
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/browser/service_worker/service_worker_url_request_job_unittest.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/common/service_worker/service_worker_event_dispatcher.mojom
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/common/service_worker/service_worker_event_dispatcher.typemap
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/common/service_worker/service_worker_messages.h
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/common/service_worker/service_worker_types.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/common/service_worker/service_worker_types.h
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/renderer/cache_storage/cache_storage_dispatcher.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/renderer/service_worker/service_worker_context_client.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/renderer/service_worker/service_worker_context_client.h
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/renderer/service_worker/service_worker_type_util.cc
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/content/test/BUILD.gn
[add] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/resources/respondwith-fetch-worker.js
[add] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/resources/slow-fetch-and-stop-worker-iframe.html
[add] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/resources/slow-response.php
[add] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/stop-worker-during-respond-with.html
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/modules/fetch/DEPS
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/modules/fetch/FetchDataLoader.cpp
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/modules/fetch/FetchDataLoader.h
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/modules/serviceworkers/DEPS
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/modules/serviceworkers/FetchRespondWithObserver.cpp
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.h
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/platform/BUILD.gn
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/platform/exported/WebServiceWorkerResponse.cpp
[add] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/platform/exported/WebServiceWorkerStreamHandle.cpp
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeClientImpl.cpp
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeClientImpl.h
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/public/BUILD.gn
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h
[add] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerStreamHandle.h
[add] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom
[modify] https://crrev.com/1ac68cf90fa046d3e9c1418aee7cd14b8ec38210/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h

Status: Fixed (was: Started)
Labels: M-60
Project Member

Comment 15 by bugdroid1@chromium.org, Jul 13 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2806adc6cae9df89a37e4ee7eca4ace525312afe

commit 2806adc6cae9df89a37e4ee7eca4ace525312afe
Author: Marijn Kruisselbrink <mek@chromium.org>
Date: Thu Jul 13 18:03:30 2017

Remove unused blink::Stream class.

After ac68cf90fa046d3e9c1418aee7cd14b8ec38210 there is no code left that
still uses blink::Stream, so remove the class and its IPCs.

Bug:  690795 
Change-Id: I1a60a65b232bed39aa1d16896ba611d484324c8e
Reviewed-on: https://chromium-review.googlesource.com/568689
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Takeshi Yoshino <tyoshino@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486437}
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/content/browser/fileapi/fileapi_message_filter.cc
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/content/browser/fileapi/fileapi_message_filter.h
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/content/browser/fileapi/fileapi_message_filter_unittest.cc
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/content/browser/renderer_host/render_process_host_impl.cc
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/content/child/blob_storage/webblobregistry_impl.cc
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/content/child/blob_storage/webblobregistry_impl.h
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/content/common/fileapi/webblob_messages.h
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/content/test/mock_webblob_registry_impl.cc
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/content/test/mock_webblob_registry_impl.h
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/third_party/WebKit/Source/core/streams/BUILD.gn
[delete] https://crrev.com/ec6c1b3f0dbfc303a1517e0513a411e3d1068bb7/third_party/WebKit/Source/core/streams/Stream.cpp
[delete] https://crrev.com/ec6c1b3f0dbfc303a1517e0513a411e3d1068bb7/third_party/WebKit/Source/core/streams/Stream.h
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/third_party/WebKit/Source/modules/fetch/FetchDataLoader.h
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/third_party/WebKit/Source/modules/serviceworkers/FetchRespondWithObserver.cpp
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/third_party/WebKit/Source/platform/blob/BlobRegistry.cpp
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/third_party/WebKit/Source/platform/blob/BlobRegistry.h
[modify] https://crrev.com/2806adc6cae9df89a37e4ee7eca4ace525312afe/third_party/WebKit/public/platform/WebBlobRegistry.h

Sign in to add a comment