Source mirror for WetGrape egpu: dawn-zlib
  • C 79.4%
  • C++ 19.2%
  • CMake 1%
  • Roff 0.2%
Find a file
Michael Hoisie 456ae73001 [zlib] Overlap bitstream refill with Huffman table lookup in inflate
In the chunked inflate fast path (INFLATE_CHUNK_READ_64LE), inflate
previously refilled the 64-bit bit accumulator before indexing into the
Huffman tables. This created serialized dependency chains in the inflate
hot path:

  Load (input stream) -> Shift (bit accumulator) -> Load (Huffman table)

Moving the refills after the table address calculations changes the
execution sequence so the memory loads can happen in parallel:

  Load (input stream) -> Load (Huffman table) -> Shift (bit accumulator)

Because the loads are independent, modern out-of-order processors can
issue both memory requests concurrently rather than stalling the table
lookup on the input stream load.

Refilling after the distance table lookup means the distance code and
its extra bits always start from a full accumulator.

Add two dynamic-Huffman regression tests for worst-case bit consumption.

Here is a table with benchmark averages. The full benchmark results are
in a spreadsheet linked in the bug.

cpu                           class              level 6
----------------------------  -----------------  -------
EPYC 9B45 Turin (Zen 5)       server               7.86%
EPYC 9B14 Genoa (Zen 4)       server              11.21%
Xeon 8481C (Sapphire Rapids)  server               6.16%
Google Axion (Neoverse-V2)    server               8.89%
Ampere Altra (Neoverse-N1)    server               8.33%
Ryzen 9 9900X (Zen 5)         desktop              8.77%
Intel Xeon Ice Lake           server               8.21%
Pixel 8 Cortex-X3 (prime)     mobile prime         5.53%
Pixel 9 Cortex-X4 (prime)     mobile prime        10.13%
Pixel 8 Cortex-A510 (little)  mobile efficiency    5.56%
Pixel 9 Cortex-A520 (little)  mobile efficiency    8.37%
----------------------------  -----------------  -------
average across CPUs                                8.09%

Depends on https://chromium-review.googlesource.com/c/chromium/src/+/8422584
for macOS arm64 code coverage instrumentation flags.

Bug: 555022654, 562085582
Change-Id: Ia2e39cf49adec51ffa3d161fc3e2f961d23c1e08
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8312239
Auto-Submit: Michael Hoisie <hoisie@google.com>
Reviewed-by: Adenilson Cavalcanti <cavalcantii@chromium.org>
Reviewed-by: Hans Wennborg <hans@chromium.org>
Commit-Queue: Michael Hoisie <hoisie@google.com>
Cr-Commit-Position: refs/heads/main@{#1702310}
NOKEYCHECK=True
GitOrigin-RevId: ea7f42038188e90cbb8884160c980f9c679c7440
2026-09-21 19:11:37 -07:00
contrib [zlib] Overlap bitstream refill with Huffman table lookup in inflate 2026-09-21 19:11:37 -07:00
doc Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
examples Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
google zlib: Migrate zip_reader_unittest to TimeFormatAsIso8601 2026-08-10 22:29:38 -07:00
patches [minizip] Check LFH / CD encryption flag consistency 2026-06-23 10:19:25 -07:00
test Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
win32 [zlib] Add win32/zlib1.rc from upstream 2026-03-07 10:34:11 -08:00
adler32.c [zlib][riscv] Import RVV 1.0 based version of Adler-32. 2024-03-26 12:04:09 -07:00
adler32_simd.c [zlib][aosp] Set SIMD ISA per function via __target__ instead of module cflags 2026-08-20 05:56:26 -07:00
adler32_simd.h Update copyright headers in third_party/zlib/ 2022-09-27 12:32:57 -07:00
BUILD.gn Remove dead allow_circular_includes_from across several targets 2026-09-14 18:36:03 -07:00
chromeconf.h Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
CMakeLists.txt [zlib] Optimize longest_match with 64-bit SWAR compare256 2026-08-25 16:45:14 -07:00
compare256.h [zlib] Optimize longest_match with 64-bit SWAR compare256 2026-08-25 16:45:14 -07:00
compress.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
cpu_features.c [zlib][aosp] Set SIMD ISA per function via __target__ instead of module cflags 2026-08-20 05:56:26 -07:00
cpu_features.h [zlib][riscv] Import RVV 1.0 based version of Adler-32. 2024-03-26 12:04:09 -07:00
crc32.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
crc32.h [zlib] Re-sync with zlib 1.2.12, patch 11 of N 2022-04-22 00:58:07 -07:00
crc32_simd.c [zlib][x86] Fix AVX-512 CRC target features 2026-08-31 01:36:48 -07:00
crc32_simd.h [zlib][x86] Implement AVX-512 based CRC-32 checksum 2023-04-03 21:00:28 -07:00
crc_folding.c [zlib][aosp] Set SIMD ISA per function via __target__ instead of module cflags 2026-08-20 05:56:26 -07:00
deflate.c [zlib] Optimize longest_match with 64-bit SWAR compare256 2026-08-25 16:45:14 -07:00
deflate.h Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
DIR_METADATA [buganizer] Migrate remaining DIR_METADATA in third_party 2024-02-12 15:57:13 -08:00
gzclose.c [zlib] Sync with zlib 1.2.13.1, patch 2 of N 2023-05-31 15:18:07 -07:00
gzguts.h [zlib] Define EWOULDBLOCK if not defined already 2026-03-06 00:30:56 -08:00
gzlib.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
gzread.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
gzwrite.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
infback.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
inffast.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
inffast.h [zlib] Sync with zlib 1.2.13.1, patch 2 of N 2023-05-31 15:18:07 -07:00
inffixed.h Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
inflate.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
inflate.h Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
inftrees.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
inftrees.h Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
LICENSE Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
OWNERS Mark myself as a fallback reviewer for zlib. 2025-05-15 13:24:51 -07:00
README Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
README.chromium Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
slide_hash_simd.h Update copyright headers in third_party/zlib/ 2022-09-27 12:32:57 -07:00
trees.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
trees.h Update zlib to 1.2.5. 2011-12-12 08:48:38 +00:00
uncompr.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
zconf.h [zlib] Check whether HAVE_STDARG_H is defined before using it 2026-03-05 14:34:47 -08:00
zconf.h.in Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
zlib.3 Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
zlib.h Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
zlib.map Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
zlib.pc.cmakein Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
zlibConfig.cmake.in Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
zutil.c Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00
zutil.h Reland "[zlib] Update to v1.3.2" 2026-03-04 12:02:35 -08:00

ZLIB DATA COMPRESSION LIBRARY

zlib 1.3.2.1 is a general purpose data compression library.  All the code is
thread safe (though see the FAQ for caveats).  The data format used by the zlib
library is described by RFCs (Request for Comments) 1950 to 1952 at
https://datatracker.ietf.org/doc/html/rfc1950 (zlib format), rfc1951 (deflate
format) and rfc1952 (gzip format).

