WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
75083
Indirect adjacency combinator has potential sublinear performance
https://bugs.webkit.org/show_bug.cgi?id=75083
Summary
Indirect adjacency combinator has potential sublinear performance
Allan Sandfeld Jensen
Reported
2011-12-22 06:10:55 PST
When evaluating a selector with multiple "indirect adjacency" combinators such as "a ~ b ~ c", the runtime of of the selector-matcher currently has sublinear performance. Two indirect adjacency combinator will for instance result in O(n^2) element checks, where n is the number of siblings. Three indirect adjacency combinators will result in O(n^3) element checks, etc. The "indirect adjacency" combinator is very rare in the wild, so the chance of seeing two in the same selector is highly unlikely however. The problem can be solved similar to the same issue with multiple ancestor combinators. The recursive selector checker just needs to expanded with a result-type of SelectorFailsAllSiblings.
Attachments
Patch
(4.37 KB, patch)
2011-12-22 06:16 PST
,
Allan Sandfeld Jensen
no flags
Details
Formatted Diff
Diff
New patch with performance tests
(6.94 KB, patch)
2011-12-28 05:48 PST
,
Allan Sandfeld Jensen
no flags
Details
Formatted Diff
Diff
Patch
(7.34 KB, patch)
2011-12-28 07:33 PST
,
Allan Sandfeld Jensen
koivisto
: review+
Details
Formatted Diff
Diff
Patch
(7.35 KB, patch)
2012-01-03 05:59 PST
,
Allan Sandfeld Jensen
koivisto
: review+
koivisto
: commit-queue-
Details
Formatted Diff
Diff
Patch
(7.50 KB, patch)
2012-01-03 06:42 PST
,
Allan Sandfeld Jensen
koivisto
: review+
Details
Formatted Diff
Diff
Patch
(7.34 KB, patch)
2012-01-04 01:43 PST
,
Allan Sandfeld Jensen
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Allan Sandfeld Jensen
Comment 1
2011-12-22 06:16:54 PST
Created
attachment 120315
[details]
Patch
Darin Adler
Comment 2
2011-12-22 08:37:58 PST
Comment on
attachment 120315
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=120315&action=review
> Source/WebCore/ChangeLog:4 > + Fix rare superlinear runtime of the indirect adjacency combinator
The code change is fine, but it needs a test. Using the techniques from the LayoutTests/perf directory is should be straightforward to demonstrate the problem and the fix.
Allan Sandfeld Jensen
Comment 3
2011-12-28 05:48:04 PST
Created
attachment 120659
[details]
New patch with performance tests
WebKit Review Bot
Comment 4
2011-12-28 05:56:46 PST
Attachment 120659
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/perf..." exit_code: 1 LayoutTests/ChangeLog:1: ChangeLog entry has no bug number [changelog/bugnumber] [5] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Allan Sandfeld Jensen
Comment 5
2011-12-28 07:33:13 PST
Created
attachment 120669
[details]
Patch
Antti Koivisto
Comment 6
2011-12-30 02:02:32 PST
Comment on
attachment 120669
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=120669&action=review
r=me
> Source/WebCore/ChangeLog:7 > +
https://bugs.webkit.org/show_bug.cgi?id=75083
> + Fix rare superlinear runtime of the indirect adjacency combinator > + > + Reviewed by NOBODY (OOPS!). > +
You should briefly explain in the ChangeLog what the superlinear case looks like and how this patch fixes it.
Allan Sandfeld Jensen
Comment 7
2012-01-03 05:59:05 PST
Created
attachment 120939
[details]
Patch Updates changelog with test and improved description
Antti Koivisto
Comment 8
2012-01-03 06:11:00 PST
Comment on
attachment 120939
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=120939&action=review
> Source/WebCore/ChangeLog:10 > +2011-12-28 Allan Sandfeld Jensen <
allan.jensen@nokia.com
> > + > + Fix superlinear runtime of the rare case of multiple indirect adjency combinators, > + such as "li ~ li ~ li". The recursive matching algorithm now detects cases > + where all siblings have failed a check of a selector. > +
https://bugs.webkit.org/show_bug.cgi?id=75083
> + > + Reviewed by NOBODY (OOPS!). > + > + Test: perf/nested-combined-selectors.html
If you look around in the ChangeLog, you see that the standard format is: Bug title <Bugzilla URL> Reviewed by Foo. Brief description. Test: for/foo.html Please follow that.
Allan Sandfeld Jensen
Comment 9
2012-01-03 06:42:16 PST
Created
attachment 120940
[details]
Patch
Antti Koivisto
Comment 10
2012-01-03 11:21:08 PST
Comment on
attachment 120940
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=120940&action=review
> LayoutTests/ChangeLog:1 > -2012-01-02 Gavin Barraclough <
barraclough@apple.com
> > + 2011-12-28 Allan Sandfeld Jensen <
allan.jensen@nokia.com
>
Extra space.
> LayoutTests/ChangeLog:10 > + 2012-01-02 Gavin Barraclough <
barraclough@apple.com
>
Extra space.
Allan Sandfeld Jensen
Comment 11
2012-01-04 01:43:25 PST
Created
attachment 121085
[details]
Patch One more attempt at perfect Changelog writing.
WebKit Review Bot
Comment 12
2012-01-05 02:57:36 PST
Comment on
attachment 121085
[details]
Patch Clearing flags on attachment: 121085 Committed
r104133
: <
http://trac.webkit.org/changeset/104133
>
WebKit Review Bot
Comment 13
2012-01-05 02:57:41 PST
All reviewed patches have been landed. Closing bug.
Nils Barth
Comment 14
2013-05-15 20:42:50 PDT
This bug appears to still be present. Allan, if you're concerned about this, you might want to take a look at the revised tests. Per revised LayoutTests/perf in Chromium, the test: perf/nested-combined-selectors.html ...which was flaky before, is now consistently failing, and inspecting the output, as at:
http://test-results.appspot.com/dashboards/flakiness_dashboard.html#tests=%5Eperf%2Fnested-combined-selectors.html%24
...shows that it has O(n^2) performance once n >= 32 or so. (You can download resources/magnitude-perf.js and perf/nested-combined-selectors.html from ToT Chromium and run locally to verify.) I don't know if this is an unrealistically large size; description Allan writes: The "indirect adjacency" combinator is very rare in the wild, so the chance of seeing two in the same selector is highly unlikely however. I've opened a bug at Chromium regarding this: Issue 232266: perf/nested-combined-selectors.html fails (on Linux): styling multiple combinators is O(n^2), should be O(n)
https://code.google.com/p/chromium/issues/detail?id=232266
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