Grid: single track span optimisation #343
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Improve performance of CSS Grid context sizing.
Changes made
Implements Section 11.4.2 of the CSS Grid spc "Size tracks to fit non-spanning items". This is a specialised variant of Section 11.4.3 "Increase sizes to accommodate spanning items crossing content-sized tracks" that defines an optimised intrinsic track sizing algorithm for the case where an item spans exactly 1 track (the most common case).
Performance results
A 50% performance improvement for the "deep" benchmarks (which are the most realistic). More modest 5-15% improvements on the "wide" and "superdeep" benchmarks. This brings our 6500 node random track benchmark down to ~8ms. This is still slower than flexbox at 10000 nodes (~5ms) but isn't that far off (roughly 2x), and from what I've read we should expect grid to be a little slower than flexbox. It's also a lot better than the ~540ms that this benchmark was taking when it was first created, or even the ~24ms it was taking this morning.
As of this PR, I'm considering performance good enough for release.