All functions of the compression library are documented in the file zlib.h
(volunteer to write man pages welcome, contact zlib@gzip.org).  A usage example
of the library is given in the file test/example.c which also tests that
the library is working correctly.  Another example is given in the file
test/minigzip.c.  The compression library itself is composed of all source
files in the root directory.

To compile all files and run the test program, follow the instructions given at
the top of Makefile.in.  In short "./configure; make test", and if that goes
well, "make install" should work for most flavors of Unix.  For Windows, use
one of the special makefiles in win32/ or contrib/vstudio/ .  For VMS, use
make_vms.com.

Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
<info@winimage.com> for the Windows DLL version.  The zlib home page is
https://zlib.net/ .  Before reporting a problem, please check this site to
verify that you have the latest version of zlib; otherwise get the latest
version and check whether the problem still exists or not.

PLEASE read the zlib FAQ https://zlib.net/zlib_faq.html before asking for help.

Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan.  1997
issue of Dr.  Dobb's Journal; a copy of the article is available at
https://zlib.net/nelson/ .

The changes made in version 1.3.2.1 are documented in the file ChangeLog.

Unsupported third party contributions are provided in directory contrib/ .

zlib is available in Java using the java.util.zip package. Follow the API
Documentation link at: https://docs.oracle.com/search/?q=java.util.zip .

A Perl interface to zlib and bzip2 written by Paul Marquess <pmqs@cpan.org>
can be found at https://github.com/pmqs/IO-Compress .

A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
available in Python 1.5 and later versions, see
https://docs.python.org/3/library/zlib.html .

zlib is built into tcl: https://wiki.tcl-lang.org/page/zlib .

An experimental package to read and write files in .zip format, written on top
of zlib by Gilles Vollant <info@winimage.com>, is available in the
contrib/minizip directory of zlib.


Notes for some targets:

- For Windows DLL versions, please see win32/DLL_FAQ.txt

- For 64-bit Irix, deflate.c must be compiled without any optimization. With
  -O, one libpng test fails. The test works in 32 bit mode (with the -n32
  compiler flag). The compiler bug has been reported to SGI.

- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
  when compiled with cc.

- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is
  necessary to get gzprintf working correctly. This is done by configure.

- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
  other compilers. Use "make test" to check your compiler.

- For PalmOs, see https://palmzlib.sourceforge.net/


Acknowledgments:

  The deflate format used by zlib was defined by Phil Katz.  The deflate and
  zlib specifications were written by L.  Peter Deutsch.  Thanks to all the
  people who reported problems and suggested various improvements in zlib; they
  are too numerous to cite here.

Copyright notice:

 (C) 1995-2026 Jean-loup Gailly and Mark Adler

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

  Jean-loup Gailly        Mark Adler
  jloup@gzip.org          madler@alumni.caltech.edu

If you use the zlib library in a product, we would appreciate *not* receiving
lengthy legal documents to sign.  The sources are provided for free but without
warranty of any kind.  The library has been entirely written by Jean-loup
Gailly and Mark Adler; it does not include third-party code.  We make all
contributions to and distributions of this project solely in our personal
capacity, and are not conveying any rights to any intellectual property of
any third parties.

If you redistribute modified sources, we would appreciate that you include in
the file ChangeLog history information documenting your changes.  Please read
the FAQ for more information on the distribution of modified source versions.