]> git.ipfire.org Git - thirdparty/zlib-ng.git/commit
Reorganize inflate window layout
authorJim Kukunas <james.t.kukunas@linux.intel.com>
Wed, 30 Jun 2021 23:36:08 +0000 (19:36 -0400)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 2 Dec 2021 08:26:32 +0000 (09:26 +0100)
commitdc3b60841dbfa9cf37be3efb4568f055b4e15580
treee3c99e1a618b64e2886fd8bebb3493fad00d9ea6
parent81154c58da8aa516fc1acb1ae3429406dc734bb7
Reorganize inflate window layout

This commit significantly improves inflate performance by reorganizing the window buffer into a contiguous window and pending output buffer. The goal of this layout is to reduce branching, improve cache locality, and enable for the use of crc folding with gzip input.

The window buffer is allocated as a multiple of the user-selected window size. In this commit, a factor of 2 is utilized.

The layout of the window buffer is divided into two sections. The first section, window offset [0, wsize), is reserved for history that has already been output. The second section, window offset [wsize, 2 * wsize), is reserved for buffering pending output that hasn't been flushed to the user's output buffer yet.

The history section grows downwards, towards the window offset of 0. The pending output section grows upwards, towards the end of the buffer. As a result, all of the possible distance/length data that may need to be copied is contiguous. This removes the need to stitch together output from 2 separate buffers.

In the case of gzip input, crc folding is used to copy the pending output to the user's buffers.

Co-authored-by: Nathan Moinvaziri <nathan@nathanm.com>
infback.c
inffast.c
inffast.h
inflate.c
inflate.h
inflate_p.h
test/infcover.c