-
Notifications
You must be signed in to change notification settings - Fork 27
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
Use const-generics #19
Comments
Const generics are now stable in 1.51. |
I had a brief look, the In the meantime, it might be worth experimenting with it on nightly to see if benchmarks would improve with const generics. |
I've been doing some experiments in https://github.com/chyyran/lzma-rs/commits/feature-perf-experiments and found that const generics in Without const generics (but with some additional optimizations) SnowflakePowered@ecc71a0
With const generics SnowflakePowered@ad7d096
Probably worth pursuing in the future because of that benefit but SnowflakePowered@ad7d096 uses kind of a nasty workaround to get around the lack of |
Since For LZMA2 streams, the theoretical maximum parameters for the These benchmarks are with an allocating
The huge array on the stack probably causes a lot of cache misses and substantially reduces performance. It seems the only benefit to using const generics here is with |
For now, the
DecoderState
andBitTree
structs use memory allocations (inVec
) to store their state, despite having sizes known at compile time. This is in the most part to avoid code duplication.Once const generics are stable enough, they should be used instead to remove the need for dynamic allocation, and make the whole state struct more compact and contiguous (therefore potentially more cache-friendly).
This should hopefully improve performance a bit.
The text was updated successfully, but these errors were encountered: