-
Notifications
You must be signed in to change notification settings - Fork 116
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
Laying out flex trees with height/width set to Auto is slow (100x slower than when set to Percent) #502
Comments
@matthewgapp To follow up on this:
|
Awesome response, thanks for writing that up. I know these issues aren't all fully resolved yet, but for the sake of keeping issues actionable I'm going to close this out. Feel free to spin out new issues for pathological cases / perf improvement ideas, or keep discussing the big picture here. |
taffy
version0.3.12
Platform
Rust
What you did
Reproduced via the script below.
What went wrong
Laying out flex trees with height and width set to Auto is slow (and unusable). It's 100x - 200x slower than when height and width are set to 100%. I would expect height/width of Auto to perform about the same (maybe a littler slower) as height/width 100% Percent. But not 100 - 200x slower
Computing a flex layout of a tree of nodes scales extremely poorly with increasing tree depth, to the point where Taffy is not practical for trees that exceed a depth of about 20.
So think it boils down to a combination of flex column and width, height being set to Auto (see code comments in repro snippet).
I looked at the call stack and it appears that when the dimensions are set to Auto, it will recurse through the nodes ~N^2 times. The bottom-most nodes end up getting laid out almost 10,000x.
Caching of layout results is disabled on the layout pass. There should probably be some memoization at some point in that recursion so that nodes are not laid out redundantly over and over during a layout pass.
I'm not sure why flex direction of column makes things so much worse.
Additional information
Workaround is to use width and height set to 100% instead of Auto.
The text was updated successfully, but these errors were encountered: