Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid: single track span optimisation #343

Closed

Conversation

nicoburns
Copy link
Collaborator

@nicoburns nicoburns commented Jan 29, 2023

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.

@nicoburns nicoburns mentioned this pull request Jan 29, 2023
87 tasks
@nicoburns nicoburns force-pushed the grid/single-track-span-optimisation branch from bb7be1c to 611084c Compare January 29, 2023 21:25
@nicoburns nicoburns added this to the 0.3 "CSS Grid" milestone Jan 29, 2023
@alice-i-cecile alice-i-cecile enabled auto-merge (squash) February 3, 2023 01:07
@alice-i-cecile alice-i-cecile added the performance Layout go brr label Feb 3, 2023
@nicoburns nicoburns closed this Feb 3, 2023
auto-merge was automatically disabled February 3, 2023 01:31

Pull request was closed

@nicoburns nicoburns force-pushed the grid/single-track-span-optimisation branch from 611084c to ab747b8 Compare February 3, 2023 01:31
@nicoburns
Copy link
Collaborator Author

This was accidentally included in #344. So it has been merged, just not via this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Layout go brr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants