arXiv:2610.06530cs.ITOct 2026

Manuscript Offprint

arXiv:2610.06530

Improved LZ77 Compression with Match-Length-Dependent Sliding Windows

Yingquan, Wu

Abstract

We devise and analyze WLZ, a family of LZ77 encoders whose sliding-window sizes depend on match length: short matches use smaller windows and shorter distance fields, while long matches retain access to distant repetitions. Write B:=log⁡2WB := \log_2 W for the maximum window WW. A parsing-transfer bound charges both window restrictions and missed matches, preserving established convergence and finite-input minimax orders, and a sharper block charge proves stationary-ergodic universality of exact greedy WLZ when full-window matching begins at length o(B)o(B). A calibrated window schedule never increases minimum token cost relative to a single-window baseline and saves Ω(BW−β)\Omega(BW^{-\beta}) in rate on specified iid sources, with β>2\beta > 2. The remaining gains come from the token code rather than the windows. On a uniform iid source, a growing phrase cap with a cheap length symbol improves redundancy from the Ω(log⁡B/B)\Omega(\log B/B) of the original 1977 fixed-field format, whatever phrase cap it uses, to O(log⁡log⁡B/B)O(\log \log B/B). Recoding a single-symbol run (r,1)(r, 1) as (1,r)(1, r), with a logarithmic-cost count rr that may exceed the match cap, codes inputs with O(nα)O(n^\alpha) runs, 0≤α<10 \leq \alpha < 1, in O(nαlog⁡n)O(n^\alpha \log n) bits, versus Ω(n)\Omega(n) for that format with phrase cap Θ(log⁡W)\Theta(\log W) and W=o(n)W = o(n). On globally p-periodic inputs, Huffman coding the fields of a capped parse with nearest-distance ties reduces the large-file rate from Θ(B/W)\Theta(B/W) under fixed-width coding to at most 3/W3/W, including tables and framing. Finally, selection among complete WLZ codes yields an entropy-rate estimator consistent almost surely and in mean, with finite-data error bounds for fixed nonuniform iid sources.

1 Introduction

LZ77 represents repeated substrings by backward distances and match lengths [5]. A larger history exposes distant repetitions, but wider fixed-width pointers can make short matches expensive. WLZ assigns a window W(ℓ)W(\ell) to each match length ℓ\ell, allowing short matches to use fewer distance bits while longer matches retain access to a larger history (Section 3). The decoder infers the distance range from the decoded length.

*Earlier versions of the window scheme appeared in the author's 2017 patent and 2021 Data Compression Conference (DCC) report [1, 2]. The codecs WLZ4 and WZIP built on it are described in [3], and their source code is public [4].

†Y. Wu is with Tenafe Inc., 591 W. Hamilton Ave, Campbell, CA 95008, USA (e-mail: icodywu@gmail.com).

Practical LZ77 formats differ mainly in how they code these pairs. DEFLATE [6], the format of zlib [7], gzip, ZIP, and PNG, combines a 32KB window with Huffman coding: literals and match lengths 3–258 share one alphabet, distances use another, and both code a range symbol followed by raw extra bits. This 1990s design remains ubiquitous but trails modern formats in compression ratio and especially in decoding speed: on the Silesia corpus, Zstandard [8] at its fastest level compresses 5% more than zlib at its fastest and decodes about four times as fast [9].

The author’s 2017 patent discusses conditional distance ranges [1, Fig. 3 and eq. (2)], and the conference report [2] introduced the window scheme and an LZ4-based experimental comparison. A separate paper [3] presents two complete codecs built on it, the byte-aligned WLZ4 and the entropy-coded WZIP, with a bounded dynamic-programming parser adapted to length-dependent windows and measurements against LZ4, Zstandard, Brotli and xz; their source code is public [4].

Zstandard and LZ4 [10] are widely deployed lossless codecs in storage and data-processing systems [11, 12], and the top of each class is hard to move. Zstandard at level 22 combines windows up to 128 MiB, binary-tree match finding with dynamic-programming parsing, and FSE entropy coding [8, 13], refined over years of engineering. Its --max mode, introduced in version 1.5.7, pursues further compression gains with substantially greater encoding time and memory [14]. On Silesia, the measured alternatives that exceed Zstandard 22's ratio, Brotli 11 and xz -9e, decode about 2.5 and 8 times more slowly than Zstandard 22 [3]. Against this mature baseline, WZIP levels 11–12, using Huffman coding only, improve the compression ratio over Zstandard 22 by 0.9–1.1% while retaining 84–86% of its decoding throughput (812–830 MB/s). WLZ4 improves the ratio over LZ4HC 12 by up to 16.1% while decoding at 2.43 GB/s; already at level 2, it slightly exceeds LZ4HC 12's ratio at four times its compression speed. These Silesia results demonstrate additional compression gains while preserving much of the decoding throughput of the respective baselines [3], motivating the analysis of length-dependent windows and their token codes.

