WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
87832
[Performance] Optimize querySelector() by caching a CSSParser object on Document
https://bugs.webkit.org/show_bug.cgi?id=87832
Summary
[Performance] Optimize querySelector() by caching a CSSParser object on Document
Kentaro Hara
Reported
2012-05-30 01:09:27 PDT
Currently one of the bottlenecks of Node::querySelector() and Node::querySelectorAll() is to create a CSSParser object every time. PassRefPtr<Element> Node::querySelector(const String& selectors, ExceptionCode& ec) { CSSParser parser(document()); // This is a bottleneck! CSSSelectorList querySelectorList; parser.parseSelector(selectors, querySelectorList); ...; } We can avoid creating a CSSParser object by caching the CSSParser object on Document. I'll upload a couple of proposed patches for performance comparison. After that I'll post some comments on the patches.
Attachments
Patch [A]
(3.13 KB, patch)
2012-05-30 01:17 PDT
,
Kentaro Hara
no flags
Details
Formatted Diff
Diff
Patch [B]
(4.41 KB, patch)
2012-05-30 01:19 PDT
,
Kentaro Hara
no flags
Details
Formatted Diff
Diff
Patch [C]
(5.06 KB, patch)
2012-05-30 01:28 PDT
,
Kentaro Hara
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Kentaro Hara
Comment 1
2012-05-30 01:17:06 PDT
Created
attachment 144745
[details]
Patch [A]
Kentaro Hara
Comment 2
2012-05-30 01:19:58 PDT
Created
attachment 144747
[details]
Patch [B]
Kentaro Hara
Comment 3
2012-05-30 01:28:19 PDT
Created
attachment 144751
[details]
Patch [C]
Antti Koivisto
Comment 4
2012-05-30 01:29:37 PDT
CSSParser has so far not been reusable. There might be state left from the previous runs that affect the results of the next runs. I think you should try caching SelectorQueries first. That would avoid the need to spin up the parser repeatedly in the first place.
Kentaro Hara
Comment 5
2012-05-30 01:32:46 PDT
(In reply to
comment #4
)
> CSSParser has so far not been reusable. There might be state left from the previous runs that affect the results of the next runs. > > I think you should try caching SelectorQueries first. That would avoid the need to spin up the parser repeatedly in the first place.
Sounds reasonable. Caching SelectorQueries would solve the CSSParser construction problem.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug