Open
Bug 1336199
Opened 8 years ago
Updated 2 years ago
Allow storing alternate data (ex: JS Bytecode) in the DOM cache
Categories
(Core :: Storage: Cache API, defect, P3)
Core
Storage: Cache API
Tracking
()
NEW
People
(Reporter: asuth, Unassigned)
References
(Blocks 2 open bugs)
Details
Attachments
(4 files, 4 obsolete files)
(deleted),
patch
|
Details | Diff | Splinter Review | |
Bug 1336199 - P2: Keeping alternative body and nsICacheInfoChannel in the InternalResponse. r?bkelly
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review |
Bug 1231565 added support for the HTTP cache to store "alternative data type" streams in support of caching parsed JS representations (serialized in their XDR form) for bug 900784.
DOM cache should plan to support this so sites switching to ServiceWorkers don't experience performance regressions in JS loading versus a fully-HTTP cached site.
The implementation is likely to also be important to WASM in the future since it should allow the compiled form to be opportunistically or explicitly cached along-side the canonical body response. (Currently, our IndexedDB implementation supports storage of compiled WASM modules via structured clone. But this might not end up the standard way to do so... in https://github.com/WebAssembly/design/issues/972#issuecomment-276877682 the Google Chrome team has indicated they've disabled IndexedDB persistence of WASM modules.) WASM is likely to favor directly receiving a file descriptor that could potentially be mmapp'ed rather than a stream, so that should ideally be factored into any implementation changes.
Updated•8 years ago
|
Blocks: ServiceWorkers-perf
Comment 1•8 years ago
|
||
I had some thoughts on this in bug 900784 comment 66.
Updated•8 years ago
|
Priority: -- → P3
Comment 3•7 years ago
|
||
If you need help for the API, Valentin Gosu did the implementation as part of the Necko, and I used it in the ScriptLoader.
If you want to test using the ScriptLoader, you can ask me, or have a look at the test case:
http://searchfox.org/mozilla-central/rev/b258e6864ee3e809d40982bc5d0d5aff66a20780/dom/base/test/test_script_loader_js_cache.html
Comment 4•7 years ago
|
||
Thanks Nicolas,
The testcase indeed helped me a lot in bug 1350359 ;)
Updated•7 years ago
|
Assignee: bhsu → nobody
Updated•7 years ago
|
Assignee: nobody → echuang
Comment 5•7 years ago
|
||
Comment 6•7 years ago
|
||
Comment 7•7 years ago
|
||
Updated•7 years ago
|
Attachment #8919562 -
Attachment description: P3: Save the filenames for alternative data to the datebase → P3: Save the filenames for alternative data to the datebase (WIP)
Comment 8•7 years ago
|
||
Comment 9•7 years ago
|
||
Hi Eden,
Though the patches cannot be applied directly, I believe they still can be used as references and reminder for the discussion we had a couple days ago. In additional to the patches, we still need to plumb the IPDL and modify the implementation of match() to retrieve the saved alternative data from the DOM cache. Besides, we still need a testcase for that, which could be similar to the one in bug 1350359. We just need to save the response carrying the alternative data to DOM cache and retrieve it.
Comment 10•7 years ago
|
||
Reusing the test case in test_script_loader_intercepted_js_cache.html.
In this test, file_js_dom_cache.html will be loaded three times.
For the first time, get the data by fetching from the network, and script loader will save the alternative data into http cache.
For the second time, get the data from http cache by calling fetch again, and ServiceWorkerScript will save the alternative data into the dom cache.
For the third time, get the response from dom cache directly. And the same result with the second time load is expected.
Attachment #8919559 -
Attachment is obsolete: true
Attachment #8919560 -
Attachment is obsolete: true
Attachment #8919562 -
Attachment is obsolete: true
Attachment #8919563 -
Attachment is obsolete: true
Attachment #8943217 -
Flags: review?(bkelly)
Comment 11•7 years ago
|
||
Since alternativeBody and nsICacheInfoChannel will be accessed multiple times when synthesizing the response and saving the data into the dom cache, we need to keep them in InternalResponse.
This patch also supports clone the alternative data and cacheInfoChannel when calling InternalResponse::Clone.
Attachment #8943218 -
Flags: review?(bkelly)
Comment 12•7 years ago
|
||
This patch supports to save the alternative body and nsICacheInfoChannel information while putting request/response pair into the dom cache.
In fact, this patch doesn't save the whole nsICacheInfoChannel into the dom cache, it only saves the needed raw data for loading alternative body by script loader.
Attachment #8943219 -
Flags: review?(bkelly)
Comment 13•7 years ago
|
||
Supports to load saved alternative data and nsICacheInfoChannel information from the dom cache while executing match operations.
CachedCacheInfoChannel is a limited nsICacheInfoChannel implementation for script loader reading the alternative data, since it is hard to restore the real nsICacheInfoChannel without open a real channel.
Attachment #8943220 -
Flags: review?(bkelly)
Comment 14•7 years ago
|
||
I'm sorry I didn't get to this review today. I will do it tomorrow morning.
Updated•7 years ago
|
Assignee: echuang → bkelly
Updated•7 years ago
|
Status: NEW → ASSIGNED
Comment 15•6 years ago
|
||
(In reply to Ben Kelly [:bkelly] from comment #14)
> I'm sorry I didn't get to this review today. I will do it tomorrow morning.
I didn't do it the next morning! I think I can say I won't have time for these reviews. The patches should probably be rebased before review at this point as well.
Updated•6 years ago
|
Attachment #8943217 -
Flags: review?(bkelly)
Updated•6 years ago
|
Attachment #8943218 -
Flags: review?(bkelly)
Updated•6 years ago
|
Attachment #8943219 -
Flags: review?(bkelly)
Updated•6 years ago
|
Attachment #8943220 -
Flags: review?(bkelly)
Updated•6 years ago
|
Assignee: bkelly → nobody
Status: ASSIGNED → NEW
Updated•6 years ago
|
Assignee: nobody → echuang
Comment 16•6 years ago
|
||
General question: if a Response is clone()d and one Response gets stored in the Cache and the other Response is fed to the JS script loader (or, with bug 1487113, WebAssembly.compileStreaming()) and thereby gains alt-data in the HTTP Cache, would the Cache.put() be able to "take" the alt-data from the HTTP Cache so that it doesn't have to be regenerated a second time?
Otherwise, to avoid this recompilation, iiuc, the developer would:
cache.add(url).then(() => fetchEvent.respondWith(cache.match(url)))
which seems a bit sub-optimal.
Updated•6 years ago
|
Priority: P3 → P1
Comment 17•6 years ago
|
||
Talking with Eden, he's not actively working on this but still in his plan.
Priority: P1 → P2
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
Reporter | ||
Updated•5 years ago
|
Component: DOM: Core & HTML → Storage: Cache API
Comment 19•5 years ago
|
||
Example of how much this bug affects apps' start time.
from bug 1593579
Booting my app :
(Hiding the splash and showing GV. All content is delivered by serviceworker):
onFirstComposite
sequence after app-start:
- splash screen duration <1s
- black screen 0.7~3s
- base UI gets rendered (main page ~15k)
- delay ~0.4s
- toolbox UI get rendered (additional JS file ~200k)
onFirstContentfulPaint
sequence after app-start:
- splash screen duration 2
5s (in most cases 23s) - base UI with toolbox UI is ready and visible
Note: that when onFirstContentfulPaint gets triggered, all the app content is ready/compiled - the toolbox UI from the additional JS file has been run and the toolbox UI rendered.
That means that the cost of not having the JS Bytecode cached/ready, means 3 times longer "booting time" for the app.
(tested on 2yr old, mid-range device)
Comment 21•5 years ago
|
||
*correction
onFirstContentfulPaint
sequence after app-start:
splash screen duration is about 3s
Updated•5 years ago
|
Priority: P2 → P3
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•