Open Bug 1179894 Opened 9 years ago Updated 2 years ago

Optimize ghost windows out of the CC graph

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

Tracking Status
firefox42 --- affected

People

(Reporter: mccr8, Unassigned)

References

(Blocks 2 open bugs)

Details

Attachments

(2 files, 1 obsolete file)

Ghost windows cause horrible performance problems due to the CC, and probably are not going to go away, so we should just optimize them out of the CC graph. We may want to add them back to the graph occasionally, say once every 10 minutes, in case the window really did go away.
This is a dup of some old bug, which never got fixed since we in general have had ghost windows somewhat rarely. Lately couple of regressions though.
Blocks: GhostWindows
Also, remove a redundant null check of |window| and move a comment.

MozReview-Commit-ID: 6E8J4f5l7Q5
Here's an untested patch. It adds a flag to inner windows that indicate if the ghost window detector thought it was a ghost window the last time it ran. Then it adds code to nsCCUncollectableMarker::Observe() that marks any windows that have the ghost window flag set as uncollectable. I don't know if that's enough to clear out the CC graph to a reasonable extent.
Attachment #8941235 - Attachment is obsolete: true
I tested this by making all nsGlobalWindowInners leak forever, opening the HTML5 spec, then closing the tab. My earlier version had a minor bug, plus I changed it to mark the document in the ghost window, rather than the window. I think that's better, though I guess we could leak an inner window without a document.

You can see here what happens when the ghost window detector notices that the spec page is leaking:
CC(T+97.5)[content-21748] max pause: 49ms, total time: 241ms, slices: 6, suspected: 3, visited: 352061 RCed and 11631 GCed, collected: 0 RCed and 0 GCed (0|0|0 waiting for GC)
CC(T+157.3)[content-21748] max pause: 4ms, total time: 4ms, slices: 1, suspected: 11, visited: 196 RCed and 4703 GCed, collected: 0 RCed and 0 GCed (0|0|0 waiting for GC)

The total time goes from 241ms to 4ms.
My patches here cause intermittent leaks in the bc mochitests:
  https://treeherder.mozilla.org/#/jobs?repo=try&revision=7af94973ff5c5bd322b0dc00043421c906c49ced

The bc leak detector forces GCs and CCs, which I think makes things get marked as a ghost faster than they would be normally, so maybe that interferes with things. It is also possible that there are similar problems in other test suites, but they don't show up as leaks because we don't run these optimizations on shutdown, so they won't show up in the normal leak detector.
perhaps numGhostSkips should be based on timestamp and not counter?
Blocks: 1450430
Priority: -- → P3
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: