When a JaegerCompartment is created, it always generates some code immediately in the TrampolineCompiler, which involves mapping 64KB of executable memory (64KB is the minimum code chunk size). This shouldn't be necessary for atomsCompartment. It should be easy to add a boolean flag |hasCode| somewhere to JaegerCompartment and avoid this for atomsCompartment. A small win but an easy one.
We're also allocating 186,000 bytes worth of space for trace JIT data, which is unnecessary for the atomsCompartment. And probably a bit more for various heap allocations done in TraceMonitor::init(). We should avoid that too.
This idea can be extended. Some compartments have tiny amounts of JS code in them which never gets method JITted and/or trace JITted (eg. techcrunch.com's front page has dozens of them). Doing lazy initialization/allocation of the relevant code and data chunks could save quite a bit of space.
Thanks for pointing me to this Nick. bug 650411 should help a lot since both in theory can be hoisted to the (single-threaded) JSRuntime (which should be very few in number).
(In reply to comment #3) > Thanks for pointing me to this Nick. bug 650411 should help a lot since > both in theory can be hoisted to the (single-threaded) JSRuntime (which > should be very few in number). The entire JaegerCompartment and TraceMonitor could be hoisted? That'd be very nice.
Yep (the comment for JaegerCompartment explains that all it wants is single-threadedness).
Luke, it sounds like a single-threaded JSRuntime won't happen soon. Assuming that's right, I'll go ahead with this bug, because my per-compartments patch for about:memory shows that it's really easy to get dozens and dozens of tiny compartments, and the thought of wasting 0.25MB on each one is giving me an ulcer.
Created attachment 540002 [details] [diff] [review] make TraceMonitor lazy This patch does the TraceMonitor. Here's an example from about:memory: │ └──────65,536 B (00.14%) -- compartment(atoms) │ ├──65,536 B (00.14%) -- mjit-code │ ├───────0 B (00.00%) -- scripts │ ├───────0 B (00.00%) -- mjit-data │ ├───────0 B (00.00%) -- tjit-code │ └───────0 B (00.00%) -- tjit-data │ ├──0 B (00.00%) -- allocators-main │ └──0 B (00.00%) -- allocators-reserve 186,000 bytes down, 65,536 to go. I'll do the patch for the JaegerCompartment on Monday.
(In reply to comment #7) > > 186,000 bytes down Actually, on 64-bit it's more like 256KB because there are various other things (most notably the TraceNativeStorage) in the TraceMonitor that aren't captured in the memory reporters. On 32-bit it's a bit less.
Comment on attachment 540002 [details] [diff] [review] make TraceMonitor lazy Nice; ulcers are bad.
I've narrowed the focus of this bug just to TraceMonitor; JaegerCompartment is now covered by bug 665404.
Landed with a follow-up to fix some --disable-tracejit bustage: http://hg.mozilla.org/tracemonkey/rev/1e464e38591e http://hg.mozilla.org/tracemonkey/rev/57ef3b619966
cdleary-bot mozilla-central merge info: http://hg.mozilla.org/mozilla-central/rev/1e464e38591e http://hg.mozilla.org/mozilla-central/rev/57ef3b619966 Note: not marking as fixed because fixed-in-tracemonkey is not present on the whiteboard.