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
[Question] LZMA2 Compression? / LZMA Compression level? #773
Comments
LZMA2 could be added. Would need some source and a PR I think the compression level is setable directly on LZMAStream but not exposed outwardly. Needs a PR |
I took a look here
Default LZMA settings are 32 fastbytes and 1MB dictionary (1<<20) I testes compressing a single 26MB file: 7z(22.01) So its not only the compression level (fastbytes) but the dictionary size as well. Be warned that compressing with a 16MB dictionary uses a lot more ram in sharpcompress. But that was a single file, i went ahead and compressed the 940MB folder 16:23 - 184MB Sharpcompress default
And ive been unable to get it down to 148MB like 7z Ultra does by increasing the fastbytes more, not sure why. Yeah compression speed is what has me worried here because it is unusuable, not sure what kind of magic 7z does, but this is way too slow, and the c# LZMA sdk is just as slow as well. |
Note that the fastBytes parameter is not a higher=higher compression. The default in LZMA is 128 (of 273) and in my case 100 to 128 often resulted in a tiny bit better compression than the highest value (but mostly the same). Together with a dictionary of size (1<<23) I get nearly the same compression as 7zip. SharpCompress is slow because it uses the official LZMA C# SDK, which is an unoptimized never-updated sloppy translation from 2013. 7zip uses the algorithm written and optimized in ANSI-C. |
1<<24 dictionary size seems to be giving me the best results along with a fastbytes of at least 64 (default is 32) I guess i will have to profile this to see were is wasting so much time. |
Ive been looking at the methods were the LZMA SDK spends so much time and i only managed to get marginal gains in speed. Maybe someone with more C# experience than me can figure something out. I cant belive the state of the LZMA SDK for C#, no LZMA2, no XZ and LZMA compression is just unusable and it was like this 10 years ago from what im seeing. C# is slower than C++ but come on, you cant take over 35 minutes to compress a 900mb folder. |
if you find an implementation that is faster then let me know. |
Ive looked but i dont think there is one. But not giving up the attempts to fix it myself it is one method thats seems to be causing all the problems.
This is one of those things were SIMD extensions maybe applied. But im not experienced in any of that. |
Good luck. I've never looked at compression algorithms myself. I was more concerned about the interface and maybe some archive formats. |
Hi, first off i wanted to thank everyone involved in this project for all the amazing work, ive been using this lib for a while and its great.
-First i wanted to ask about the status of LZMA2 compression, to me knowledge there is only LZMA compression support, it may already be in and i might not know about it.
-Second, there is any LZMA compression level option? because comparing to the final size of a file compressed with 7z or the LZMA C# SDK at max level the files produced by SharpCompress are considerably bigger.
Thank you.
The text was updated successfully, but these errors were encountered: