Closed Bug 1371508 Opened 7 years ago Closed 7 years ago

Lots of time spent maintaining nsDisplayLayerEventRegions on BBC coverage of the UK election

Categories

(Core :: Graphics, enhancement, P3)

53 Branch
enhancement

Tracking

()

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: bzbarsky, Assigned: botond)

References

()

Details

(Keywords: perf, Whiteboard: [gfx-noted])

Attachments

(1 file)

I'm not sure whether the URL will still show anything useful tomorrow...

What I'm seeing going on there is refresh driver ticks thathave a bunch of time under nsLayoutUtils::PaintFrame.

About 1/5 of this code is in pixman_op, adding rects to regions under nsDisplayLayerEventRegions::AddFrame.  Another 1/5 is elsewhere under nsDisplayLayerEventRegions::AddFrame (including under pixman_op); there's malloc/free traffic in there, etc, etc.

I see nothing that would redce the complexity of the regions in question at first glance.  So if we're adding lots of rects to them, we get O(N^2) behavior, right?

Profile is at https://perf-html.io/public/7f7c7b793164acc14d1a73df1fcbd4894bdb2f9b/calltree/?thread=4 and the "Content (3 of 4)" process is the one I'm looking at.

Kats, it looks like you touched this code somewhat recently; do you have time to take a look?
Flags: needinfo?(bugmail)
(In reply to Boris Zbarsky [:bz] (if a patch has no decent message, automatic r-) from comment #0)
> I see nothing that would redce the complexity of the regions in question at
> first glance.  So if we're adding lots of rects to them, we get O(N^2)
> behavior, right?

Basically, yeah. Botond recently added a call to reduce the complexity of the "maybe-hit" regions at [1] but that might not be the one being hit on this page. Botond, do you have cycles to take a look at this one?

The other regions (mHitRegion, mDispatchToContentRegion, etc.) are subject to similar issues as mMaybeHitRegion. While we can simplify the mDispatchToContentRegion outwards without any problem, simplifying the mHitRegion is a little more tricky. For that case we'll have to make sure that we dump the extra area included into the mDispatchToContentRegion so that we don't end up with false-positive results on layer hit tests in the compositor.

[1] http://searchfox.org/mozilla-central/rev/a798ee4fc323f9387b7576dbed177859d29d09b7/layout/painting/nsDisplayList.cpp#4428
Flags: needinfo?(bugmail) → needinfo?(botond)
Keywords: perf
Priority: -- → P3
Whiteboard: [gfx-noted]
I do an SVG map on that page with a bunch of small elements (once for each electoral district in the UK, it seems), and I'm seeing us build dispatch-to-content regions with ~1000 elements. I believe the DTC region, like the maybe-hit region, should be safe to simplify outward.
Assignee: nobody → botond
Flags: needinfo?(botond)
Comment on attachment 8877813 [details]
Bug 1371508 - Simplify the dispatch-to-content region in nsDisplayLayerEventRegions::AddFrame() and AddInactiveScrollPort() if it starts to get large.

https://reviewboard.mozilla.org/r/149230/#review154688
Attachment #8877813 - Flags: review?(tnikkel) → review+
Pushed by bballo@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/cbddc717675d
Simplify the dispatch-to-content region in nsDisplayLayerEventRegions::AddFrame() and AddInactiveScrollPort() if it starts to get large. r=tnikkel
https://hg.mozilla.org/mozilla-central/rev/cbddc717675d
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
That helps a good bit.  The time under nsDisplayLayerEventRegions::AddFrame is now 16% self time, where before it was only 1%.

We still spend a ton of CPU painting on this page, but I'm not seeing other quite-as-obvious-to-me smoking guns.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: