-
Notifications
You must be signed in to change notification settings - Fork 117
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
Layout algorithm decoupling, Sizing Constraints & Perf Improvements #246
Layout algorithm decoupling, Sizing Constraints & Perf Improvements #246
Conversation
Wow, I'm kind of at a loss for words with those benchmark results. I'm going to be prioritizing getting this reviewed and merged: let me know when you feel it's ready. |
Same! The majority of the improvement came from a one-line change too! I'm busy tomorrow, but I'll see if I can find some time to get this into a mergeable state on Sunday :) |
This gives huge performance wins on deep trees. On my machine, an improvement from 17s to 3ms (note change of unit) on the benchmark with 10,000 nodes at a depth of 14
73c3ea4
to
c67507a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stream of consciousness thoughts as I read:
- Jesus those perf numbers. Algorithmic complexity really does matter eh?
AvailableSpace::Definite
is really nice! Very clear, very explicit- Size::NONE -> Size::MAX_CONTENT definitely needs a migration guide. More clear though!
AvailableSpace
instead of anOption<f32>
is so much clearer.- Ditto
RunMode
andSizingMode
. Great docs too! - The methods in debug.rs feel like they will be genuinely useful to users: I'd make them properly pub.
Overall, this does a ton of the things that the team has wanted to do for this library: stronger types, better docs, dramatically better performance, foundations for multiple layout algorithms. I'm looking forward to merging this when it's ready!
Plenty to nitpick (missing doc links, commented out code), but I trust you'll get around to those :) Let me know when you're ready for a final review pass!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- ❤️
RunMode
,SizingMode
andAvailableSpace
. It really helps readability :) - The debug seems particularly useful! We should further build on that both for ourselves and end-users.
Really appreciate the work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing performance improvements!
So I've done some rough benchmarking against yoga by:
Results
* But in fairness to yoga, the error is "please increase the memory limit" and the equivalent taffy benchmark was using much more memory (6gb+) than yoga's limit of 134mb. I'd like to run taffy without criterion, to get a better idea of how much memory it uses in real-world usage. Perhaps we could also try https://docs.rs/dhat/latest/dhat/ ConclusionsAt least on this benchmark we seem to be quite a bit faster than yoga. Although I'm a little worried that it seems a bit too good to be true. Code for yoga benchmarkspackage.json
index.js
|
Admittedly, yoga also implements parts of the flexbox spec we're ignoring. I'd avoid publicizing it widely until we close that gap. |
@alice-i-cecile I now consider this ready for review. I had planned to add a P.S. You've added the 0.3 milestone to this PR, but I believe we are yet to release a 0.2 version so it probably ought to be that? On that note, perhaps it would make sense to start gearing up for a release (release notes need a bit of work I think!) once this lands? Seems to me that this, along with the cumulative changes already on |
Interesting. Do you have a list in your head of things that they implement that we don't?
I feel like it might be worth calling out in our release notes, but with the explicit caveat that we're not yet that confident in our benchmarks and would appreciate scrutiny from 3rd parties. So long as we don't come across as showing off or putting others down I think we should be alright sharing numbers? |
Honestly, I'm not sure how useful a direct comparison between yoga and taffy is, since they use completely different languages. |
Agreed, let's ship it. WRT missing features, I think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really exceptional work. Two things to add to the release notes (see the comments), then I'll merge this in!
Added :) |
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Awesome work! Let's get |
Objective
Lays the groundwork for Support multiple layout algorithms #28 by splitting the "leaf" algorithm out from the flexbox algorithm
and creating a trait that each algorithm implements(I now intend to make this a separate PR)Addresses Improve docs and API to clarify the purpose of
MeasureFunc
#214 by adding an available_space parameter to MeasureFuncs. TheAvailableSpace
is also used for the flexbox parent size parameter.Dramatically improves performance on deep trees (17s -> 3ms) by improving caching. (Fixes Slow performance with deep hierachies #243)
Adds a debug module with support for printing a nested tree of logs when rendering a tree (todo: add a feature flag for outputting logs and default to off).
Benchmark Results
Pay attention to units: there are all of seconds, milliseconds and microseconds in here.
Warning
Note for anyone reading this in the future: the absolute values in these benchmarks turned to be bunk due to flaw in the measuring methodology. However the relative improvement ended up being similar. See
benches
folder for up to date benchmark results.Context
Code is still WIP. Cleanup needed in a number of places. It is passing all tests though.
Feedback wanted
Nothing specific, but general feedback welcome.