Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Issue 18162016: OrderIterator should be O(number of children) (Closed)

Created:
7 years, 5 months ago by Julien - ping for review
Modified:
7 years, 5 months ago
Reviewers:
cbiesinger, tony, esprehn, ojan
CC:
blink-reviews, dglazkov+blink, eae+blinkwatch, leviw+renderwatch, jchaffraix+rendering, tony
Visibility:
Public.

Description

OrderIterator should be O(number of children) The current implementation is O(number of children * order)! This change introduces a faster way to iterate over the children by using a HashMap to keep the subset of children for each 'order' value. This is a speed vs memory tradeoff as we are now using O(number of children + order) memory when the existing code was using O(order) memory). This is also a stepping stone to speed up CSS Grid Layout painting and hit-testing by allowing arbitrary children to be collected into the OrderIterator. This change doesn't introduce any runtime performance in PerformanceTests/Layout/flexbox-lots-of-data.html. In a test case with 1000 flex items with different 'order' that get forced layout in an infinite loop, this moves OrderIterator::next from the slowest function (>80%) to among the other functions (~7%). BUG=256804 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=154445

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+47 lines, -54 lines) Patch
M Source/core/rendering/OrderIterator.h View 3 chunks +22 lines, -7 lines 0 comments Download
M Source/core/rendering/OrderIterator.cpp View 2 chunks +25 lines, -47 lines 2 comments Download

Messages

Total messages: 8 (0 generated)
Julien - ping for review
7 years, 5 months ago (2013-07-13 00:57:35 UTC) #1
esprehn
Does this still need review? I'd prefer Ojan look at this, but I can do ...
7 years, 5 months ago (2013-07-17 13:58:28 UTC) #2
Julien - ping for review
On 2013/07/17 13:58:28, esprehn wrote: > Does this still need review? I'd prefer Ojan look ...
7 years, 5 months ago (2013-07-17 17:53:44 UTC) #3
cbiesinger
lgtm sorry I didn't get to this sooner!
7 years, 5 months ago (2013-07-17 19:12:38 UTC) #4
Julien - ping for review
On 2013/07/17 19:12:38, cbiesinger wrote: > lgtm > > sorry I didn't get to this ...
7 years, 5 months ago (2013-07-17 21:54:53 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jchaffraix@chromium.org/18162016/1
7 years, 5 months ago (2013-07-17 21:55:48 UTC) #6
commit-bot: I haz the power
Change committed as 154445
7 years, 5 months ago (2013-07-17 23:57:21 UTC) #7
tony
7 years, 5 months ago (2013-07-19 17:36:31 UTC) #8
Message was sent while issue was closed.
drive by comments

https://chromiumcodereview.appspot.com/18162016/diff/1/Source/core/rendering/...
File Source/core/rendering/OrderIterator.cpp (right):

https://chromiumcodereview.appspot.com/18162016/diff/1/Source/core/rendering/...
Source/core/rendering/OrderIterator.cpp:57: for (; m_currentChildIndex <
currentOrderChildren.size(); ++m_currentChildIndex) {
Using a for loop here is weird since you always return in body.  This could be
an if statement.

https://chromiumcodereview.appspot.com/18162016/diff/1/Source/core/rendering/...
Source/core/rendering/OrderIterator.cpp:94:
OrderIterator::OrderedValuesMap::AddResult result =
m_iterator.m_orderedValues.add(order, Vector<RenderBox*>());
Can we use a std::map<int, Vector<RenderBox*> > here?  Keeping 2 data structures
seems like extra complexity.

Powered by Google App Engine
This is Rietveld 408576698