Closed
Bug 523288
Opened 15 years ago
Closed 15 years ago
[FIX]Speed up RuleProcessorData ctor and SelectorMatches a bit
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
Details
Attachments
(4 files, 4 obsolete files)
5.64 KB,
patch
|
Details | Diff | Splinter Review | |
14.52 KB,
patch
|
Details | Diff | Splinter Review | |
13.82 KB,
patch
|
Details | Diff | Splinter Review | |
22.14 KB,
patch
|
Details | Diff | Splinter Review |
See the "RuleProcessorData and performance" thread in .layout.
I decided to go with a fairly conservative fix, in the end; just moving the obvious expensive stuff out of the constructor and reorganizing code a tad.
Assignee | ||
Comment 1•15 years ago
|
||
I also changed the class/id matching to just return PR_FALSE when not matching instead of lugging |result| around. We might want to do a followup to get rid of |result| elsewhere too, but the attr matching was a bit daunting in that respect. ;)
Assignee | ||
Comment 2•15 years ago
|
||
Attachment #407208 -
Flags: review?(dbaron)
Assignee | ||
Comment 3•15 years ago
|
||
Main changes here:
1) Not writing most of the members twice in the ctor. Those movl calls were
showing up all over in the assembly. Moving some more member init into our
lazy getters.
2) Not trying to get classes/id if we have no attributes; as long as we're
getting the attr count anyway, we might as well do this. Most nodes have no
classes/ids.
3) Adding mIsHTML to the RuleProcessorData, since we need this for the common
case of tag selectors.
4) Using mParentContent in a few places where for some reason we weren't.
Attachment #407209 -
Flags: review?(dbaron)
Assignee | ||
Comment 4•15 years ago
|
||
For reference, these give me about a 20% speedup or so on http://www2.webkit.org/perf/slickspeed/ (goes from 620ms to 500ms or so on my hardware) for the querySelector column.
Assignee | ||
Updated•15 years ago
|
Attachment #407207 -
Flags: review?(dbaron)
Assignee | ||
Comment 5•15 years ago
|
||
Attachment #407209 -
Attachment is obsolete: true
Attachment #407321 -
Flags: review?(dbaron)
Attachment #407209 -
Flags: review?(dbaron)
Assignee | ||
Comment 6•15 years ago
|
||
I just realized that part 1 means I should perhaps remove this comment in SelectorMatches:
// The selectors for which we set node bits are, unfortunately, early
// in this function (because they're pseudo-classes, which are
// generally quick to test, and thus earlier). If they were later,
// we'd probably avoid setting those bits in more cases where setting
// them is unnecessary.
David, thoughts?
Comment 7•15 years ago
|
||
Comment on attachment 407208 [details] [diff] [review]
Part 2. Main guts of the speed improvement: get mLinkState/mIsLink/mContentState lazily
I had to make one of the assertions in SelectorMatches use LinkState() instead of mLinkState to make this compile in a DEBUG build.
Assignee | ||
Comment 8•15 years ago
|
||
Yeah, I think I might have made that change locally after posting the patches... :(
Assignee | ||
Updated•15 years ago
|
Summary: Speed up RuleProcessorData ctor and SelectorMatches a bit → [FIX]Speed up RuleProcessorData ctor and SelectorMatches a bit
Comment on attachment 407207 [details] [diff] [review]
Part 1. Move class/id matching earlier in SelectorMatches.
>+ if (!elementClasses->Contains(classList->mAtom, isCaseSensitive ? eCaseMatters : eIgnoreCase)) {
Could you wrap this line at under 80 characters?
r=dbaron with that
Attachment #407207 -
Flags: review?(dbaron) → review+
Comment on attachment 407208 [details] [diff] [review]
Part 2. Main guts of the speed improvement: get mLinkState/mIsLink/mContentState lazily
Maybe the |protected| section you're adding to should actually be
|private|?
Also, the comment for mGotIsLink should say it applies to both mIsLink
and mLinkState. (Maybe it should have a more neutral name?)
Maybe it's better not to initialize mIsLink and mContentState in the
constructor? Then valgrind would catch failure to initialize. (Not
sure which is faster, though; initializing big swaths could be faster.)
If you do, though, you need to change the assertion in LinkState to
check mGotIsLink (and perhaps you should anyway).
r=dbaron
Attachment #407208 -
Flags: review?(dbaron) → review+
Attachment #407321 -
Flags: review?(dbaron) → review+
Comment on attachment 407321 [details] [diff] [review]
Part 3 fixed to properly set mIsLink to false as needed.
r=dbaron
(And it looks like this addresses the third of my comments on patch 2, except for the assertion in LinkState.)
Assignee | ||
Comment 12•15 years ago
|
||
> Could you wrap this line at under 80 characters?
Done.
> Maybe the |protected| section you're adding to should actually be |private|?
Done. Made mLanguage and mNthIndices private too.
> (Maybe it should have a more neutral name?)
Renamed to mGotLinkInfo and commented better.
> change the assertion in LinkState to check mGotIsLink
Good catch. Done.
Assignee | ||
Comment 13•15 years ago
|
||
Assignee | ||
Comment 14•15 years ago
|
||
Attachment #407207 -
Attachment is obsolete: true
Attachment #407208 -
Attachment is obsolete: true
Assignee | ||
Comment 15•15 years ago
|
||
Attachment #407321 -
Attachment is obsolete: true
Updated•15 years ago
|
Attachment #414303 -
Attachment is patch: true
Attachment #414303 -
Attachment mime type: application/octet-stream → text/plain
Assignee | ||
Comment 16•15 years ago
|
||
Assignee | ||
Comment 17•15 years ago
|
||
Pushed:
http://hg.mozilla.org/mozilla-central/rev/1e9e3cd957f2
http://hg.mozilla.org/mozilla-central/rev/b3636bfdc6d9
http://hg.mozilla.org/mozilla-central/rev/a6508c37eb41
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•