libnxz / power-gzip

POWER NX zlib compliant library
23 stars 18 forks source link

Using different compression arguments generates errors #43

Closed carlosedp closed 4 years ago

carlosedp commented 4 years ago

While using gzm for some tests, I found-out that the default mode (-t 31) is kinda like the --fast option on GZip but I was unable to change it to more compression.

If I try, with anything different than 31, I get an error:

❯ time gzm -t 31 < kernel-modules-5.9.5.tar >mod.nx.gz
gzm -t 31 < kernel-modules-5.9.5.tar > mod.nx.gz  0.05s user 0.05s system 99% cpu 0.092 total
❯ time gzm -t 26 < kernel-modules-5.9.5.tar >mod.nx.gz
zpipe: invalid compression level
gzm -t 26 < kernel-modules-5.9.5.tar > mod.nx.gz  0.00s user 0.00s system 93% cpu 0.003 total
❯ gzm --help
usage: gzm [-d] [-t t] < source > dest
usage: gzm [-s s] [-t t] [-f f] < source > dest
   -s followed by one of ints: default(DH+LZ): 0, fixed(FH+LZ): 1, huffman_only: 2, RLE: 3
   -t followed by one of ints: gz file format: gzip: 0, zlib: 1, raw: 2, autodetect format: 47(inflate only)
or -t followed by one of ints: gzip 25 to 31, zlib 9 to 15, raw -8 to -15 for window sizes 2^9 to 2^15
   -f followed by one of ints: no_flush: 0, sync_flush: 1, partial_flush: 2, full_flush: 3, z_block: 5

Some info:

-rw-r--r-- 1 carlosedp carlosedp 308M Nov 16 16:25 kernel-modules-5.9.5.tar
-rw-r--r-- 1 carlosedp carlosedp 127M Nov 16 16:31 mod.nx.gz
-rw-r--r-- 1 carlosedp carlosedp 120M Nov 16 17:04 mod.pigz.gz

❯ file mod.nx.gz
mod.nx.gz: gzip compressed data, max speed, from Unix, original size 322048000

❯ file mod.pigz.gz
mod.pigz.gz: gzip compressed data, last modified: Mon Nov 16 19:25:35 2020, max speed, from Unix, original size 322048000
tuliom commented 4 years ago

That's because the NX GZIP Engine only supports a window size of 32KB.

Reference: https://github.com/libnxz/power-gzip/blob/master/lib/nx_deflate.c#L822-L824

Notice that level 6 is the only one supported too.

carlosedp commented 4 years ago

Thanks for the clarification!