Skip to content
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

[bug] When using LZMA2, Fast, do the two right-click compression commands have different compression rates? #353

Open
GitCourser opened this issue Sep 14, 2023 · 5 comments

Comments

@GitCourser
Copy link

When using Add to archive..., select LZMA2, Fast [std] & Level 9, the compressed file will be smaller than the one compressed by Add to <Archive>.7z.
But if change to LZMA2 [std], the file size will be the same after compression by both methods.
Are the compression parameters saved when using Fast not used?

@g0blin-NN
Copy link

@GitCourser
Is it the same with standard 7-zip? 7-zip-zstd adds the necessary functions but does not change 7-zip itself.
That's what I think. I could be wrong.
ps Pardon my English. I don't know it.

@sebres
Copy link
Collaborator

sebres commented Sep 14, 2023

I assume it was multithreaded compression, was not it?
The compression ratio may change from time to time if method uses multiple threads for compression (default by LZMA2 x9).
You can not only get different compression ratio for different number of threads, but also different compression ratio for same number of threads...
And it'd additionally depend on input and another circumstances (like faster read by cached IO, etc), since buffers handling could deviate by threaded processing.

So your tests are inconclusive if number of threads is larger than 1.

@GitCourser
Copy link
Author

@sebres
I have tested it several times. For the same batch of files, one or several, no matter how many times it is compressed, as long as the same method is used, the compressed size will be the same.
When using LZMA2 [std] Level 9, right-click Add to archive... or Add to <Archive>.7z, and you will get compressed packages of the same size.
But when using LZMA2, Fast [std] Level 9, right-clicking Add to archive... (after calling up the dialog box) will definitely result in a higher compression rate than directly using Add to <Archive>.7z. Smaller file size

@sebres
Copy link
Collaborator

sebres commented Sep 14, 2023

I guess I understand what you meant now - just not follow exact scenario (of unexpected case) - your description is a bit confusing...
Do you mean this:

  1. right-clicking Add to archive...
  2. select "LZMA2, Fast [std] Level 9" and do compress
  3. archive is N bytes
  4. right-clicking Add to "Archive.7z" (to compress directly without dialog)
  5. archive is N+X bytes (larger than with dialog)

Then I can confirm it.
Indeed, it looks like some of the parameters (from dialog) are not selected if compressing without dialog.
Either not stored or possibly not loaded if compression starts without dialog. This is what 7z saves to the registry:

[HKEY_CURRENT_USER\SOFTWARE\7-Zip-Zstandard\Compression\Options\7z]
"Method"="FLZMA2"
"Level"=dword:00000009
"Dictionary"=dword:08000000

(some of the parameters may be not stored if they are default).

But as @g0blin-NN said - this can be an issue of original 7z.
Although I already saw some stuff that definitely stored in original 7z and never stored in 7z-zstd - for instance archive history of 7z-zstd never contains any path (also registry ArcHistory seems to be always empty).

@GitCourser
Copy link
Author

@sebres
Yes, that’s what it means, but I think this is a bug, because the saved parameters will be used when using LZMA2 (to compress directly without dialog), but not when using LZMA2, Fast

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants