Re: [csswg-drafts] [css-grid-3][masonry] variable track sizes + dense packing has poor performance (#9326)

Back to the original issue...

Agreed that having N different track sizes means dense packing would require O(N) layout passes on items added after a gap, and this would be a problem. We suggest adopting a heuristic that brings this closer to O(2) for most cases:

1. Lay out the item in the widest track, and in the narrowest track, and find the shortest height among the two.
2. Skip trying to fit into any gaps that are shorter than that height.

It's possible, but unlikely, that an item's actual shortest height would be at a middling width; and this allows us to avoid a lot of that extra work in the much more common cases where the item definitely won't fit.


-- 
GitHub Notification of comment by fantasai
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9326#issuecomment-2007788457 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 19 March 2024 17:46:10 UTC