Closed Bug 1093307 Opened 11 years ago Closed 11 years ago

OOM calls ShrinkGCBuffers, but ShrinkGCBuffers does its work off-main-thread

Categories

(Core :: JavaScript: GC, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: terrence, Assigned: terrence)

References

(Blocks 1 open bug)

Details

(Whiteboard: [MemShrink:P2])

Attachments

(3 files)

ShrinkGCBuffers is an API called by gecko occasionally to do decommit: this happens off-main-thread and does not block, so effectively has no effect on the main thread. However, the OOM path in JSRuntime is trying to use it to free memory before re-allocating. We need a new API here that works on the main thread to synchronously toss everything that isn't nailed down.
Whiteboard: [MemShrink]
Ah, actually looks like onOOM calls waitForBackgroundSweepOrAllocEnd -- didn't know that was public(!) -- so it's not actually totally busted. Still there's a ton more stuff we could be tossing here.
There is more to do here. In particular we should not have to do racy tricks with the bg thread, or involve another thread at all here. This is an acceptable first step though.
Attachment #8516802 - Flags: review?(jcoppeard)
And it looks like there's another serious facepalm with the shrinking GCs we trigger from the browser's low-memory signal. We currently do a full, non-incremental GC, then return to the mutator and sweep everything on the background thread. Of course, this means we'll only ever finish this work and actually free up memory far later, probably long after the browser has OOM'ed.
Attachment #8516851 - Flags: review?(jcoppeard)
Attachment #8516802 - Flags: review?(jcoppeard) → review+
Comment on attachment 8516851 [details] [diff] [review] 1_shrink_harder-v0.diff Review of attachment 8516851 [details] [diff] [review]: ----------------------------------------------------------------- This is ok but we may need to change this again if we want to enable incremental compacting GC. ::: js/src/jsgc.cpp @@ +5024,5 @@ > > + sweepOnBackgroundThread = !lastGC && > + !TraceEnabled() && > + CanUseExtraThreads() && > + !shouldCompact() && shouldCompact() will return turn only if invocationKind == GC_SHRINK so this line is unnecessary with this change.
Attachment #8516851 - Flags: review?(jcoppeard) → review+
This probably also wants to do unconditional decommit on the foreground.
Keywords: leave-open
This adds a trivial decommit loop for use by the OOM path so that we don't have to rely on the expireChunksAndArenas viper-pit. This also unlocks a nice follow-up: now if we want to use a Vector to pass chunks to do background decommit, we can can fall back to this path on OOM to do the decommit in the foreground.
Attachment #8517724 - Flags: review?(jcoppeard)
Attachment #8517724 - Flags: review?(jcoppeard) → review+
Keywords: leave-open
Whiteboard: [MemShrink] → [MemShrink:P2]
The build error was fixed in the other bug, so I think this should be fine now. https://hg.mozilla.org/integration/mozilla-inbound/rev/d2603e86d422
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: