Closed Bug 1555199 Opened 6 years ago Closed 6 years ago

looping based on isIncrementalGCInProgress is unreliable

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla69
Tracking Status
firefox69 --- fixed

People

(Reporter: sfink, Assigned: sfink)

Details

Attachments

(1 file)

I ran into this as a result of my "Set gcLastSweepGroupIndex earlier" patch in bug 1167452.

Anyway, consider https://searchfox.org/mozilla-central/rev/7556a400affa9eb99e522d2d17c40689fa23a729/js/src/jsapi-tests/testWeakMap.cpp#100-102

I am getting a case where the GC is mostly done, in the Finalize state. When debugGCSlice runs, it finishes that GC off and starts a new one. Then when it compares sweep group indexes, the old code never cleared the indexes and hasn't yet set new ones, so it works. The new code clears them out when starting a new GC.

So the question is, should this be using finishGC if it wants to finish the GC? In that case, the new code is fine; it won't restart the GC so it still has access to the previous GC's indexes.

Or do we want to say that the loop should be a valid way to finish up a GC (without starting a new one)? I haven't worked out what the minimal change would be for that.

(In reply to Steve Fink [:sfink] [:s:] from comment #0)

When debugGCSlice runs, it finishes that GC off and starts a new one.

Why does this happen? I would have thought it just finished the current one.

So the question is, should this be using finishGC if it wants to finish the GC?

Yes, that would be clearer than looping so I think we should do that.

(In reply to Jon Coppeard (:jonco) from comment #2)

(In reply to Steve Fink [:sfink] [:s:] from comment #0)

When debugGCSlice runs, it finishes that GC off and starts a new one.

Why does this happen? I would have thought it just finished the current one.

I think I fooled myself into misinterpreting this.

I was looking at the GC number to determine which GC I was looking at. But that is also incremented for minor GCs; I should have been looking at the major GC number. (Well, I was also basing it off of when the zone's sweep group index was being reset, but that was buggy -- see below.)

Though in stepping through this, one thing seems a little problematic -- while we are in the part of an incremental GC where we wait for first background finalization and then decommitting, we're constantly doing nursery collections and thus expensively tenuring everything. shouldCollectNurseryForSlice explicitly returns true for Finalize and Decommit -- why is that? (needinfo pbone for that.)

The real bug is in how I was clearing the zone's sweep group index. I hadn't realized that zones get constantly scheduled and unscheduled during an incremental GC. I was clearing it during scheduling. So while the patch here is probably fine to land, it won't fix what I was working on.

Flags: needinfo?(pbone)

(In reply to Steve Fink [:sfink] [:s:] from comment #3)

Though in stepping through this, one thing seems a little problematic -- while we are in the part of an incremental GC where we wait for first background finalization and then decommitting, we're constantly doing nursery collections and thus expensively tenuring everything. shouldCollectNurseryForSlice explicitly returns true for Finalize and Decommit -- why is that? (needinfo pbone for that.)

Because I didn't understand them at the time I wrote that code and was playing it safe. We can fix that (Bug 1555558).

Flags: needinfo?(pbone)
Pushed by sfink@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d8b0efeaaa35 Use finishGC to finish a GC instead of looping r=jonco
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla69
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: