]> git.ipfire.org Git - thirdparty/zlib-ng.git/log
thirdparty/zlib-ng.git
2 days agoIf runtime CPU detection is disabled then define native_* macros to generic fallbacks... develop
Vladislav Shchapov [Sat, 16 May 2026 04:38:14 +0000 (09:38 +0500)] 
If runtime CPU detection is disabled then define native_* macros to generic fallbacks only if native_* macros is not previous defined.

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2 days agoShow --benchmark_cooldown in benchmark_zlib --help output
Nathan Moinvaziri [Sun, 17 May 2026 02:14:58 +0000 (19:14 -0700)] 
Show --benchmark_cooldown in benchmark_zlib --help output

Use the custom help printer callback in benchmark::Initialize to
append the --benchmark_cooldown flag to the standard help text.

3 days agoPass local window variable to quit_insert_string and insert_string functions.
Hans Kristian Rosbach [Mon, 11 May 2026 18:36:50 +0000 (20:36 +0200)] 
Pass local window variable to quit_insert_string and insert_string functions.

3 days agoUse local block_start and window variables in FLUSH_BLOCK.
Hans Kristian Rosbach [Mon, 11 May 2026 18:01:26 +0000 (20:01 +0200)] 
Use local block_start and window variables in FLUSH_BLOCK.
Also ensure all deflate methods use local window variable.
deflate_medium now passes local window to its static functions.

4 days agoSplit out writing deflate headers into a separate function, keeping the
Hans Kristian Rosbach [Tue, 12 May 2026 13:50:06 +0000 (15:50 +0200)] 
Split out writing deflate headers into a separate function, keeping the
deflate hot-path clean. This only benefits cases where you call deflate()
multiple times to provide more data.

4 days agoTest building with ClangCl for Windows ARM64
Mika Lindqvist [Mon, 4 May 2026 15:08:08 +0000 (18:08 +0300)] 
Test building with ClangCl for Windows ARM64

4 days agoUse Intel(R) Software Development Emulator for run tests on emulated Sapphire Rapids CPU
Vladislav Shchapov [Mon, 11 May 2026 14:30:24 +0000 (19:30 +0500)] 
Use Intel(R) Software Development Emulator for run tests on emulated Sapphire Rapids CPU

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
6 days agoMake CRC32 checking of headers use crc32_small directly, instead of taking
Hans Kristian Rosbach [Thu, 14 May 2026 11:06:45 +0000 (13:06 +0200)] 
Make CRC32 checking of headers use crc32_small directly, instead of taking
a detour through functable to spin up a vector optimized function when the
header is too small to be handled by it.
CRC2 and CRC4 call CRC_DO1_B macro directly since knowing the exact size
lets us inline a very small crc implementation.

6 days agoRename single-letter size-table awk variables.
Nathan Moin Vaziri [Thu, 14 May 2026 20:59:48 +0000 (13:59 -0700)] 
Rename single-letter size-table awk variables.

The awk block parsing the size command output used bt/bd/bb/bD for
base values and dt/dd/db/dD for deltas, with case-only distinction
between bd (data) and bD (dec) that's easy to misread. Spell them out
as base_text/base_data/base_bss/base_dec and d_text/d_data/d_bss/d_dec
for legibility.

6 days agoShow stripped library file size in delta workflow.
Nathan Moin Vaziri [Thu, 14 May 2026 19:04:25 +0000 (12:04 -0700)] 
Show stripped library file size in delta workflow.

The size table reports text/data/bss/dec from the size command, which
sums section sizes but doesn't account for ELF segment alignment padding.
A delta can show up in the dec column without changing the on-disk byte
count of the shipped .so. Add a row reporting the actual file size of
the stripped library so the shipping deliverable is visible alongside
the segment accounting.

6 days agoInline NEON_accum32 into adler32_copy_impl
Nathan Moinvaziri [Sun, 15 Mar 2026 02:47:21 +0000 (19:47 -0700)] 
Inline NEON_accum32 into adler32_copy_impl

Remove the separate NEON_accum32 function and inline its body
directly into the adler32_copy_impl loop. This eliminates the
function call boundary and lets src/dst pointers advance
naturally through the NEON processing iterations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6 days agoCombine NEON_accum32_copy and NEON_accum32 into single function
Nathan Moinvaziri [Sun, 15 Mar 2026 02:43:49 +0000 (19:43 -0700)] 
Combine NEON_accum32_copy and NEON_accum32 into single function

Use a const int COPY parameter to select between the copy and
non-copy paths, matching the pattern used by adler32_copy_impl.
The copy variant uses 4x individual loads+stores (better ILP),
while the non-copy variant uses a single ld1x4 quad load.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6 days agoRemove obsolete padding in deflate and inflate state.
Hans Kristian Rosbach [Tue, 12 May 2026 18:01:26 +0000 (20:01 +0200)] 
Remove obsolete padding in deflate and inflate state.
Reorder some elements to better pack and improve cache-locality in deflate state.

8 days ago[CI] Add Cygwin with gcc.
Mika T. Lindqvist [Mon, 11 May 2026 05:54:55 +0000 (08:54 +0300)] 
[CI] Add Cygwin with gcc.

8 days ago[CI] Cleanup action caches.
Mika T. Lindqvist [Tue, 12 May 2026 07:53:45 +0000 (10:53 +0300)] 
[CI] Cleanup action caches.

8 days ago[CI] Extend caching apt packages to pigz workflow.
Mika T. Lindqvist [Tue, 12 May 2026 20:54:18 +0000 (23:54 +0300)] 
[CI] Extend caching apt packages to pigz workflow.

10 days agoFix scan_endstr offset in longest_match slow path.
Nathan Moin Vaziri [Sat, 11 Apr 2026 03:38:29 +0000 (20:38 -0700)] 
Fix scan_endstr offset in longest_match slow path.

LONGEST_MATCH_SLOW was using len - (STD_MIN_MATCH+1) instead of
len - (STD_MIN_MATCH-1) for the end-of-string hash probe, hashing a
window inside the already-matched region instead of ending one byte
past the current match. The slow path was missing match extensions
it should have been finding. The comment and the upstream fast_zlib
source both specify the correct offset.

Closes #2248.

Reported-by: Sergey "Shnatsel" Davidoff <291257+Shnatsel@users.noreply.github.com>
Reported-by: Folkert de Vries <7949978+folkertdev@users.noreply.github.com>
12 days agoMove shared code to composite actions.
Mika Lindqvist [Thu, 7 May 2026 21:28:46 +0000 (00:28 +0300)] 
Move shared code to composite actions.

12 days ago[CI] Cache Ubuntu .deb packages to speed up installing dependencies.
Mika Lindqvist [Tue, 5 May 2026 22:33:15 +0000 (01:33 +0300)] 
[CI] Cache Ubuntu .deb packages to speed up installing dependencies.
* Purge old packages and unneeded dependencies before copying remaining packages to cached directory

2 weeks agoAdd /delta workflow for loongarch64
Vladislav Shchapov [Tue, 5 May 2026 13:16:58 +0000 (18:16 +0500)] 
Add /delta workflow for loongarch64

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2 weeks ago[CI] Force refreshing homebrew for macOS.
Mika Lindqvist [Wed, 6 May 2026 14:53:37 +0000 (17:53 +0300)] 
[CI] Force refreshing homebrew for macOS.

2 weeks ago[CI] Use older runner for Visual Studio 2022 jobs.
Mika Lindqvist [Wed, 6 May 2026 01:19:12 +0000 (04:19 +0300)] 
[CI] Use older runner for Visual Studio 2022 jobs.

2 weeks agoWhen using ALIGN_DOWN() macro, the signedness of types must match to avoid UBSAN...
Mika Lindqvist [Tue, 5 May 2026 19:59:27 +0000 (22:59 +0300)] 
When using ALIGN_DOWN() macro, the signedness of types must match to avoid UBSAN triggering warning about implicit sign change during widening.

2 weeks agoAdd early return when prev_length already exceeds lookahead
Nathan Moin Vaziri [Sun, 12 Apr 2026 17:00:09 +0000 (10:00 -0700)] 
Add early return when prev_length already exceeds lookahead

Near end-of-input the caller's prev_length can exceed the
current lookahead, making the chain walk pointless since no
match can be longer than the available input. The non-slow
path never clamped this case — break_matching was slow-path
only — leaving the output contract unguarded.

Together with the existing `if (len >= lookahead)` early
return in the update block — which stops the chain walk as
soon as a match reaches lookahead — this ensures no
unnecessary chain steps are taken. madler/zlib does the full
chain walk when prev_length exceeds lookahead and clamps
best_len at the function exit resulting in extra work.

2 weeks agoRemove dead break_matching label from longest_match
Nathan Moin Vaziri [Sun, 12 Apr 2026 17:01:47 +0000 (10:01 -0700)] 
Remove dead break_matching label from longest_match

The lookahead guard at break_matching is unreachable because
the early return `if (len >= lookahead) return lookahead` fires
before best_len is ever assigned, keeping best_len < lookahead
as a loop invariant. Replace the three goto sites with direct
returns and delete the label entirely.

2 weeks agoAllow /delta on fork pull requests
Nathan Moin Vaziri [Mon, 4 May 2026 20:47:20 +0000 (13:47 -0700)] 
Allow /delta on fork pull requests

The author_association gate already restricts triggers to OWNER, MEMBER,
or COLLABORATOR, so a maintainer running /delta on a fork PR carries the
same trust as checking the PR out locally. Drop the fork rejection and
the unused base/head repo id parsing.

2 weeks ago[CI] Use gcov from MinGW32 when generating coverage for 32-bit builds.
Mika Lindqvist [Mon, 4 May 2026 19:01:15 +0000 (22:01 +0300)] 
[CI] Use gcov from MinGW32 when generating coverage for 32-bit builds.

