-
Notifications
You must be signed in to change notification settings - Fork 470
Pass sameZoneAs to sandbox constructor to make GCs cheaper #325
Comments
Thanks for the tip. Apparently this option was not documented until last Jan 2015, so this might explain why it was not used originally. What specific entry in |
That's the global zone where all the chrome/browser.xul/addon/framescript stuff lives by default. The tab-specific zones are listed under explicit -> window-objects |
Using uBlock (from where uMatrix's Firefox-specific code mostly come from), I measured the effect of using
|
yes, ideally it will have the following effects a) the window and the sandbox can be discarded together, i.e. without having to GC the system zone In practice those benefits may not be fully realized because there can be references crossing zone boundaries, keeping objects alive longer than necessary. That can be further improved by either using weak references for anything pointing into the sandbox or by nuking the sandbox if you're holding onto a reference to it somewhere. I see that you're registering message manager callbacks and have them point into the sandbox (I think?). Maybe using weak listeners would be appropriate there if the callbacks are kept alive by a field in the sandbox anyway. But that's a second step, separating the zones might already provide some good improvement. |
According to
about:memory
µMatrix sandboxes all seem to live within the same zone (in process/remote tab child global, depending on e10s).As I understand it this has a negative impact on GC performance since allocations by scripts loaded into those sandboxes triggers GCs in this fairly large zone instead of GCing in a window-specific zone. I would guess that the the cross-zone references are also be more expensive.
This can be mitigated by using the sameZoneAs option.
The addon SDK does this for its sandboxes, so it's probably best practice.
The text was updated successfully, but these errors were encountered: