7-Zip-zstd icon indicating copy to clipboard operation
7-Zip-zstd copied to clipboard

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

Open GitCourser opened this issue 2 years ago • 5 comments

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?

GitCourser avatar Sep 14 '23 02:09 GitCourser

@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.

g0blin-NN avatar Sep 14 '23 11:09 g0blin-NN

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.

sebres avatar Sep 14 '23 13:09 sebres

@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

GitCourser avatar Sep 14 '23 14:09 GitCourser

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).

sebres avatar Sep 14 '23 15:09 sebres

@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

GitCourser avatar Sep 15 '23 02:09 GitCourser