2 weeks agodeflate_rle: remove unnecessary check for too long matches
Hans Kristian Rosbach [Mon, 4 May 2026 19:38:27 +0000 (21:38 +0200)] 
deflate_rle: remove unnecessary check for too long matches

2 weeks agoDeflate_fast does not have 'prev_length', fix comment.
Hans Kristian Rosbach [Sun, 3 May 2026 18:07:34 +0000 (20:07 +0200)] 
Deflate_fast does not have 'prev_length', fix comment.

3 weeks agoFix check against BUILD_ALT_BENCH that was always defined as OFF
Nathan Moin Vaziri [Wed, 22 Apr 2026 20:50:58 +0000 (13:50 -0700)] 
Fix check against BUILD_ALT_BENCH that was always defined as OFF

3 weeks agoAdd PNG decode benchmark for narrow image widths
Nathan Moinvaziri [Thu, 26 Mar 2026 19:11:59 +0000 (12:11 -0700)] 
Add PNG decode benchmark for narrow image widths

Benchmark libpng row-by-row decoding where avail_out falls
below the 260-byte inflate_fast threshold. Uses a synthetic
gradient-with-noise pixel generator that produces deflate
token distributions representative of real photographs.
Also fix encode_png to use the passed width and height
instead of the hardcoded IMWIDTH and IMHEIGHT constants.

3 weeks agoFix libpng linking and include paths for benchmark apps
Nathan Moinvaziri [Thu, 26 Mar 2026 17:51:33 +0000 (10:51 -0700)] 
Fix libpng linking and include paths for benchmark apps

The FetchContent path was missing the binary directory from
PNG_INCLUDE_DIR, causing pnglibconf.h not to be found. The
link target was hardcoded to libpng.a which does not resolve
when libpng is built via FetchContent. Use png_static as the
CMake target when fetched, and normalize both paths through
PNG_STATIC_LIBRARY and PNG_INCLUDE_DIR variables.

3 weeks agoBump actions/cache from 4 to 5
dependabot[bot] [Fri, 1 May 2026 07:52:33 +0000 (07:52 +0000)] 
Bump actions/cache from 4 to 5

Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
3 weeks agoBump actions/checkout from 4 to 6
dependabot[bot] [Fri, 1 May 2026 07:52:30 +0000 (07:52 +0000)] 
Bump actions/checkout from 4 to 6

Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
3 weeks agoBump mymindstorm/setup-emsdk from 14 to 16
dependabot[bot] [Fri, 1 May 2026 07:52:24 +0000 (07:52 +0000)] 
Bump mymindstorm/setup-emsdk from 14 to 16

