Open
Bug 1162497
Opened 10 years ago
Updated 2 years ago
Relazify scripts with inner functions
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
NEW
People
(Reporter: jandem, Unassigned)
References
(Blocks 1 open bug)
Details
(Whiteboard: [MemShrink:P2])
Relazification currently doesn't work for scripts with inner functions or direct eval, because relazifying such functions complicates StaticScopeIter, in particular JSFunction::isHeavyWeight() requires a non-lazy script.
I just instrumented the browser to see how common this is. I opened a bunch of popular websites (Gmail, Facebook, Twitter etc) and looked at the number of scripts we can relazify (across many different GCs):
Can relazify: 290,564 (82.17%)
Can't relazify (inner functions): 62,725 (17.74%)
Can't relaizfy (direct eval): 312 ( 0.08%)
Scripts with inner functions are likely larger (relazifying them is a bigger memory win), so I also looked at the bytecode length:
Can relazify: 36,277,124 bytes (68.50%)
Can't relazify (inner functions): 16,592,780 bytes (31.33%)
Can't relaizfy (direct eval): 88,790 bytes ( 0.16%)
This confirms that even though < 20% of scripts have inner functions, these scripts hold onto > 30% of all bytecode.
| Reporter | ||
Comment 3•10 years ago
|
||
(In reply to Nicholas Nethercote [:njn] from comment #2)
> Jan, any progress here?
I'm not working on this right now. There are a couple of issues:
(1) StaticScopeIter wants to know needsCallObject (was: isHeavyweight) in a number of places and we need a non-lazy script for that. We can't easily delazify there though.. I tried to figure out needsCallObject during syntax parsing but it's complicated. Another solution is to *cache* needsCallObject on the LazyScript the first time we create a JSScript (so LazyScript::needsCallObject would have 3 states: Unknown, True, False). Not super excited about this but it should work.
(2) If we relazify and then delazify a script with inner functions, it could cause duplicate static scope chains: delazifying will create new scope objects but there could still be closures referencing the old ones. Not sure if this is a problem in practice, I'll talk to shu.
Comment 4•10 years ago
|
||
(In reply to Jan de Mooij [:jandem] from comment #3)
>
> (2) If we relazify and then delazify a script with inner functions, it could
> cause duplicate static scope chains: delazifying will create new scope
> objects but there could still be closures referencing the old ones. Not sure
> if this is a problem in practice, I'll talk to shu.
We discussed on IRC. Different JSFunction identities would be observable in Debugger.
I would prefer inner JSFunction identities stay stable across relazification of scripts with inner function. I don't how feasible this is, unfortunately. If the list of inner JSFunctions were preserved in the LazyScript across a relazification, we could re-use them on delazification.
| Reporter | ||
Comment 5•10 years ago
|
||
Unassigning myself for now. This seems hard to get right (see previous comments) and other issues may show up. Right now not worth the effort I think.
Assignee: jdemooij → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(jdemooij)
Comment 6•8 years ago
|
||
Dropping to P2 given the scope of work.
Whiteboard: [MemShrink:P1] → [MemShrink:P2]
Updated•3 years ago
|
Severity: normal → S3
Updated•2 years ago
|
Blocks: sm-frontend
You need to log in
before you can comment on or make changes to this bug.
Description
•