On 7/30/13 3:30 AM, Simon Sapin wrote:
a. A CSS representation of the whole selector list a a string, for the
CSSOM’s selectorText
b. The specificity for the cascade
c. Just the data structures we need for matching
I think this would work, but maybe the cost of a. cancels whatever we
gain in c.?
Well, (a) would increase memory usage but it could be pretty cold memory
so shouldn't affect things like cache pressure and whatnot...
It's worth measuring how much the string in "a" would be (esp. if we
store it in UTF-8 or something?), as well as measuring how much memory
Gecko's current selectors take.
1) The linked list for SelectorList leads to lots of cache misses as we
traverse it, last we measured.
Would using a vector rather than a linked list fix that?
Possibly.
The other big source of cache misses I recall, by the way, is the
merging loop in RuleHash::EnumerateAllRules...
How about, instead of a big Selector struct, having a "list of simple
selectors"? This list does not have to be in CSS source order, it could
be reordered in a way that makes matching more convenient (eg. ID
selectors first.)
Fwiw, I _think_ this is more like how WebKit does it last I looked.
struct Selector {
compound_selectors: ~[CompoundSelector],
An interesting question here is how long typical lists of compound
selectors are and whether it's worth trying to do some auto-array-like
thing with an inline buffer for some small size here.
struct CompoundSelector {
simple_selectors: ~[SimpleSelector],
Likewise.
enum SimpleSelector {
Might need to be a little careful about how big a SimpleSelector can end
up; looks like two machine words to handle the LocalNameSelector case,
right? Can we do anything larger out-of-line or something?
In any case, this is more like what we were thinking of, I think.
If I can make a recommendation: instrument a Gecko build with logging
information about selectors and do some measuring/recording of what
selectors we see as you browse for a while. Then we can actually get
some answers on what the memory tradeoffs are here, say, as well as
frequencies at which various constructs are seen and whatnot.
-Boris
_______________________________________________
dev-servo mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-servo