Bumps [mymindstorm/setup-emsdk](https://github.com/mymindstorm/setup-emsdk) from 14 to 16.
- [Release notes](https://github.com/mymindstorm/setup-emsdk/releases)
- [Commits](https://github.com/mymindstorm/setup-emsdk/compare/v14...v16)

---
updated-dependencies:
- dependency-name: mymindstorm/setup-emsdk
  dependency-version: '16'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
3 weeks agoOptimize adler32_swar alignment and remove platform conditionals
Nathan Moinvaziri [Thu, 19 Mar 2026 19:28:22 +0000 (12:28 -0700)] 
Optimize adler32_swar alignment and remove platform conditionals

3 weeks agoCall adler32_c directly in adler32_copy_c scalar fallback
Nathan Moinvaziri [Tue, 17 Mar 2026 02:03:25 +0000 (19:03 -0700)] 
Call adler32_c directly in adler32_copy_c scalar fallback

The generic copy function was calling through the function
table, which dispatched to the best SIMD implementation
instead of the scalar path. This led to incorrect benchmarks
for adler32_copy/c since it measured the SIMD path rather
than the scalar fallback. Call adler32_c directly so the
scalar copy variant actually exercises the scalar checksum.

3 weeks agoAdd SWAR scalar adler32 for 64-bit platforms with unaligned access
Michael Niedermayer [Sun, 15 Mar 2026 08:03:47 +0000 (01:03 -0700)] 
Add SWAR scalar adler32 for 64-bit platforms with unaligned access

Borrows the SWAR (SIMD Within A Register) technique from FFmpeg's
libavutil/adler32.c by Michael Niedermayer. The original splits each
8-byte load into even/odd byte lanes packed as 4x16-bit accumulators
in a uint64_t, with a running prefix sum for the s2 contribution, and
a final reduction using multiply-and-shift with positional weight
constants. The chunk size is capped at 23 iterations of 8 bytes (184
bytes) to keep the 16-bit accumulators from overflowing.

Our improvements over the original FFmpeg implementation:
  - Process 16 bytes per iteration (two 64-bit loads) instead of 8,
    halving loop overhead while staying within the 23-iteration limit.
  - Handle an 8-byte remainder after the 16-byte loop so no bytes
    fall through to the slow scalar path unnecessarily.
  - Applied to both the NMAX inner loop (adler32_c) and the combined
    copy+checksum tail path (adler32_copy_tail) for all callers.

Benchmark results (AArch64, Apple M3, 10 repetitions):
  adler32_c 4MB:   1,131,242 ns -> 232,708 ns  (-79.4%)
  adler32_c 256KB:    70,672 ns ->  14,384 ns  (-79.7%)
  adler32_c 4KB:       1,105 ns ->     228 ns  (-79.3%)
  adler32_c 512B:        141 ns ->      29 ns  (-79.3%)
  adler32_c 64B:          20 ns ->       6 ns  (-69.6%)

https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/adler32.c

Co-Authored-By: Nathan Moinvaziri <nathan@nathanm.com>
3 weeks agoSimplify safe-mode copy path selection in inflate_fast
Nathan Moinvaziri [Wed, 25 Mar 2026 00:34:05 +0000 (17:34 -0700)] 
Simplify safe-mode copy path selection in inflate_fast

The branch structure now tests safe_mode directly, which is clearer and
produces the same code on all platforms. No functional change to the copy
operations used.

3 weeks agoAdd inflateBack test for safe mode bailout MATCH state handler
Nathan Moinvaziri [Tue, 10 Mar 2026 21:28:50 +0000 (14:28 -0700)] 
Add inflateBack test for safe mode bailout MATCH state handler

3 weeks agoImprove inflate_fast performance for small output buffers
Nathan Moinvaziri [Tue, 10 Mar 2026 19:00:02 +0000 (12:00 -0700)] 
Improve inflate_fast performance for small output buffers

Lowers the inflate_fast entry threshold from 260 to 3 bytes of
available output by adding a safe_mode parameter that uses
bounds-checked copies and bails to the MATCH state when output
space is insufficient. This eliminates the performance cliff
where libpng-style row-by-row decompression falls back to the
slow inflate path for the last 260 bytes of each row.

3 weeks agoReplace small/large buffer tests with parameterized test_chunked
Nathan Moinvaziri [Tue, 14 Apr 2026 03:20:26 +0000 (20:20 -0700)] 
Replace small/large buffer tests with parameterized test_chunked

test_large_buffers reset d_stream.next_out on every inflate iteration, so the
decompressed output was never compared against the source. test_chunked keeps
the input, compressed, and decompressed buffers separate and checks them with
memcmp.

New avail_out values (3, 64, 128, 256, 259) exercise inflate_fast()'s safe-mode
MATCH-state bailout around the 258-byte maximum match length.

4 weeks agoBump Google Benchmark to v1.9.5
Mika T. Lindqvist [Thu, 23 Apr 2026 11:46:39 +0000 (14:46 +0300)] 
Bump Google Benchmark to v1.9.5
* Google Benchmark v1.9.4 fails to compile with recent versions of clang and Visual C++ if warnings are treated as errors

4 weeks agoAdd compressed and ratio fields to deflate/corpora benchmarks
Nathan Moin Vaziri [Mon, 13 Apr 2026 05:27:42 +0000 (22:27 -0700)] 
Add compressed and ratio fields to deflate/corpora benchmarks

4 weeks agoAdd corpora benchmarks for deflate and inflate
Nathan Moin Vaziri [Wed, 8 Apr 2026 01:17:52 +0000 (18:17 -0700)] 
Add corpora benchmarks for deflate and inflate

Adds benchmark_corpora.cc which dynamically discovers and benchmarks
all files from the zlib-ng/corpora repository (silesia, calgary,
canterbury, large, snappy, etc.).

Benchmarks are registered at startup using RegisterBenchmark. If the
corpora directory is not present, no benchmarks are registered.
Deflate is tested at levels 1, 6, and 9 per file. Inflate is tested
once per file using data pre-compressed at level 9.

4 weeks agoAdd --benchmark_cooldown flag to mitigate thermal throttling
Nathan Moin Vaziri [Wed, 8 Apr 2026 01:10:20 +0000 (18:10 -0700)] 
Add --benchmark_cooldown flag to mitigate thermal throttling

Adds a --benchmark_cooldown=<seconds> flag that inserts a sleep between
benchmark families. This helps produce consistent results on systems
where sustained workloads cause thermal throttling and CPU frequency
scaling.

Uses a wrapping BenchmarkReporter that sleeps before forwarding results
to the default display reporter.

4 weeks agoAdd /delta workflow for per-PR binary size comparison
Nathan Moin Vaziri [Tue, 14 Apr 2026 18:01:39 +0000 (11:01 -0700)] 
Add /delta workflow for per-PR binary size comparison

On a /delta PR comment the job builds the PR head and base with
RelWithDebInfo, splits the DWARF into sibling .debug companions, and
runs several tools against both stripped libraries:

- binutils size for text/data/bss totals plus a Δ row
- bloaty for sections, top 30 compile units, and top 30 symbols
- nm --defined-only --dynamic to diff the exported symbol set
- abidiff for C ABI changes (honouring test/abi/ignore)
- minigzip at levels 1-9 over silesia-small.tar and, on native
  builds, the full silesia.tar

Results come back as a "## Delta Report" PR comment with a details
block per section, reporting both head and base SHAs so offset runs
are unambiguous.

Comment syntax is /delta [arch] [-N]. Arch defaults to x86_64 and
accepts aarch64, powerpc64le, riscv64, and s390x. -N selects the Nth
commit back from the PR head so a regression can be bisected without
force-pushing. Cross-compile builds reuse cmake/toolchain-*.cmake
and run the stripped binaries under qemu-user.

4 weeks agoUse fallback defines for Chorba Scalar/SSE
Nathan Moinvaziri [Wed, 18 Feb 2026 08:29:00 +0000 (00:29 -0800)] 
Use fallback defines for Chorba Scalar/SSE

Gate Scalar and SSE chorba uniformly on CRC32_CHORBA_FALLBACK and
CRC32_CHORBA_SSE_FALLBACK across prototypes, dispatch, sources, tests
and benchmarks instead of spot-checking WITHOUT_CHORBA /
WITHOUT_CHORBA_SSE directly at each site.

Also move crc32_chorba_c.c into ZLIB_GENERIC_SRCS and align Makefile.in
to match so the CMake and autotools builds stay bit-identical.

4 weeks agoRemove inert comment about disabling Chorba SSE in X86 functions header
Nathan Moin Vaziri [Sat, 18 Apr 2026 21:16:40 +0000 (14:16 -0700)] 
Remove inert comment about disabling Chorba SSE in X86 functions header

This was never correct, it should have been WITHOUT_CHORBA_SSE not NO_CHORBA_SSE

4 weeks agoFix typo in No Chorba CMake option name in CI
Nathan Moin Vaziri [Sat, 18 Apr 2026 20:49:12 +0000 (13:49 -0700)] 
Fix typo in No Chorba CMake option name in CI

The 'Ubuntu GCC No Chorba' matrix entry was passing -DWITH_CHORBA=OFF
since its introduction in 9d4af458, but the actual CMake option is
named WITH_CRC32_CHORBA.

4 weeks agoRemove CMake warning about MSVC Chorba bug
Nathan Moin Vaziri [Sat, 18 Apr 2026 20:52:57 +0000 (13:52 -0700)] 
Remove CMake warning about MSVC Chorba bug

The Chorba bug on SSE2/SSE41 has been fixed so this no longer applies.

4 weeks agoMerge duplicate 32-bit _mm_cvtsi64_si128 polyfills
Nathan Moin Vaziri [Fri, 17 Apr 2026 20:23:52 +0000 (13:23 -0700)] 
Merge duplicate 32-bit _mm_cvtsi64_si128 polyfills

The MSVC and GCC 32-bit polyfills for _mm_cvtsi64_si128 /
_mm_cvtsi128_si64 had identical bodies. Merge them into a single
block guarded by !__clang__ && ARCH_32BIT, with the MSVC-only
#include <intrin.h> nested inside.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 weeks agoFix MSVC v142 miscompile of _mm_cvtsi64_si128 polyfill on 32-bit
Nathan Moin Vaziri [Fri, 17 Apr 2026 20:22:49 +0000 (13:22 -0700)] 
Fix MSVC v142 miscompile of _mm_cvtsi64_si128 polyfill on 32-bit

MSVC v142 (Visual Studio 2019, and VS 2022 pre-17.11) miscompiles
_mm_set_epi64x(0, a) on 32-bit Windows by routing part of the synthesis
through a GPR, clobbering live register data and causing stack corruption
in the chorba SSE2/SSE4.1 CRC32 code paths.

Replace the _mm_set_epi64x(0, a) polyfill with _mm_loadl_epi64 which
compiles to a single MOVQ xmm,m64 that bypasses the buggy synthesis
path. Also convert the GCC 32-bit _mm_cvtsi64_si128 macro to a static
inline for consistency, and drop the redundant ARCH_X86 guard since
x86_intrins.h is only reachable from x86 code.

https://developercommunity.visualstudio.com/t/10853479

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 weeks agoFix UBSAN implicit conversion warning in test/fuzz/fuzzer_example_flush.c.
Hans Kristian Rosbach [Wed, 15 Apr 2026 13:31:48 +0000 (15:31 +0200)] 
Fix UBSAN implicit conversion warning in test/fuzz/fuzzer_example_flush.c.

5 weeks agoFix UBSAN implicit conversion warning in test/test_deflate_concurrency.cc.
Hans Kristian Rosbach [Wed, 15 Apr 2026 12:58:44 +0000 (14:58 +0200)] 
Fix UBSAN implicit conversion warning in test/test_deflate_concurrency.cc.

5 weeks agoFix UBSAN implicit conversion warning in test/test_shared_ng.h.
Hans Kristian Rosbach [Wed, 15 Apr 2026 12:27:27 +0000 (14:27 +0200)] 
Fix UBSAN implicit conversion warning in test/test_shared_ng.h.

5 weeks agoFix UBSAN implicit conversion warning in arch/s390/crc32_vx.c.
Hans Kristian Rosbach [Wed, 15 Apr 2026 12:13:20 +0000 (14:13 +0200)] 
Fix UBSAN implicit conversion warning in arch/s390/crc32_vx.c.

5 weeks agoFix UBSAN implicit conversion warning in inftrees.c.
Hans Kristian Rosbach [Wed, 15 Apr 2026 11:39:54 +0000 (13:39 +0200)] 
Fix UBSAN implicit conversion warning in inftrees.c.

Co-authored-by: Nathan Moin Vaziri <nathan@nathanm.com>
5 weeks agoCMake: Add 'implicit-conversion' and 'nullability' to sanitizers
Hans Kristian Rosbach [Mon, 2 Mar 2026 21:12:58 +0000 (22:12 +0100)] 
CMake: Add 'implicit-conversion' and 'nullability' to sanitizers
we attempt to enable with ubsan builds.

5 weeks agoRename longest_match_slow to longest_match_roll
Nathan Moin Vaziri [Mon, 13 Apr 2026 22:26:24 +0000 (15:26 -0700)] 
Rename longest_match_slow to longest_match_roll

The "slow" variant of longest_match uses a 3-byte rolling hash to seed
its offset-search lookups after a match has been found. Rename the
template gate, the functable entry, and all arch-specific instantiations
from *_slow to *_roll to reflect what the variant actually uses, so a
separate integer-hash offset-search variant can coexist under its own
name.

Pure rename, no behavior change.

5 weeks agoAdd small output buffer inflate benchmark #2062
Nathan Moinvaziri [Tue, 14 Apr 2026 02:00:09 +0000 (19:00 -0700)] 
Add small output buffer inflate benchmark #2062

Benchmarks the inflate fast path with constrained output
buffers ranging from 64 to 16384 bytes per call, reproducing
the libpng decompression pattern described in the "running
off a cliff" analysis.

https://nigeltao.github.io/blog/2021/fastest-safest-png-decoder.html#running-off-a-cliff

5 weeks agoRemove macro and inline inflate benchmark definition directly
Nathan Moinvaziri [Tue, 10 Mar 2026 18:40:39 +0000 (11:40 -0700)] 
Remove macro and inline inflate benchmark definition directly

5 weeks agoFix VPCLMULQDQ CRC32 build with partial AVX-512 baselines
Nathan Moin Vaziri [Fri, 10 Apr 2026 20:29:05 +0000 (13:29 -0700)] 
Fix VPCLMULQDQ CRC32 build with partial AVX-512 baselines

The 512-bit path in crc32_pclmulqdq_tpl.h assumed AVX-512F was
enough, but some of the intrinsics it used actually require
AVX-512DQ. Pick the correct variants based on the available
features.

5 weeks agoAdd fallback defines to skip generic C code when native intrinsics exist
Nathan Moinvaziri [Tue, 10 Mar 2026 06:41:45 +0000 (23:41 -0700)] 
Add fallback defines to skip generic C code when native intrinsics exist

Each arch header now sets *_FALLBACK defines (ADLER32_FALLBACK,
CHUNKSET_FALLBACK, COMPARE256_FALLBACK, CRC32_BRAID_FALLBACK,
SLIDE_HASH_FALLBACK) when no native SIMD implementation exists.
Generic C source files, declarations, functable entries, tests,
and benchmarks are guarded by these defines.

5 weeks agoUse __attribute__((constructor)) to initialize the functable
Vladislav Shchapov [Sun, 22 Mar 2026 14:43:46 +0000 (19:43 +0500)] 
Use __attribute__((constructor)) to initialize the functable

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
5 weeks ago[CI] Switch CMake workflow to use MSYS2 for MinGW32.
Mika Lindqvist [Mon, 13 Apr 2026 17:34:38 +0000 (20:34 +0300)] 
[CI] Switch CMake workflow to use MSYS2 for MinGW32.

5 weeks agoAdd ACCUM_ROUND macro to crc32_chorba_sse2
Nathan Moin Vaziri [Fri, 3 Apr 2026 00:16:27 +0000 (17:16 -0700)] 
Add ACCUM_ROUND macro to crc32_chorba_sse2

5 weeks agoAdd ACCUM_ROUND macro to crc32_chorba_c
Nathan Moin Vaziri [Thu, 2 Apr 2026 04:38:16 +0000 (21:38 -0700)] 
Add ACCUM_ROUND macro to crc32_chorba_c

5 weeks agoAdd NEXT_ROUND macro in crc32_chorba_c
Nathan Moin Vaziri [Thu, 2 Apr 2026 04:33:23 +0000 (21:33 -0700)] 
Add NEXT_ROUND macro in crc32_chorba_c

5 weeks agoFix formatting in crc32_chorba_c
Nathan Moin Vaziri [Thu, 2 Apr 2026 04:35:31 +0000 (21:35 -0700)] 
Fix formatting in crc32_chorba_c

5 weeks agoFix formatting in crc32_chorba_sse41
Nathan Moin Vaziri [Thu, 2 Apr 2026 04:11:21 +0000 (21:11 -0700)] 
Fix formatting in crc32_chorba_sse41

5 weeks agoFix formatting for crc32_chorba_sse2.
Nathan Moin Vaziri [Thu, 2 Apr 2026 04:04:41 +0000 (21:04 -0700)] 
Fix formatting for crc32_chorba_sse2.

This should fix a bunch of CodeQL warnings about commented code.

5 weeks agocrc32: use may_alias for chorba buffers
cl2t [Sat, 14 Mar 2026 06:17:20 +0000 (14:17 +0800)] 
crc32: use may_alias for chorba buffers

5 weeks agocrc32: zero initialize chorba bitbuffer
cl2t [Sat, 14 Mar 2026 03:36:16 +0000 (11:36 +0800)] 
crc32: zero initialize chorba bitbuffer

5 weeks agoExtract fold_block_chorba function for PCLMULQDQ path
Nathan Moinvaziri [Thu, 12 Mar 2026 19:58:31 +0000 (12:58 -0700)] 
Extract fold_block_chorba function for PCLMULQDQ path

5 weeks agoExtract fold_block_16/8 functions for VPCLMULQDQ paths
Nathan Moinvaziri [Thu, 12 Mar 2026 19:36:27 +0000 (12:36 -0700)] 
Extract fold_block_16/8 functions for VPCLMULQDQ paths

5 weeks ago[CI] Add configure MinGW32/MinGW64 workflows.
Mika Lindqvist [Sat, 11 Apr 2026 20:41:49 +0000 (23:41 +0300)] 
[CI] Add configure MinGW32/MinGW64 workflows.

5 weeks agoMove chunk_{128,256}bit_perm_idx_lut.h, chunk_permute_table.h to arch/shared.
Vladislav Shchapov [Mon, 30 Mar 2026 08:03:59 +0000 (13:03 +0500)] 
Move chunk_{128,256}bit_perm_idx_lut.h, chunk_permute_table.h to arch/shared.

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
5 weeks agoFix loongarch64 name in crc32_copy benchmark.
Vladislav Shchapov [Mon, 30 Mar 2026 07:57:32 +0000 (12:57 +0500)] 
Fix loongarch64 name in crc32_copy benchmark.

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
5 weeks agoReuse unrolled ARMv8 CRC32 implementation for LoongArch64.
Vladislav Shchapov [Fri, 27 Mar 2026 21:39:33 +0000 (02:39 +0500)] 
Reuse unrolled ARMv8 CRC32 implementation for LoongArch64.

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
5 weeks agoConvert crc32_armv8_align, crc32_armv8_tail and crc32_copy_impl functions to template.
Vladislav Shchapov [Fri, 27 Mar 2026 21:19:39 +0000 (02:19 +0500)] 
Convert crc32_armv8_align, crc32_armv8_tail and crc32_copy_impl functions to template.

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
5 weeks ago[CI] Build MSVC 2026 C23 with benchmarks.
Mika Lindqvist [Sat, 11 Apr 2026 19:00:54 +0000 (22:00 +0300)] 
[CI] Build MSVC 2026 C23 with benchmarks.

5 weeks agoAdd back zng_clz for big-endian and use macro for compare256
Nathan Moinvaziri [Tue, 17 Mar 2026 06:35:05 +0000 (23:35 -0700)] 
Add back zng_clz for big-endian and use macro for compare256

6 weeks agoMove S390 VX vector typedefs into vx_intrins.h
Nathan Moein Vaziri [Thu, 2 Apr 2026 02:23:27 +0000 (19:23 -0700)] 
Move S390 VX vector typedefs into vx_intrins.h

The `vector` keyword requires -fzvector which is not available on all
GCC versions (e.g. EL10). Use __attribute__((vector_size(16))) typedefs
instead, matching the existing style in crc32_vx.c.

6 weeks agoAdd compatibility header for VX instructions
Nathan Moein Vaziri [Thu, 2 Apr 2026 01:08:26 +0000 (18:08 -0700)] 
Add compatibility header for VX instructions

GCC/Clang don't support vec_sub or vec_subs, but IBM compiler does.

6 weeks agoAdd slide hash optimization for S390 VX
Nathan Moinvaziri [Tue, 17 Mar 2026 07:20:57 +0000 (00:20 -0700)] 
Add slide hash optimization for S390 VX

We can clean up the build system and combine checks for VGFMA since
they are part of base VX instruction set.

6 weeks agoFix building GH1235 test for 32-bit MinGW
Mika T. Lindqvist [Tue, 7 Apr 2026 17:57:08 +0000 (20:57 +0300)] 
Fix building GH1235 test for 32-bit MinGW

```
C:/build/git/zlib-ng/test/gh1235.c: In function 'main':
C:/build/git/zlib-ng/test/gh1235.c:34:43: error: passing argument 2 of 'compress2' from incompatible pointer type [-Wincompatible-pointer-types]
   34 |         if (PREFIX(compress2)(compressed, &bytes, plain, i, 1) != Z_OK) return -1;
      |                                           ^~~~~~
      |                                           |
      |                                           z_size_t * {aka unsigned int *}
In file included from C:/build/git/zlib-ng/zutil.h:15,
                 from C:/build/git/zlib-ng/test/gh1235.c:4:
../zlib.h:1261:69: note: expected 'long unsigned int *' but argument is of type 'z_size_t *' {aka 'unsigned int *'}
 1261 | Z_EXTERN int Z_EXPORT compress2(unsigned char *dest, unsigned long *destLen, const unsigned char *source,
      |                                                      ~~~~~~~~~~~~~~~^~~~~~~
```

8 weeks agoUpdate s390x actions runner docker build scripts
Hans Kristian Rosbach [Mon, 23 Mar 2026 18:35:05 +0000 (19:35 +0100)] 
Update s390x actions runner docker build scripts

2 months agoAdd an altivec variant of "count_lengths" in inftrees
Adam Stylinski [Sat, 7 Mar 2026 17:43:02 +0000 (12:43 -0500)] 
Add an altivec variant of "count_lengths" in inftrees

This accounts for a small bump in performance

2 months agoUpdate e2k cross compiler to version lcc-1.29.16
Vladislav Shchapov [Fri, 13 Mar 2026 15:55:47 +0000 (20:55 +0500)] 
Update e2k cross compiler to version lcc-1.29.16

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2 months agoRemove check that is always true (even if WANT_MIN_MATCH was reduced from 4 to 3).
Hans Kristian Rosbach [Thu, 12 Mar 2026 19:31:30 +0000 (20:31 +0100)] 
Remove check that is always true (even if WANT_MIN_MATCH was reduced from 4 to 3).

2 months agoAvoid calling fizzle_matches unless checks pass
Hans Kristian Rosbach [Thu, 12 Mar 2026 16:00:39 +0000 (17:00 +0100)] 
Avoid calling fizzle_matches unless checks pass

2 months ago- Add local variables match_len and strstart in insert_match, to avoid extra lookups...
Hans Kristian Rosbach [Thu, 12 Mar 2026 15:35:50 +0000 (16:35 +0100)] 
- Add local variables match_len and strstart in insert_match, to avoid extra lookups from struct.
- Move check for enough lookahead outside of function, can avoid function call
  instead of calling and immediately returning.

2 months ago- Add local variable match_len in emit_match to avoid extra lookups from struct.
Hans Kristian Rosbach [Thu, 12 Mar 2026 14:32:09 +0000 (15:32 +0100)] 
- Add local variable match_len in emit_match to avoid extra lookups from struct.
- Move s->lookahead decrement to top of function, both branches of the function
does it and they don't care when it is done.

2 months agoAdd copy fallback for Adler32 ARM when building with no-unaligned-access
Nathan Moinvaziri [Thu, 12 Mar 2026 03:03:11 +0000 (20:03 -0700)] 
Add copy fallback for Adler32 ARM when building with no-unaligned-access

2 months agoUnroll 64-byte CRC32+copy loop for ARMv8
Nathan Moinvaziri [Fri, 13 Mar 2026 05:03:04 +0000 (22:03 -0700)] 
Unroll 64-byte CRC32+copy loop for ARMv8

Process 64 bytes per iteration using 8x uint64_t loads
with interleaved memcpy stores and __crc32d calls.
RPi5 benchmarks show 30-51% improvement over the
separate crc32 + memcpy baseline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 months agoAdd fallback for ARM CRC32 copy when compiling with no-unaligned-access
Nathan Moinvaziri [Thu, 12 Mar 2026 02:49:53 +0000 (19:49 -0700)] 
Add fallback for ARM CRC32 copy when compiling with no-unaligned-access

2 months agoReplace memcpy with NEON intrinsics for better performance alignment
Nathan Moinvaziri [Fri, 6 Mar 2026 23:48:35 +0000 (15:48 -0800)] 
Replace memcpy with NEON intrinsics for better performance alignment

2 months agoImplement interleaved copying for CRC32 ARMv8 PMULL+EOR3.
Nathan Moinvaziri [Tue, 24 Feb 2026 17:14:53 +0000 (09:14 -0800)] 
Implement interleaved copying for CRC32 ARMv8 PMULL+EOR3.

2 months agoImplement interleaved copying for CRC32 ARMv8.
Nathan Moinvaziri [Fri, 6 Mar 2026 03:01:45 +0000 (19:01 -0800)] 
Implement interleaved copying for CRC32 ARMv8.