Page MenuHomeFreeBSD

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

Authored by mqudsi_neosmart.net on Jan 24 2019, 6:22 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 Linters Available
Unit
No Unit 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.