Page MenuHomeFreeBSD

Correct maximum zstd compression level in bsdtar(1)
Needs ReviewPublic

Authored by mqudsi_neosmart.net on Jan 24 2019, 6:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 19 2024, 12:45 AM
Unknown Object (File)
Feb 16 2024, 6:51 AM
Unknown Object (File)
Jan 12 2024, 11:51 PM
Unknown Object (File)
Dec 20 2023, 12:23 AM
Unknown Object (File)
Dec 12 2023, 4:42 AM
Unknown Object (File)
Nov 24 2023, 8:23 AM
Unknown Object (File)
Nov 14 2023, 11:13 PM
Unknown Object (File)
Nov 4 2023, 3:08 PM

Details

Summary

The man page for bsdtar(1) incorrectly has 22 listed as the maximum supported
compression level for the zstd compression algorithm (as specified with
--options zstd:compression-level=nn). In practice using anything greater than
19 results in the following message at runtime:

Warning : compression level higher than max, reduced to 19

Diff Detail

Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 22124
Build 21345: arc lint + arc unit

Event Timeline

Looking at sys/contrib/zstd/programs/zstdcli.c, at around line 1082, this all depends on whether --ultra is given on the command line. This is the only location of the warning message I have discovered so far.

If --ultra is given, then the maximum level is 22, as defined by ZSTD_maxCLevel() at line 4150 of sys/contrib/zstd/lib/compress/zstd_compress.c. If --ultra is not given, then the maximum level is 19, as defined at line 20 of sys/contrib/zstd/programs/zstdcli.c, and subsequently used at line 1082 of the same source file.

If there isn't a way of passing --ultra from bsdtar(1) to zstd(1) and there is no intention of passing --ultra unconditionally, then the proposed change is warranted.

My review is valid for base/head as of r343529.

(Still learning the ropes when it comes to markup.)

Thanks for the review.

One can obviously manually pass --ultra to the compressor if using the --use-compress-program option, but that would bypass the compression level setting altogether.