-
Notifications
You must be signed in to change notification settings - Fork 50
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
Parameters to lower memory consumption #144
Comments
Something like provided here with mem_level and window_bits |
The window_bits/mem_level feature isn't implemented in miniz_oxide (and original miniz, the paramter is just provided for API compatability for zlib, it's just ignored) currently. The The memory savings of the window_bits/mem_level thing in zlib is in the level of 32kb so it's only of relevance on extremely memory constrained systems hence there why there hasn't been a lot of incentive to implement it in alternative implementations. |
Thanks @oyvindln for your answer. So I played a little bit with the codebase and my tests. I'm sorry if I did some very dumb things but I wanted to share what I found and see if we could find an easy way to implement like a new |
For instance, these data look good with my current use case but I would like to know the risk of lowering the size of the dictionary, because it's like the most impacting parameter. pub const LZ_CODE_BUF_SIZE: usize = 8 * 1024;
pub const LZ_HASH_BITS: i32 = 12;
pub(crate) const LZ_DICT_SIZE: usize = 4096; |
There shouldn't be any risk on the compression side other than lower compression ratio. However, if they are made into non-const values it could have notable impacts on the compiler's ability to optimize things like removing bounds checks so if they are to be made configurable it should ideally be done using generics or similar in some way so one can keep the benefits of that. On the decompression side you can't really rely on the data in the DEFLATE stream actually obeying the maximum window size that has been set in the header DEFLATE header unless it's data you yourself is responsible for, since it's just a flag. So, it's only really usable for decompressing data you yourself have compressed with a lower window size since otherwise deflate compressed data will have been using the max window size in probably 99.9% of cases. |
I'm implementing this spec in rust and it requires the window_bits be set to 10, and no header be used, so it would be helpful to be able to set window_bits to a custom value. |
@praveenperera indeed, a feature like the window bits would be useful. I am implementing the permessage-deflate standard for websocket and some servers might be under certain constraints. Thus, they would require a lower dictionary window. |
Aight if it actually has some real world use it makes sense to look into implementing some way of limiting the compressor window size. One maybe simple workaround for now could be to just use rle encoding ( |
It's a bit janky to use stil but I've in 02a8857 I've now made it so that if I believe also the fast mode used for level 1 only uses a window size of 4096 (i.e window bits of 12) rather than the full window for matches so I can look into also setting the header accordingly, but I'll leave that for later on as I want to get a new release out soon. |
Hello ! I would like to know if there are some parameters available to lower memory consumption ? Like for example in zlib we can play with window_bits parameter when compressing. They also have memory level and so one. I would really like to stay on miniz_oxyde instead of using zlib. My use case is to compress a long lived stream of memory I want to lower the memory usage of the compression
The text was updated successfully, but these errors were encountered: