Closed Bug 681815 Opened 13 years ago Closed 12 years ago

Release more regenerable data on GC

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: mfinkle, Assigned: gwagner)

Details

(Keywords: memory-footprint, mobile, Whiteboard: [MemShrink:P2][mentor=nnethercote@mozilla.com])

Can we add support for freeing caches, like JIT, in response to a "memory-pressure" notification? On Android, when the app goes into the background, we send the "memory-pressure" notification in an effort to dump as much memory as possible. If we use too much memory in the background, Android will kill the application if more memory is required by a different task.

See bug 675259 for other details.

We seem to do a cycle collection and a GC currently:

http://mxr.mozilla.org/mozilla-central/source/dom/base/nsJSEnvironment.cpp#192

I don't know if that is all we can do or if we can drop more memory.
Whiteboard: [MemShrink]
Keywords: footprint, mobile
OS: Linux → All
Hardware: x86 → All
Whiteboard: [MemShrink] → [MemShrink][mentor=nnethercote@mozilla.com]
AFAIK, TI purges all code when on GC, so with TI landed, this is already done. Brian, is that right?
mjit code is now purged on GC, but there are other caches we don't clear on every GC.  (TI-related ones are the observed type sets for scripts and lazily constructed type objects, and there are non-TI-related ones like regexp data etc.).  Also, the jitcode is only purged if TI is enabled (it is not valid to throw away jitcode for stock JM if a script has frames on the stack), and it is currently disabled on ARM.
Summary: Free caches in response to a 'memory-pressure' notification → Release JIT code in response to a 'memory-pressure' notification
Whiteboard: [MemShrink][mentor=nnethercote@mozilla.com] → [MemShrink:P1][mentor=nnethercote@mozilla.com]
Lets add a telemetry probe that measure how much memory is released on memory-pressure
(In reply to Brian Hackett from comment #2)
> mjit code is now purged on GC, but there are other caches we don't clear on
> every GC.  (TI-related ones are the observed type sets for scripts and
> lazily constructed type objects, and there are non-TI-related ones like
> regexp data etc.).  Also, the jitcode is only purged if TI is enabled (it is
> not valid to throw away jitcode for stock JM if a script has frames on the
> stack), and it is currently disabled on ARM.

Does it make sense to clear those other caches on every GC? On ARM only, maybe?

How close are we to having TI running on ARM? That's supposed to be coming, so we shouldn't have to do anything for jitcode there.
(In reply to David Mandelin from comment #4)
> Does it make sense to clear those other caches on every GC? On ARM only,
> maybe?

I think we should be aggressive about throwing away regenerable data on GC, regardless of platform.  In circumstances where throwing away data has a significant (and measured) associated cost, it doesn't need to *always* be discarded but should still be thrown away as early as we can bear it (every N seconds during a GC, say).
Gregor, could you look into what we can gain here and what it would take to fix this?
Assignee: general → anygregor
I see two paths here:

- With TI enabled, we just have to worry about these other caches (see comment 2).  In which case we can probably downgrade the priority on this bug.

- On ARM, we still have to worry about this.  What's the status of TI for ARM?  If it will land soon, we can downgrade this bug entirely.
TI is on by default on ARM now.
In that case, I'm retitling and re-prioritizing this.

What's in the list of regenerable stuff?

- TI-related ones are the observed type sets for scripts and lazily constructed type objects
- Regexp data etc (bug 673274 covers this?)
- Property tables.

Anything else?
Summary: Release JIT code in response to a 'memory-pressure' notification → Release more regenerable data on GC
Whiteboard: [MemShrink:P1][mentor=nnethercote@mozilla.com] → [MemShrink:P2][mentor=nnethercote@mozilla.com]
This is kind of being done in a piecemeal fashion, largely by bhackett, so I don't think we need this bug open.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.