Allow caching JS loaded with loadSubScript

RESOLVED FIXED in mozilla8

Status

()

Core
XPConnect
RESOLVED FIXED
6 years ago
4 years ago

People

(Reporter: mossop, Assigned: mwu)

Tracking

({dev-doc-complete})

Trunk
mozilla8
dev-doc-complete
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite ?

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 5 obsolete attachments)

(Reporter)

Description

6 years ago
Either directly or with a new API we could do with a means of caching JS loaded through loadSubScript, see bug 648124 for a prime use.
(Reporter)

Updated

6 years ago
OS: Mac OS X → All
Hardware: x86 → All
(Assignee)

Comment 1

6 years ago
Created attachment 524525 [details] [diff] [review]
WIP: Cache subscripts in startupcache

Patch based on tracemonkey tip. Needs a bit more cleanup but it should work if someone wants to take this and measure how much time we save on bootstrap.js when cached.
Assignee: nobody → mwu
(Assignee)

Comment 2

6 years ago
Created attachment 527150 [details] [diff] [review]
Cache subscripts in startupcache

This one passes tests.
Attachment #524525 - Attachment is obsolete: true
(Assignee)

Updated

6 years ago
Depends on: 481603
Thank you, I've been meaning to file this bug for weeks.

This is also important for Jetpack, which loads *all* of its scripts (including the SDK) via evalInSandbox.
(Assignee)

Comment 4

6 years ago
Created attachment 538661 [details] [diff] [review]
Cache subscripts in startupcache, v2

Updated based on patches in bug 592943
Attachment #527150 - Attachment is obsolete: true
(Assignee)

Comment 5

6 years ago
(In reply to comment #3)
> Thank you, I've been meaning to file this bug for weeks.
> 
> This is also important for Jetpack, which loads *all* of its scripts
> (including the SDK) via evalInSandbox.

Oh yeah, jetpack was one of the reasons I worked on this. Are you working on/looking at jetpack startup perf? I can get you a build with caching so you can see how much it helps jetpack if you want to do some measurements.
(Assignee)

Updated

6 years ago
Depends on: 592943
(Reporter)

Comment 6

6 years ago
Once bug 481603 is fixed I wonder if there might be a bunch of benefits in switching jetpack to use modules where possible to save multiple add-ons using the same version of the SDK having to load the same script multiple times. Would have to be some careful manual refcounting or something to make it useful though I guess
(Assignee)

Comment 7

6 years ago
Created attachment 539104 [details] [diff] [review]
Cache subscripts in startupcache, v3

New version which is dependent on the cache invalidation stuff in bug 481603.
Attachment #538661 - Attachment is obsolete: true
(Assignee)

Comment 8

6 years ago
Created attachment 539408 [details] [diff] [review]
Cache subscripts in startupcache, v4
Attachment #539104 - Attachment is obsolete: true
(Assignee)

Comment 9

6 years ago
Created attachment 543034 [details] [diff] [review]
Cache subscripts in startupcache, v5

Remove some unused includes.
Attachment #539408 - Attachment is obsolete: true
Attachment #543034 - Flags: review?(jst)
Comment on attachment 543034 [details] [diff] [review]
Cache subscripts in startupcache, v5

Looks good, and with this I think you can remove the static ReadScriptFromStream() and WriteScriptToStream() functions from mozJSComponentLoader.cpp too!

r=jst with that.
Attachment #543034 - Flags: review?(jst) → review+
(Assignee)

Comment 11

6 years ago
Opps. Guess I completely forgot to remove the original function while trying to move it.

Testing on try, will push to m-i once things look ok on try. http://tbpl.mozilla.org/?tree=Try&rev=d36f38e6c687
(Assignee)

Comment 12

6 years ago
http://hg.mozilla.org/integration/mozilla-inbound/rev/cb5d55ec3e5d
Whiteboard: [inbound]
Merged:
http://hg.mozilla.org/mozilla-central/rev/cb5d55ec3e5d
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Flags: in-testsuite?
Resolution: --- → FIXED
Whiteboard: [inbound]
Target Milestone: --- → mozilla8
What release will this land in? It needs to be documented.
Keywords: dev-doc-needed
(Assignee)

Comment 15

6 years ago
Firefox 8, as noted in target milestone.

This is just an optimization. Developers don't need to do anything about this.
(Assignee)

Updated

6 years ago
Duplicate of this bug: 648124
They do. The various script loading methods are listed on MDC, along with their advantages and disadvantages. The fact this now supports caching can be both an advantage and a disadvantage over other methods, depending on their purposes (especially for developers who rely on getting a fresh load of the script each time it's called).
:kmag updated the docs here:

https://developer.mozilla.org/en/XPCOM_Interface_Reference/mozIJSSubScriptLoader#loadSubScript%28%29

I've added a mention to Firefox 8 for developers.
Keywords: dev-doc-needed → dev-doc-complete

Comment 19

6 years ago
(In reply to comment #18)
> :kmag updated the docs here:
> 
> https://developer.mozilla.org/en/XPCOM_Interface_Reference/
> mozIJSSubScriptLoader#loadSubScript%28%29
> 
> I've added a mention to Firefox 8 for developers.

How I can disable caching JS for debugging?

The following settings seems nothing effect.
user_pref("nglayout.debug.disable_xul_fastload", true);
user_pref("nglayout.debug.disable_xul_cache", true);
Depends on: 736519

Updated

4 years ago
No longer blocks: 648124
Depends on: 821726
You need to log in before you can comment on or make changes to this bug.