Re: [w3c/ServiceWorker] Questions regarding inevitable nature of performance gains and losses of ServiceWorker (Issue #1667)

- A1: See https://w3c.github.io/ServiceWorker/#motivations and also https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement because ServiceWorkers are not intended to be necessary to use a site (although obviously it is possible, though not advisable or commendable, to structure sites in a way that require ServiceWorkers).

- A2: Specs ideally try to provide implementations as much latitude as possible to optimize, only codifying behavior when necessary to provide consistency in observable behavior and thereby maintaining web compatibility between browsers.  A ServiceWorker that tried to explicitly cache things in memory itself would likely be counter-productive as it would defeat immense swathes of existing browser optimizations (the HTTP cache, the ability to store derived byproducts like the JS bytecode cache and WASM compiled representations that can be stored alongside HTTP cache and Cache API entries, the ability to just send file descriptors between processes and memory map things, various shared memory optimizations) and operating system optimizations (disk caches), plus subject itself to significant resource management pressure that would motivate the browser to reboot the ServiceWorker regularly and/or unload pages associated with it.

- A3: As in A2, the goal is to minimize implementation constraints.  The primary spec mechanism that relates to this is the concept of [agent clusters](https://html.spec.whatwg.org/multipage/webappapis.html#agents-and-agent-clusters).  Service Workers (like Shared Workers) do not exist in the same agent cluster as their controlled pages and so can be placed in the same process or a different process.  In general, it's probably best for a site to assume that if any of its globals crash, it will take down all of the globals and the tab too.  I should also note that, at least in Firefox, which currently does isolate ServiceWorkers in their own processes, we would be likely to mark a ServiceWorker as broken that kept crashing its process or kept using exorbitant amounts of resources and would bypass the ServiceWorker like ctrl-shift-reload is used on subsequent loads.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1667#issuecomment-1398871613
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/issues/1667/1398871613@github.com>

Received on Friday, 20 January 2023 20:05:28 UTC