Length-conditioned representations have precedents: Snappy couples a compact short-copy form with an 11-bit offset [15], while LZMA and Brotli use length-derived distance models [16, 17]. These need not impose a unique maximum distance for each length. Lizard does, in a byte-aligned format: it gives 16-bit offsets to matches of 4 bytes or more and reserves 24-bit offsets for matches of 16 or more [18], a two-level length-dependent window. A 2026 GPU-decoding preprint similarly restricts ordinary matches by distance-dependent minimum lengths, with a focus on decoding throughput [19]. Other multiple-index designs include Sadakane and Imai's two-level hashing with suffix sorting [20], Zstandard's 2019 double-fast matcher, which uses different seed lengths under a common window limit [21], and the multilayer suffix trees of Crochemore, Langiu, and Mignosi, which keep one sliding-window suffix tree per class of equal offset cost, over geometrically growing windows, to find an occurrence as cheap as the rightmost one [22]. Context-selected dictionaries are a distinct mechanism [23].

Crochemore, Langiu, and Mignosi establish greedy phrase-count optimality under dynamic suffix closure and uniform costs [24]. Minimum-bit parsing accounts for variable costs [25], dictionary-symbolwise flexible parsing attains optimality under dictionary-closure and coding assumptions [26], and the gap of minimum-bit parsing from greedy encoding can be superconstant [27]. Rightmost occurrence selection and packed-input factorization address complementary construction problems [28, 29, 30].

The original LZ77 proof uses constrained-language phrase counting [5]; later sliding-window and recurrence results establish stationary ergodic optimality [31, 32, 33], and phrase-count bounds under substring complexity give convergence rates [34, 35]. Mixing-based hitting-time results offer quantitative extensions through recurrence-tail bounds [36], and modified LZ schemes achieve O(1/log⁡W)O(1/\log W) redundancy under their source assumptions [37].

Here we develop a finite-input analysis under explicit parsing, search, and coding assumptions (Section 2). Separate indexes use seed lengths suited to their match classes; Section 4.4 quantifies their search costs and memory. Parallel search and dictionary-aided compression are discussed in Appendix B.

The analysis rests on one observation: a suffix of a legal copy can keep a distance outside its shorter length's window, so the suffix closure behind the classical LZ77 comparisons fails. The parsing-transfer inequality (Proposition 5.3) charges this loss, together with matches the parser misses, and makes established phrase-count bounds applicable to WLZ.

Consequently, for arbitrary short-match restrictions below a full-window threshold of O(log⁡W)O(\log W), exact greedy WLZ keeps the convergence rates of LZ77 under substring-complexity bounds (Corollary 5.7) and, for windows comparable to the input length, its finite-class minimax orders (Corollary 5.10); ordinary LZ77 attains these orders as well. A sharper block charge proves stationary-ergodic universality when the threshold is o(log⁡W)o(\log W) (Theorem 5.13). The same transfer bounds the cost of capped hash search on average over hash choices, and inspecting the p most recent candidates loses nothing on p-periodic inputs (Corollaries 5.4 and 5.5).

Strict improvements come mainly from the token code. On a uniform iid source, a cheap codeword for a growing phrase cap reduces redundancy from the Ω(log⁡B/B)\Omega(\log B/B) of the original 1977 fixed-field format, whatever cap that format uses, to O(log⁡log⁡B/B)O(\log \log B/B), where B:=log⁡2WB := \log_2 W (Theorem 6.2 and Proposition 6.3); the comparison isolates the cost of the historical length field, and a single-window encoder with the same token code gains as much. Coding a run of one symbol as (1,r)(1, r) with a logarithmic count codes inputs with O(nα)O(n^\alpha) runs, 0≤α<10 \leq \alpha < 1, in O(nαlog⁡n)O(n^\alpha \log n) bits, against Ω(n)\Omega(n) for that format with a logarithmic phrase cap (Proposition 6.6). On globally periodic inputs, Huffman coding the fields of a parse with nearest-distance ties lowers the large-file rate from Θ(B/W)\Theta(B/W) under fixed-width distances to at most 3/W, tables and framing included (Theorem 5.6), and Proposition 4.6 bounds the loss of coding range symbols with raw extra bits, as DEFLATE and Zstandard do [6, 8]. The windows themselves never increase the minimum token cost under a calibrated schedule and save a polynomially small rate on a fixed iid source (Theorem 6.5).

As an application, selecting among complete WLZ codes yields an entropy-rate estimator, consistent almost surely and in mean, with finite-data error bounds (Section 7). Appendix D turns to exact parsing of a given input, where the loss of suffix closure reappears: greedy parsing no longer minimizes the number of phrases, and the reduction to maximal matches fails, yet the minimum token cost is computable in O(n(K+Y)log⁡n)O(n(K + Y) \log n) time for K constant-window intervals of lengths and Y constant runs of the length cost.

Taken together, the windows preserve the asymptotic orders and reduce search and memory, since short seeds need only small indexes (Section 4.4), while the larger coding gains come from the token code. The codec measurements of [3] are consistent with this division: in WLZ4, whose offset fields have fixed widths, the windows raise the compression ratio; in

WZIP, ablations indicate that length-conditioned offset coding, the modeling opportunity in (8), improves compression, while restricted windows reduce indexing resources.

References (60)