-
Notifications
You must be signed in to change notification settings - Fork 61
Improve rust version performance #29
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
base: master
Are you sure you want to change the base?
Conversation
|
Nice work, now is really faster ! MarcoCiaramella C Impl 2D: 623 msec |
EndrII
left a comment
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.
good job
|
Based on this PR I made some further improvements by precomputing the lookup tables entirely at compile time: CryZe@cebabc3 Feel free to pull it into this PR. |
I was working in a similar path, making the gradients to be initialized at compile time so that don't need to initialize the context at runtime, and more important, remove the synchronization/verification that happens in every access to the gradients. @CryZe did just that and better than I would be able to. With his improvements, I got a 7% speedup over the original pull request implementation and 6.5% over the deprecated C implementation that was benchmarked by @EndrII. |
This precomputes all lookup tables at compile time, so there's no runtime performance hit anymore at all. As a side effect, this also means the library is now entirely `no_std` compatible.
hm looks good, but i want to test it before merging |
looks as optimistaions broken this library |
EndrII
left a comment
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.
build is failed
|
Library is now |
Be careful when profiling it, since the gradients are now constant, the used functions are pure, meaning that if the returned value is not used in some way like it wasn't in the original benchmarks, the compiler probably will wipe the function call away, making the timings be zero. |
EndrII
left a comment
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.
wow, amassing work !
MarcoCiaramella C Impl 2D: 626 msec
Deprecated C Impl 2D: 617 msec
Rust Impl 2D: 602 msec
@CryZe @qarmin @gabrielcfvg Thank you very much!!!
today i will integrate this library to my project )
The main issue was that instead of using OnceLock (which was stabilized about half a year after the initial version was merged), a custom implementation was used.
That implementation relied on unwrap in a critical section, which significantly reduced performance.
Additionally, it caused the following warnings in Rust 1.91.0:
I’ve also added simple stability tests to prevent accidental changes to the function output in the future.
An additional example was included to make it easier to verify performance.
Old implementation - ~640ms
New implementation - ~490ms