WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
117489
Avoid N^2 walk placing renderers when building the render tree
https://bugs.webkit.org/show_bug.cgi?id=117489
Summary
Avoid N^2 walk placing renderers when building the render tree
Ryosuke Niwa
Reported
2013-06-10 22:14:52 PDT
Consider merging
https://chromium.googlesource.com/chromium/blink/+/48a78373952b2bb07675602b8661f3dbbe79ef49
Blink resolves style by walking each element from first children to last, but when we go to insert their renderer, we look for the next renderer to insert before. On the initial style resolve, this means we'll walk the entire DOM tree trying to find the right renderer to insert before leading to an N^2 loop over the DOM on load. This could be fixed by changing the semantics by which we insert renderers (insert after instead of insert before). Instead, here I reverse the order we resolve style. This should ensure that in the common case, we'll find the renderer to insert before immediately. While looking at this, I also found we have an N^2 loop for resolving Nth last child selectors, and reversing the style resolve loop would have caused the same issue for Nth child selectors. To fix prevent this regression, I'm piping the child index down to the style resolver in the common case. This ensures both Nth and Nth last should usually be O(1). Using the microbenchmark created for lazy layout,
http://elliottsprehn.com/personal/lazyblock/
, this yields a speedup of nearly 50% (4.75s -> 2.51s).
Attachments
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2013-06-11 17:33:37 PDT
Reverted in
https://chromium.googlesource.com/chromium/blink/+/05ea41ce18f27a9644dfa1e1a52c09a68e4ca6f2
.
Ryosuke Niwa
Comment 2
2013-11-05 21:56:37 PST
Relanded in
https://chromium.googlesource.com/chromium/blink/+/0ca1663620211d9286310feb60c599eb9c8278ce
.
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