[CSS Grid Layout] Cache several vectors to avoid malloc/free churn
authorsvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Nov 2013 08:22:08 +0000 (08:22 +0000)
committersvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Nov 2013 08:22:08 +0000 (08:22 +0000)
commit3750e633c6b5454c9e7e0ca50c98808c6e92627d
treeeeeeb5254d76a6f979fa7acf047547321cd7c396
parent31be77ccb8d300f1056d637fa577db9fc45796bd
[CSS Grid Layout] Cache several vectors to avoid malloc/free churn
https://bugs.webkit.org/show_bug.cgi?id=123995

Reviewed by Dean Jackson.

From Blink r158228 by <jchaffraix@chromium.org>

Laying-out the grid items means a lot of calls to
distributeSpaceToTracks() and
resolveContentBasedTrackSizingFunctionsForItems() as they're
called in a loop. This means that there is a lot of malloc/free
going on there. By moving the vectors used by these methods to a
new class which is kept during the whole layout process we save a
lot of those calls.

This obviously mean that the price we pay for a significant
perfomance improvement is that we keep the maximum allocation till
the end of each layout, but it's an amount of memory that we have
to allocate anyway. The improvement in the
auto-grid-lots-of-data.html perf test is ~24% (165 runs/s vs 207
runs/s).

No new tests required as we're just refactoring code to a new
helper class. Nevertheless the performance improvement is backed
by the perf test mentioned above.

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::GridSizingData::GridSizingData):
(WebCore::RenderGrid::computedUsedBreadthOfGridTracks):
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctions):
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForItems):
(WebCore::RenderGrid::distributeSpaceToTracks):
(WebCore::RenderGrid::layoutGridItems):
(WebCore::RenderGrid::findChildLogicalPosition):
* rendering/RenderGrid.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159741 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h