Open Bug 1480477 Opened 6 years ago Updated 3 months ago

Removing DOM children where positional pseudo-classes are involved is really slow.

Categories

(Core :: CSS Parsing and Computation, defect, P2)

defect

Tracking

()

Performance Impact medium

People

(Reporter: emilio, Unassigned)

References

(Depends on 1 open bug, Blocks 3 open bugs)

Details

(Keywords: perf:responsiveness, Whiteboard: [layout:backlog:quality])

Attachments

(1 file)

Attached file Testcase.
See the test-case. Change firstChild by lastChild to make it twice as fast. That being said, we're still pretty slow even with that... Need to look at what other engines are doing. See bugs related to bug 1443066 for another more fine-grained invalidation that would make this cheaper, maybe.
Flags: needinfo?(emilio)
Repurposing because we're really slow even with that fixed... :(
Summary: Expansion of LaterSiblings hints can make removal of children O(n^2) → Removing DOM children where positional pseudo-classes are involved is really slow.
Blocks: 1480746
[setting this to p1 since it seems important & to get it out of triage queue -- feel free to adjust if you think that's higher priority than is merited though.]
Priority: -- → P1
Depends on: 1406622
Whiteboard: [qf]
Whiteboard: [qf] → [qf:p1:f67]
Whiteboard: [qf:p1:f67] → [qf:p1:f67][layout:p1]

--> categorizing as "responsiveness", given that this was from a dynamic-adding/removing-elements part of a benchmark (bug 1443066). And bumping to qf:p2 since qf:p1 is now reserved for pageload.

Whiteboard: [qf:p1:f67][layout:p1] → [qf:p2:responsiveness][layout:p1]
See Also: → 1523028
Flags: needinfo?(emilio)

(Just putting it further up in the ni? queue, sorry for the spam)

Flags: needinfo?(emilio)
Blocks: 1524787
Depends on: 1533963
Blocks: 1569292
Priority: P1 → P2
Whiteboard: [qf:p2:responsiveness][layout:p1] → [qf:p2:responsiveness][layout:backlog:quality]
Performance Impact: --- → P2
Whiteboard: [qf:p2:responsiveness][layout:backlog:quality] → [layout:backlog:quality]
Severity: normal → S3
Depends on: 1899597

So I don't think bug 1899597 is great long-term... For the purposes of :nth-* child, maybe we should try to defer invalidation until the next style flush... David, do you know if there's any :has() style invalidation correctness issue that we could hit?

In any case it seems we should at least coalesce the sibling walking (even if that means removing the SlowSelectorLaterSiblings stuff? not sure)

Flags: needinfo?(emilio) → needinfo?(dshin)

My initial concern was :has(:nth-child(..)) pushing up the restyle root, but :emilio pointed out to me that we already do something similar to it here. At least, it seems viable to hook into that mechanism for :has(:nth-child(...)) upwards invalidation.

Invalidating in RestyleManager has been source of correctness/perf issues for :has() as well, so this seems worth a shot.

Flags: needinfo?(dshin)
Blocks: 1502334
No longer blocks: 1502334
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: