Optimization when no fetch handler is registered |
|||||||
Issue descriptionAs the discussion[1], event handlers should be static on the very first script evaluation, and if no fetch handler is added, network requests can go to the network directly bypassing SW script. This will gain the performance when SW uses only push notification and so on. [1] https://github.com/slightlyoff/ServiceWorker/issues/718
,
Apr 22 2016
Old discussion: http://crbug.com/483354
,
Apr 22 2016
,
Apr 25 2016
,
Apr 25 2016
Created a test to measure the performance improvements objectively: http://crrev.com/1920783002
,
Apr 25 2016
,
Apr 28 2016
Confirmed the Android/470ms "sadness" of "main resource fetch with a cold Service Worker" by a test[1]. In my environment (Nexus7 2013, Release build of today's master), in-scope iframe creation with cold sw/hot sw took around 100ms/40ms while out-of-scope took 10-20ms. [1] https://github.com/amiq11/Service-Worker-Performance/commit/d45228bf47ca4ca04ef082ad2bcc7786c4dc874a
,
May 27 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb commit ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb Author: shimazu <shimazu@chromium.org> Date: Fri May 27 04:34:04 2016 ServiceWorker: Store the existence of fetch event handler Currently |has_fetch_handler| is always set to true though the ServiceWorker script has no fetch event handler. This patch passes the existence of fetch handler in the response to the install event, so the correct value will be stored. This information will be used for bypassing ServiceWorker when no fetch handler is registered. BUG= 605844 TEST=./out/Default/content_unittests --gtest_filter="ServiceWorkerJobTest.HasFetchHandler" TEST=./out/Default/content_browsertests --gtest_filter="ServiceWorkerVersionBrowserTest.InstallWith*" Review-Url: https://codereview.chromium.org/2002883002 Cr-Commit-Position: refs/heads/master@{#396381} [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/content/browser/service_worker/embedded_worker_test_helper.cc [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/content/browser/service_worker/service_worker_browsertest.cc [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/content/browser/service_worker/service_worker_context_unittest.cc [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/content/browser/service_worker/service_worker_job_unittest.cc [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/content/browser/service_worker/service_worker_register_job.cc [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/content/browser/service_worker/service_worker_register_job.h [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/content/browser/service_worker/service_worker_storage.cc [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/content/browser/service_worker/service_worker_version.h [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/content/common/service_worker/service_worker_messages.h [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/content/renderer/service_worker/service_worker_context_client.cc [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.h [modify] https://crrev.com/ceec8e3a24f7ad3a2bd7a64ae7f6d82f25dfabdb/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextProxy.h
,
May 31 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/8a5ede2ab476d57dbce99422d89333b71cd7dcab commit 8a5ede2ab476d57dbce99422d89333b71cd7dcab Author: shimazu <shimazu@chromium.org> Date: Tue May 31 05:28:42 2016 ServiceWorker: Bypass SW when the script doesn't have fetch handler When the script doesn't have a fetch handler, a request will immediately go to the network after passed to SW in current implementation. However, if SW is down, this procedure will wait for waking SW up though SW doesn't have fetch handler. This patch enables the request to directly go to network bypassing SW in this situation. BUG= 605844 TEST=/out/Release/content_unittest --gtest_filter="ServiceWorkerControlleeRequestHandlerTest.FallbackWithNoFetchHandler" Review-Url: https://codereview.chromium.org/2019613003 Cr-Commit-Position: refs/heads/master@{#396787} [modify] https://crrev.com/8a5ede2ab476d57dbce99422d89333b71cd7dcab/content/browser/service_worker/service_worker_controllee_request_handler.cc [modify] https://crrev.com/8a5ede2ab476d57dbce99422d89333b71cd7dcab/content/browser/service_worker/service_worker_controllee_request_handler_unittest.cc [modify] https://crrev.com/8a5ede2ab476d57dbce99422d89333b71cd7dcab/content/browser/service_worker/service_worker_version.h
,
May 31 2016
Just out of curiosity, are you still checking for service worker updates even if the fetch event is not fired? I wrote a spec issue for this, but was wondering what you were implementing to start: https://github.com/slightlyoff/ServiceWorker/issues/905
,
May 31 2016
Yes, updates are checked as usual. Actually we should add an assertion for that in our test (shimazu@ originally had one which I wrongly asked him to remove). I'll comment on the spec issue too.
,
Jun 1 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/db1d53558883c7301360ddb05f0895fe05ae3408 commit db1d53558883c7301360ddb05f0895fe05ae3408 Author: shimazu <shimazu@chromium.org> Date: Wed Jun 01 04:54:47 2016 ServiceWorker: Distinguish SW.PageLoad w/ and w/o fetch handler This patch separates ServiceWorker.PageLoad for serviceworker into the two: w/ and w/o fetch handler in order to measure the impact of the no-fetch handler optimization. BUG= 605844 Review-Url: https://codereview.chromium.org/2025813002 Cr-Commit-Position: refs/heads/master@{#397060} [modify] https://crrev.com/db1d53558883c7301360ddb05f0895fe05ae3408/content/browser/service_worker/service_worker_controllee_request_handler.cc [modify] https://crrev.com/db1d53558883c7301360ddb05f0895fe05ae3408/content/browser/service_worker/service_worker_metrics.cc [modify] https://crrev.com/db1d53558883c7301360ddb05f0895fe05ae3408/content/browser/service_worker/service_worker_metrics.h [modify] https://crrev.com/db1d53558883c7301360ddb05f0895fe05ae3408/tools/metrics/histograms/histograms.xml
,
Jun 1 2016
,
Jun 21 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/c367daaa701cf3e439ab3f75108a2fdd2c00342b commit c367daaa701cf3e439ab3f75108a2fdd2c00342b Author: shimazu <shimazu@chromium.org> Date: Tue Jun 21 09:14:43 2016 Revert of ServiceWorker: Bypass SW when the script doesn't have fetch handler (patchset #5 id:80001 of https://codereview.chromium.org/2019613003/ ) Reason for revert: See: http://crbug.com/621788 Original issue's description: > ServiceWorker: Bypass SW when the script doesn't have fetch handler > > When the script doesn't have a fetch handler, a request > will immediately go to the network after passed to SW in current implementation. > However, if SW is down, this procedure will wait for waking SW up though SW > doesn't have fetch handler. This patch enables the request to directly go to > network bypassing SW in this situation. > > BUG= 605844 > TEST=/out/Release/content_unittest --gtest_filter="ServiceWorkerControlleeRequestHandlerTest.FallbackWithNoFetchHandler" > > Committed: https://crrev.com/8a5ede2ab476d57dbce99422d89333b71cd7dcab > Cr-Commit-Position: refs/heads/master@{#396787} TBR=falken@chromium.org,mek@chromium.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG= 605844 Review-Url: https://codereview.chromium.org/2080793003 Cr-Commit-Position: refs/heads/master@{#400928} [modify] https://crrev.com/c367daaa701cf3e439ab3f75108a2fdd2c00342b/content/browser/service_worker/service_worker_controllee_request_handler.cc [modify] https://crrev.com/c367daaa701cf3e439ab3f75108a2fdd2c00342b/content/browser/service_worker/service_worker_controllee_request_handler_unittest.cc [modify] https://crrev.com/c367daaa701cf3e439ab3f75108a2fdd2c00342b/content/browser/service_worker/service_worker_version.h
,
Jun 28 2016
,
Jul 7 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/e14963a7be1f6445401efb43619301bf9fe3157d commit e14963a7be1f6445401efb43619301bf9fe3157d Author: shimazu <shimazu@chromium.org> Date: Thu Jul 07 09:31:48 2016 ServiceWorker: Add an API to fallback to renderer for CORS preflight Currently ServiceWorkerURLRequestJob::ForwardToNetwork invokes restart of the request and the request goes to the network directly. In subresource case, this causes an bug when the request needs CORS preflight. This patch adds an API to fallback with CORS check for subresources; this is used at a subsequent patch: aka no-fetch optimization http://crrev.com/2103063002. BUG= 621788 , 605844 Review-Url: https://codereview.chromium.org/2108573002 Cr-Commit-Position: refs/heads/master@{#404114} [modify] https://crrev.com/e14963a7be1f6445401efb43619301bf9fe3157d/content/browser/service_worker/service_worker_url_request_job.cc [modify] https://crrev.com/e14963a7be1f6445401efb43619301bf9fe3157d/content/browser/service_worker/service_worker_url_request_job.h
,
Jul 8 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/cb53dfa21239d8be2ed3bc53c83d8c001603cee6 commit cb53dfa21239d8be2ed3bc53c83d8c001603cee6 Author: shimazu <shimazu@chromium.org> Date: Fri Jul 08 14:04:11 2016 ServiceWorker: Reland of bypassing SW when no fetch handler existed When the script doesn't have fetch handler, in-scope network requests don't need to go to the service worker. This patch is to bypass it. This patch is a CL for re-landing which was reverted at http://crrev.com/2080793003. This CL should be landed after http://crrev.com/2108573002 is committed. BUG= 605844 , 621788 TEST=./out/Debug/content_unittests --gtest_filter="ServiceWorkerControlleeRequestHandlerTest.FallbackWithNoFetchHandler*" Review-Url: https://codereview.chromium.org/2103063002 Cr-Commit-Position: refs/heads/master@{#404348} [modify] https://crrev.com/cb53dfa21239d8be2ed3bc53c83d8c001603cee6/content/browser/service_worker/service_worker_controllee_request_handler.cc [modify] https://crrev.com/cb53dfa21239d8be2ed3bc53c83d8c001603cee6/content/browser/service_worker/service_worker_controllee_request_handler_unittest.cc [modify] https://crrev.com/cb53dfa21239d8be2ed3bc53c83d8c001603cee6/content/browser/service_worker/service_worker_version.h
,
Jul 11 2016
,
Sep 1 2016
This is in M54. |
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by falken@chromium.org
, Apr 22 2016