Bug 207852 - [css-grid] Improve performance of track sizing algorithm for spanning items
Summary: [css-grid] Improve performance of track sizing algorithm for spanning items
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Oriol Brufau
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-02-17 12:24 PST by Oriol Brufau
Modified: 2020-02-18 06:48 PST (History)
10 users (show)

See Also:


Attachments
Patch (14.67 KB, patch)
2020-02-17 12:34 PST, Oriol Brufau
no flags Details | Formatted Diff | Diff
Patch (14.67 KB, patch)
2020-02-17 14:46 PST, Oriol Brufau
no flags Details | Formatted Diff | Diff
Patch (14.86 KB, patch)
2020-02-18 05:21 PST, Oriol Brufau
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oriol Brufau 2020-02-17 12:24:47 PST
The grid track sizing algorithm handles intrinsic contributions from items that span a single track in a simpler way than when the span is greater than 1.

In the former case, sizeTrackToFitNonSpanningItem only calculates the track sizing function of each track once per each item in that track.

But in the latter case we not only calculate the track sizing function of multiple tracks per item, we also repeat this 5 times in order to handle the various TrackSizeComputationPhase.

Calculating the used track sizing function from the raw one is not a very expensive operation when done once, but repeating it so many times has a performance impact.

In Chromium I added a auto-grid-lots-of-spanning-data.html perf test. The changes that I plan to do will improve the performance of that test by 40% in WebKit.
Comment 1 Oriol Brufau 2020-02-17 12:34:42 PST
Created attachment 390960 [details]
Patch
Comment 2 Oriol Brufau 2020-02-17 14:46:27 PST
Created attachment 390984 [details]
Patch
Comment 3 Javier Fernandez 2020-02-18 02:05:51 PST
Comment on attachment 390984 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=390984&action=review

> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:247
> +    const GridTrackSize& trackSize = tracks(m_direction)[trackPosition].cachedTrackSize();

We can use 'auto' type here.

> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:271
> +        const GridTrackSize& trackSize = trackList[trackPosition].cachedTrackSize();

Ditto

> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:450
> +            const GridTrackSize& trackSize = track.cachedTrackSize();

Ditto

> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:573
> +        // We cannot use tracks(direction)[trackPosition].cachedTrackSize()

It's not needed to wrap comments like this.

> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:634
> +        const GridTrackSize& trackSize = rawGridTrackSize(direction, trackPosition);

Use auto here

> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:729
> +        const GridTrackSize& trackSize = allTracks[trackIndex].cachedTrackSize();

Ditto

> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:825
> +            const GridTrackSize& trackSize = allTracks[trackPosition].cachedTrackSize();

Ditto
Comment 4 Oriol Brufau 2020-02-18 05:21:31 PST
Created attachment 391040 [details]
Patch
Comment 5 WebKit Commit Bot 2020-02-18 06:47:52 PST
Comment on attachment 391040 [details]
Patch

Clearing flags on attachment: 391040

Committed r256826: <https://trac.webkit.org/changeset/256826>
Comment 6 WebKit Commit Bot 2020-02-18 06:47:53 PST
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2020-02-18 06:48:15 PST
<rdar://problem/59548279>