Closed Bug 244975 Opened 21 years ago Closed 8 years ago

Deeply nested hierarchies are too slow (GetOwnerSVGElement, GetCTM & GetScreenCTM)

Categories

(Core :: SVG, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: alex, Unassigned)

References

Details

(Keywords: perf)

I did some profiling on adding an svg elements to deeply nested groups. For my debug build I get (0.143 +/- 0.006) ms for adding a <circle> to a single <svg> element and (3.103 +/- 0.090) ms for adding a <circle> to the innermost element in a tree of 1000 <g>'s. In fact the time grows linearly with the nesting level. The most likely culprit is our implementation of GetOwnerSVGElement() which gets called by most graphics elements when the parent chain changes (e.g. when they get appended to other content). The current implementation of that method just walks the parent chain until it encounters the owner svg element. I think we should change it so that for non-container elements it calls GetOwnerSVGElement() on its parent and for container elements (<g>) it returns a cached pointer. The same goes for GetCTM and GetScreenCTM.
The situation is even worse on deleting. Deleting an <svg>-element scales quadratically with the number of nested elements it contains :-(
Assignee: alex → jonathan.watt
Status: NEW → ASSIGNED
Keywords: perf
Is this a big problem in real life? That is, do SVG trees commonly get this deep?
No, SVGs tend to be relatively shallow (depth<<10), so I don't think this is a significant factor in practice.
Assignee: jonathan.watt → general
Status: ASSIGNED → NEW
Depends on: 408147
Assignee: general → nobody
QA Contact: ian → general
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.