consider creating the ServiceWorkerSubresourceLoaderFactory eagerly |
|||
Issue descriptionCurrently it seems we start creating the ServiceWorkerSubresourceLoaderFactory the first time we need to create a URLLoader for ResourceLoader. This then fires a task to a background thread to wire up the mojo connection to the service worker I've noticed on a site with performance issues that there is a long "ServiceWorker Preparation" time for the first stylesheet loaded by the preload scanner. I wonder if this delay is due to the time required to execute this background setup work necessary to communicate with the service worker. Would it be possible to eagerly create the ServiceWorkerSubresourceLoaderFactory when the DocumentLoader is first created so that it has some time to run in the background before the preload scanner issues its first request?
,
Jan 12
Looks good to investigate. Not sure whether SWSubresourceLoaderFactory creation is included in "ServiceWorker Preparation". It looks like "SW Preparation" is calculated by ResourceResponseInfo::service_worker_ready_time - service_worker_start_time (which are set in subresource requests in S13nSW by ServiceWorkerSubresourceLoader). https://cs.chromium.org/chromium/src/third_party/blink/renderer/devtools/front_end/network/RequestTimingView.js?l=154&rcl=dd05131f5782853146226091e1c4d1209c47e2bb
,
Jan 12
Ah, good point. So if this change has any effect, if any, then it will just show up in COV. I'm unsure of what to make of the high "ServiceWorker Preparation" times, though. It seems like the worker should be running since the navigation FetchEvent was handled. I wonder if there is can be some delay with mojo creating the pipe for the connector to the service worker.
,
Jan 12
Maybe its because we lazily call EnsureControllerConnection() on the first DispatchFetchEvent: https://cs.chromium.org/chromium/src/content/renderer/service_worker/controller_service_worker_connector.cc?l=33&rcl=dd05131f5782853146226091e1c4d1209c47e2bb I'll try adding a step to my CL to eagerly call that as well.
,
Jan 12
So far I'm not really seeing any benefit here. I'm going to try to dig into chrome://tracing to see whats going on.
,
Jan 12
#c4 doesn't matter because we get the connection in the initial subresource params. EnsureControllerConnection() is essentially a no-op in this case.
,
Jan 12
I mean GetControllerServiceWorker() can just return the ControllerServiceWorker without calling the remote EnsureControllerServiceWorker() mojo call.
,
Jan 14
I can't measure any benefit here: https://docs.google.com/spreadsheets/d/15HzaL0NgCZ3yynS5bzIfWilKUnOm0EZtVT2EdaYcPU0/edit?usp=sharing I'm going to leave this open in case any thinks we should do it anyway, but it would be a bit speculative. Feel free to WONTFIX.
,
Jan 16
(6 days ago)
To follow up here, wanderview@ found the high Preparation time was the queuing time fo the fetch event. I think S13nSW changed the meaning of SW Preparation but we can revisit that in another bug. I'll wontfix for now, we can reopen if we discover bottlenecks in traces. |
|||
►
Sign in to add a comment |
|||
Comment 1 by wanderview@chromium.org
, Jan 12