Consider sharing declaration blocks for SVG mapped attributes.
Categories
(Core :: SVG, enhancement, P3)
Tracking
()
People
(Reporter: emilio, Unassigned)
References
()
Details
(Keywords: perf)
| Reporter | ||
Comment 1•8 years ago
|
||
Comment 2•7 years ago
|
||
Updated•7 years ago
|
Comment 3•7 years ago
|
||
After looking into some of the details, I'm not sure if we should do this optimization.
Some of the observations:
- If an element (regardless of SVG or not) has presentation hint, it has an associated
DeclarationBlockdeclaring all its hints.Gecko_GetHTMLPresentationAttrDeclarationBlockhttps://searchfox.org/mozilla-central/source/servo/components/style/gecko/wrapper.rs#1788 nsHTMLCSSStyleSheetis for inline style, it essentially shares a commonDeclarationBlockfor elements if they have the same string instyle="...". Some glue code:Gecko_GetStyleAttrDeclarationBlockhttps://searchfox.org/mozilla-central/source/servo/components/style/gecko/wrapper.rs#1272
So if we want to do the same for SVG presentation hint, we should share a DeclarationBlock for every individual property when they have the same value. (in that case, probably we will be caching a Declaration? since it only has 1 property, not a block...).
The concerns are:
-
It will cause many SVG elements have multiple
DeclarationBlock, one for each presentation hint, will this cause perf problem? -
The ultimate goal is to avoid constructing new
DeclarationBlockfor every SVG element. But the above method doesn't fit well with geometry property, sincex,y, etc. values can rarely be shared. If many elements have different geometry properties, we'll be constructing more blocks than before.
I think the second case is more concerning, since in the testcase, we actually take advantage of x, y in <use> not being geometry property per current spec. If they were geometry property, then the optimization would just become useless. Actually Chrome has implemented x, y as geometry property for <use>, I think that might be a big part of the reason that Chrome is slower than us.
Emilio, what do you think?
Comment 4•7 years ago
|
||
Also, the workaround in current implementation is trivial: replacing repeating attributes with inline CSS style. e.g. overflow="visible" => style="overflow:visible"
| Reporter | ||
Comment 5•7 years ago
|
||
(In reply to violet.bugreport from comment #3)
- It will cause many SVG elements have multiple
DeclarationBlock, one for each presentation hint, will this cause perf problem?
Yeah, that wouldn't be great.
- The ultimate goal is to avoid constructing new
DeclarationBlockfor every SVG element. But the above method doesn't fit well with geometry property, sincex,y, etc. values can rarely be shared. If many elements have different geometry properties, we'll be constructing more blocks than before.
Right, that's only useful for massive copies of shadow trees or such.
I think the second case is more concerning, since in the testcase, we actually take advantage of
x,yin <use> not being geometry property per current spec. If they were geometry property, then the optimization would just become useless. Actually Chrome has implementedx,yas geometry property for <use>, I think that might be a big part of the reason that Chrome is slower than us.
I don't follow this? This will surely make the optimization not apply to the <use> elements, but that's fine, the optimization would still apply to all the linked elements, wouldn't it?
Emilio, what do you think?
Would have to implement it and measure, but I suspect this may not be worth the effort.
Comment 6•7 years ago
|
||
I don't follow this? This will surely make the optimization not apply to the <use> elements, but that's fine, the optimization would still apply to all the linked elements, wouldn't it?
Yeah, I shouldn't have described it as "useless", I actually meant "not-that-impressive". Because in that case, if N <use> elements are used, we at least needs N blocks. For large N, this hard limit is already slow enough to provide a smooth user experience as in the current testcase.
Actually, I was impressed yesterday by the drastic improvement after using s/overflow="visible"/style="overflow:visible"/. But now it seems to be only applicable to some very specific and localized situations. Unassigned... Presumably it's a WONTFIX...
Comment 7•7 years ago
|
||
Description
•