Closed
Bug 1469640
Opened 6 years ago
Closed 6 years ago
Use GCParallelTask for background sweeping
Categories
(Core :: JavaScript: GC, enhancement)
Tracking
()
RESOLVED
FIXED
mozilla63
Tracking | Status | |
---|---|---|
firefox63 | --- | fixed |
People
(Reporter: jonco, Assigned: jonco)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
38.95 KB,
patch
|
sfink
:
review+
|
Details | Diff | Splinter Review |
For some reason background sweeping has entirely separate infrastructure to our other off-thread work. We should use the same infrastructure for both.
Assignee | ||
Comment 1•6 years ago
|
||
Patch to remove GCHelperState and make background sweeping a GCParallelTask. There's some complication because a single background sweep task can sweep zones from more than one sweep group, so it loops until backgroundSweepZones is empty (in BackgroundSweepTask::run). Checking whether it is still running on the main thread can't be done by checking the GCParallelTask state because this can still report it as running after we return from the method because we drop the helper thread lock at that time. Instead we add a new state variable |done| and make sure we set this to false before starting the task. The alternative was to make all GCParallelTask run() methods start with the helper thread lock held and release it themselves. It would be annoying to make all clients do this though.
Attachment #8986469 -
Flags: review?(sphink)
Comment 2•6 years ago
|
||
Comment on attachment 8986469 [details] [diff] [review] bug1469640-sweep-task Review of attachment 8986469 [details] [diff] [review]: ----------------------------------------------------------------- r=me if that !isBackgroundSweeping() && !done problem isn't a problem. ::: js/src/gc/GCRuntime.h @@ +331,5 @@ > State state() const { return incrementalState; } > bool isHeapCompacting() const { return state() == State::Compact; } > bool isForegroundSweeping() const { return state() == State::Sweep; } > + bool isBackgroundSweeping() { > + return sweepTask.isRunning(); This could return false while !done, right? Is this sequence of events possible: background sweep is running main thread does queueZonesForBackgroundSweep main thread gets to State::Finalize background sweep empties its local copy of the queue, unlocks HelperThreadState main thread checks isBackgroundSweeping()=false (with GC lock held, HelperThreadState lock not held) main thread continues background sweep re-locks HelperThreadState lock and works on the rest of the queue main thread does sweepZones() concurrently with the background sweep -- I assume this is bad @@ +480,5 @@ > // Free certain LifoAlloc blocks when it is safe to do so. > void freeUnusedLifoBlocksAfterSweeping(LifoAlloc* lifo); > void freeAllLifoBlocksAfterSweeping(LifoAlloc* lifo); > > // Public here for ReleaseArenaLists and FinalizeTypedArenas. Please document updateThreshold -- what it is and why it needs to be conditional. Maybe use alreadyDecrementedArenaCount or something? @@ -828,2 @@ > > - private: Why is all this stuff no longer private? Is it because you now need to friend a templatized class? I think that should work.
Attachment #8986469 -
Flags: review?(sphink) → review+
Assignee | ||
Comment 3•6 years ago
|
||
(In reply to Steve Fink [:sfink] [:s:] (PTO June 31) from comment #2) > This could return false while !done, right? No, this is not possible. isRunning() ends up checking GCParallelTask::state_ which is set to Dispatched in GCParallelTask::startWithLockHeld() and remains that way until the run() method returns. > Please document updateThreshold -- what it is and why it needs to be > conditional. I just realised I can move the update into the callers and get rid of this altogether, so I'll do that. > Why is all this stuff no longer private? Is it because you now need to > friend a templatized class? I think that should work. This |private| was unnecessary because we're already in a private section at this point.
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/6867578ac52d Make background sweeping a parallel task and remove GCHelperState r=sfink
Comment 5•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/6867578ac52d
Status: NEW → RESOLVED
Closed: 6 years ago
status-firefox63:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in
before you can comment on or make changes to this bug.
Description
•