/ Performance Engineer
← All posts
Nov 18, 2026 · 4 min read · Build performance

parallel-zip 1.5.0: zero-allocation native sniffing for large files

1.5.0 moves large-file incompressibility sniffing into native C on the memory-mapped view before any Java heap output buffer is allocated — pushing fixed-corpus speedups up to 61.9×.

parallel-zip 1.5.0 is out. While the release includes a handful of I/O and copy-walk cleanups, one change does the heavy lifting behind the latest benchmark jump: native pre-allocation sniffing on memory-mapped large files.

The double-work problem on large entries

In 1.4.x, any file larger than SPILL_THRESHOLD (8 MiB) and eligible for the native mmap path (up to 128 MiB, scaled down on smaller daemon heaps) went through two separate passes:

  1. Java’s looksIncompressible opened the file, read the first 64 KiB into a heap buffer, and ran java.util.zip.Deflater to see if the sample shrank. If it didn’t, Java read the entire file a second time just to compute its CRC-32 before storing it.
  2. If the sample did shrink, tryMmapNativeDeflate opened and memory-mapped the file again, allocated a full-size output byte[] on the Java heap, and only then called into libdeflate.

That meant extra syscalls, a Java Deflater warm-up on the hot path, and a multi-megabyte heap allocation before the native compressor even got to look at the bytes.

Sniffing in C before allocating a single heap byte

1.5.0 eliminates that split. When the mmap native path is available, compressLarge skips Java-side looksIncompressible completely. tryMmapNativeDeflate maps the file once (FileChannel.MapMode.READ_ONLY) and calls a new JNI entry point, sniffIncompressibleDirect, before allocating any Java output array:

  • In C (pzip_libdeflate.c), sniffIncompressibleDirect probes the first 64 KiB directly from the mapped address into a stack-allocated uint8_t scratch buffer using libdeflate_deflate_compress.
  • If the probe compresses to 98% or more of its original size (or fails to shrink), it computes libdeflate_crc32 directly over the mapped memory and returns true.
  • Back in Java, tryMmapNativeDeflate returns a STORE entry streaming the original file — zero Java heap allocation for the entry’s data or output buffer, no java.util.zip.Deflater, and a single file open.

What it did to the numbers

The impact shows up most clearly on large-archive corpora and when skipAlreadyCompressed = false (where every entry has to be evaluated by content rather than skipped by magic bytes):

Fixed-corpus project Size 1.4.1 (true / false) 1.5.0 (true / false) Speedup vs. stock Zip
SonarQube Community Build 931.1 MiB 0.65 s / 3.60 s 0.48 s / 2.17 s 61.9× / 13.71×
Flink 1.20.0 502.4 MiB 0.39 s / 2.04 s 0.22 s / 1.45 s 59.0× / 9.06×
Kafka 3.8.1 120.4 MiB 0.09 s / 0.23 s 0.06 s / 0.18 s 54.1× / 18.75×
Gradle 8.14.3 145.1 MiB 0.09 s / 0.92 s 0.08 s / 0.61 s 49.1× / 6.62×
Hadoop 3.4.0 (20k files) 1,681.2 MiB 8.61 s / 22.23 s 6.92 s / 17.72 s 25.0× / 9.76×

Across the nine freshly measured real-project Gradle builds, geometric-mean speedup over stock Zip moved from ~17.5× to ~22.6× with skipAlreadyCompressed=true, and from ~5.14× to ~5.87× with it false.

(1.5.0 also pairs this with 256 KiB writer I/O buffers, reused header ByteBuffers, a lazy spill directory that isn’t created unless an entry actually spills, and fewer per-entry allocations during the Gradle copy walk.)

Getting it

plugins {
    id 'com.ljarocki.parallel-zip' version '1.5.0'
}

Full benchmark tables for all 10 in-build projects and 11 fixed-corpus distributions are in docs/BENCHMARKS.md, and the release is on GitHub.

ŁJ
Łukasz Jarocki
Performance Engineer