summaryrefslogtreecommitdiff
path: root/unzip.c
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2019-04-02 08:01:02 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-04-02 10:30:11 -0700
commit7a6f9c9c3267185a299ad178607ac5e3716ab4a5 (patch)
tree3412bffea29a39e29f04766174bcb756e09a24e6 /unzip.c
parent38ae6a4ed36a7c86609a6a595add4298d9c202bc (diff)
downloadgzip-7a6f9c9c3267185a299ad178607ac5e3716ab4a5.tar.gz
bug#34918: [PATCH] Add support for IBM Z hardware-accelerated deflate
Future versions of IBM Z mainframes will provide DFLTCC instruction, which implements deflate algorithm in hardware with estimated compression and decompression performance orders of magnitude faster than the current gzip and ratio comparable with that of level 1. This patch adds DFLTCC support to gzip. In order to enable it, the following build commands should be used: $ ./configure --enable-dfltcc $ make When built like this, gzip would compress in hardware on level 1, and in software on all other levels. Decompression will always happen in hardware. In order to enable DFLTCC compression for levels 1-6 (i.e. to make it used by default) one could either add -DDFLTCC_LEVEL_MASK=0x7e at compile time, or set the environment variable DFLTCC_LEVEL_MASK to 0x7e at run time. Two DFLTCC compression calls produce the same results only when they both are made on machines of the same generation, and when the respective buffers have the same offset relative to the start of the page. Therefore care should be taken when using hardware compression when reproducible results are desired. One such use case - reproducible software builds - is handled explicitly: when SOURCE_DATE_EPOCH environment variable is set, the hardware compression is disabled. This patch tries to add DFLTCC support in a least intrusive way. All SystemZ-specific code was placed into a separate file, but unfortunately there is still a noticeable amount of changes in the main gzip code. Below is the summary of those changes. DFLTCC will refuse to write an End-of-block Symbol if there is no input data, thus in some cases it is necessary to do this manually. In order to achieve this, bi_buf and bi_valid were promoted to extern variables. lm_init() function moves the input buffer into the window, which is not desirable for DFLTCC. Therefore, its invocation was moved to software-only deflate(). In addition to initializing the window, this function also used to convert compression level to flags, which is still needed for DFLTCC. This responsibility was handed off to zip() function. To achieve maximum performance with DFLTCC, inbuf and outbuf must be 256k big and page-aligned. Additionally, for DFLTCC to work at all, the window must be page-aligned. In addition to compression, DFLTCC computes CRC-32 checksum, therefore, whenever it's used, software checksumming needs to be suppressed and its results replaced by those of dfltcc. This is achieved by introducing the new getcrc() and setcrc() functions. Unlike the current software implementation, DFLTCC decompresses data into the output buffer, and not the window. Therefore, just like flushing the window, flushing the output buffer must honor the test flag. Finally, znew-k test assumes that "znew -K" would not convert the test .Z file to .gz, which is not the case with DFLTCC. Since this is not the main point of the test, this assumption was relaxed.
Diffstat (limited to 'unzip.c')
-rw-r--r--unzip.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/unzip.c b/unzip.c
index a7255d4..86ef664 100644
--- a/unzip.c
+++ b/unzip.c
@@ -129,7 +129,11 @@ int unzip(in, out)
/* Decompress */
if (method == DEFLATED) {
+#ifdef IBM_Z_DFLTCC
+ int res = dfltcc_inflate();
+#else
int res = inflate();
+#endif
if (res == 3) {
xalloc_die ();