LZSS v3.16 β Levels -0..-9 (v22)
π Source Code Availability: The C source file for each version is available in Files on SourceForge β lzss_v1.1.c, lzss_v1.4.c, lzss_v1.5.c, lzss_v1.6.c, lzss_v1.7.c, lzss_v1.8a.c, lzss_v1.8b.c, lzss_v1.8c.c, lzss_v1.9.c, lzss_v2.0a.c, lzss_v2.0b.c (offset codes), lzss_v2.0c.c (streaming BROKEN, do not use), lzss_v2.0d.c (single-pass fixed-memory, legacy 12B header), lzss_v2.1_ds32_BE.c (previous: REP-4 + LE + magic/version 1), lzss_v2.2_slots.c (slots + Huffman selector, version 2), lzss_v2.3_range.c (range order-0 literals, version 3), lzss_v2.4_ctx.c (range order-1 nibble-class literals, version 4), lzss_v2.5_mix.c (per-literal implicit judge order-0 x 16ctx, version 5), lzss_v2.6_flags.c (+ order-1 binary match/lit flags, version 6), lzss_v2.7_slots.c (+ order-1 slot selector, version 7), lzss_v2.8_len.c (+ order-1 len Huffman, version 8), lzss_v2.9_rep.c (+ order-1 REP-hit context, version 9), lzss_v3.0_bcj.c (+ per-block BCJ x86 filter, version 10), lzss_v3.1_fix.c (stored+BCJ corruption fix, version 11), lzss_v3.2_dp.c (optimal DP parse + fair guard, version 12), lzss_v3.3_dp2.c (DP REP-aware + 2nd iteration + hash restore, version 13), lzss_v3.4_sel.c (quota shortlist + rep_en fix, version 14), lzss_v3.6_fast.c (skip DP2 convergido, version 15), lzss_v3.7_win.c (janela 512K + pedΓ‘gio greedy, version 16), lzss_v3.8_long.c (matches atΓ© 65535, version 17), lzss_v3.9_tiny.c (tabelas singleton compactas, version 18), lzss_v3.11_rep.c (SUPERSEDED before release: repeat-bit v19, do not use), lzss_v3.12_gate.c (repeat escape len==0, version 20), lzss_v3.13_frame.c (framing compacto 2b, version 21), lzss_v3.13_frame.c (framing compacto 2b, version 21), lzss_v3.14_slots.c (Γ‘rvores esparsas kind 11, version 21), lzss_v3.15_reuse.c (reuse cross-block, version 22), lzss_v3.16_levels.c (current: levels -0..-9, mesma version 22, use this) + invtest.c (inverter/judge/context bit-level test harness, modes 0-5) + bcjtest.c (standalone BCJ filter) (e.g. https://sourceforge.net/projects/lz77-v3/files/). Browser AIs can read the raw .c directly via .../files/<name>.c/download. Old v1.8 (Huffman Full) / v1.9-RC (Range Coder) were discarded β only approached gzip, never beat it.
An ultra-efficient, production-grade derivation of Haruhiko Okumura's LZSS (1989), optimized for bit-level stream efficiency, blazing-fast index lookups, architectural safety, and resilient cross-platform validation.
By replacing fixed-token byte structures with a unified bit-writer stream, deploying a concurrent dual sliding window setup, and driving search lookups with a high-speed hash chain, this engine achieves high data-density compression and asymmetrical runtime performance over machine bytecode and text blocks without statistical tree overhead [π].
π Architectural & Engineering Milestones
- High-Speed Hash Chaining (v1.3 Breakthrough): Integrated Jean-loup Gailly's legendary chained index lookup mapping strategy [π]. The engine bypasses brute-force linear searches by computing a fast 3-byte window hash, cutting execution time down to virtually 0.00 seconds on compiled binaries and 0.01 seconds on dense text [π].
- Dual Sliding Window Integration (v1.2): Operates a dynamic search architecture over two independent history buffers:
- 9-Bit Short Window (WS: 511 bytes): Hyper-focused cache optimizing localized spatial redundancies with nominal bit overhead [π].
- 14-Bit Long Window (WS: 16,383 bytes): Wide-angle historical sweep feeding maximum-length match sequences [π].
- Deterministic Bit-Cost Balancing: Implemented a specialized evaluation matrix determining selection based on true bit value. The engine only commits to the 14-bit window if the extra match sequence mathematically breaks even against the 5-bit offset penalty over the shorter 9-bit option [π].
- Fixed Memory Streaming (v2.0d): compressor uses a fixed ~1.6MB ceiling for any input size (ring 256KB + head 256KB + prev 512KB + toks 512KB). No
malloc(file_size), no ftell, single-pass
with incremental Adler-32 and 20B header backpatch (12B before magic, v2.1+). Decompressor uses ~260KB (ring 256KB). Old "under 16KB" claim was true only up to v1.9 β v2.x 128K window needs the hash tables (see Memory Limits below).
- Adler-32 Integrity Anchor: Employs a rigid 12-byte layout fixed to the absolute header sequence containing an Adler-32 checksum (honoring Mark Adler's contribution to compression science) [π]. The decompressor executes validation over the output block to guarantee byte-perfect restoration.
- REP Offsets, zstd-inspired (v1.8a): Per-block switch tracking the last 3 offsets; repeat matches encode a 2-bit index instead of the full 9/15-bit offset. Costs 1 bit/block where useless, saves 7β13 bits per repeat where it hits (texto_rep -32%, zeros -31%, misto -1067B).
- 15-Bit Long Window (v1.8b): Long window grows 14-bit (16,383B) β 15-bit (32,767B, same as gzip). Costs +1 bit per large match, pays off on every file larger than 16KB (make.txt -4.6%, ja_comprimido -43%).
- 10-Bit Short Window (v1.8c): Short window grows 9-bit (511B) β 10-bit (1,023B). Offset histogram showed 500-700 matches/block in 512-1023 paying 20b large, now 15b short (make.txt -1%, make.bin -117B).
- Flag-Remap (v1.9): Per-block 1-bit switch; large-dominated blocks use
large=0 / lit=10 / short=11 instead of lit=0. Auto-disabled where literals dominate (make.bin Β±0) or REP is on (make.txt -1.67%).
- Single-Pass Streaming (v2.0d, fixes v2.0c): same format/tokens as v2.0b (bit-identical output), but ring-buffered. Fixed v2.0c
ring_end -= drop corruption (lost 1 byte per 128K slide, first fail at byte 131074 of make.txt).
- REP-4 + LE + Magic (v2.1, first format break): REP history 3 β 4 (
{1,8,32} + 128), same 2-bit code β small win on binaries (make.bin -38B payload, binario_ls -94B), neutral on text. Header/total_len/raw_len forced LE (BE-safe memcmp matcher, __builtin_clz bitlen). 20B header with magic "LZSS" + version 1 (was 12B, no magic). Incompatible with v2.0d and older by design: old decoders guard-trip on v2.1 files, new decoder rejects magic-less files with a clear message.
- Slot Distances (v2.2, window flag dead): all distances 1β131071 through lzip-style slots 0β33 (magnitude = msb+nextbit) with per-block Huffman-coded selector (existing canonical machinery) + raw footers. No window flag, no remap (needed the flag; ~2KB txt headwind accepted, still net β1.55%). Per-block
has_slots bit skips the slot tree where unused (zeros identical). REP-4 untouched. Header version 2.
- Range order-0 + order-1 nibble-class literals (v2.3/v2.4): LZMA-style byte range core (canonical ShiftLow, no tables) with per-block literal mode in the same 2 bits (00 fixed / 01 huff / 10 range order-0 / 11 range order-1 by
prev>>4, 16 ctx, adaptive, continuous across blocks via snapshot). Header version 4 (decodes v2/v3/v4). 256-ctx lost by 1β3% (warmup); 16 classes won on binaries.
- Per-literal implicit judge (v2.5): MIX mode switches order-0 x 16ctx per literal with 0 side bits (both models advance always, discounted scores, post-update costs, identical order both sides). Header version 5. Neutral-to-tiny (Β±bytes): block selection already captures ~99%.
- Order-1 binary match/lit flags (v2.6, current): per-block
flagctx bit; flags via binary RC order-1 (ctx = prev flag) in own payload, bodies in second payload (u32 len + backpatch). Independent of literal mode. Header version 6 (decodes v2..v6). Biggest jump since slots: misto β10.4%, ja_comprimido β10%, beats gzip-9 on make.bin.
- Order-1 slot selector (v2.7, current): per-block
slotctx bit (only if has_slots); selector via adaptive RC order-1 by magnitude class (4 ctx Γ 34 syms, fresh/block) in own payload, footers stay in bodies. Replaces Huffman tree+codes where exact min-selection wins. Header version 7 (decodes v2..v7). bin β354, txt β340, binario_ls β368; rest identical.
- Order-1 len Huffman (v2.8, current): per-block
lenctx bit; len_code via Huffman order-1 by prev-len class (3 ctx Γ 8 syms, exact 2-pass), codes precomputed per token, extra byte raw. Header version 8 (decodes v2..v8). Biggest single jump yet: bin β716, txt β353, texto_rep β12.5%, zeros β944.
- Order-1 REP-hit context (v2.9, current): per-block
repctx bit (only if rep_en); yes/no bit via binary RC order-1 (ctx = prev outcome), index stays in bodies. Header version 9 (decodes v2..v9). binario_ls β454, texto_rep β665, zeros β352; low-rep files identical.
- BCJ x86 filter per block (v3.0, current): per-block
bcj bit; E8/E9 rel32βabs with global base before parsing, exact proxy decision (cover margin 256B), hash history via snapshot, Adler always original. Header version 10 (decodes v2..v10). bin β3.800 (β4.5%), binario_ls β1.755; rest identical.
- Stored+BCJ fix (v3.1, current): stored blocks restore raw ring (no marker exists); lazy-2-by-sum reverted (overlap double-count β literal flood). Sizes identical to v3.0. Header version 11 (decodes v2..v11).
- Optimal DP parse + fair guard (v3.2): pass-1 greedy β tables A; DP over DAG (literal + top-16-by-len + pinned best/short/long, table costs, prev-len-class state); each stream estimated with its own optimal tables (+REP walk + flag order-1 entropy), switch on clear win. Header version 12 (decodes v2..v12). bin β784, codigo β123, misto β688; txt β83.
- DP REP-aware + 2nd iteration + hash restore (v3.3): each of the 3 passes (greedy, DP1, DP2) restarts hash tables from the block-entry snapshot β without this, greedy's future inserts truncate DP's chain (
break on mp>=pos) and DP loses all cross-block matches. DP costs model REP hits via fixed per-position history from the reference path (hit = flag+repbit+2b index+len, miss = +1 repbit; model follows greedy's rep decision, refined by DP1's for DP2); DP2 re-parses with tables B + history from DP1; best-of-3 (greedy/DP1/DP2, each with own optimal tables + best rep 0/1 + flag order-1 entropy), guard 256b. 32 candidates/pos (16β32 keeps mid matches when cross-block longs flood the top list). Header version 13 (decodes v2..v13). bin β1.353, txt β5.453, binario_ls β953 (fixes v3.2 +34 noise); misto +688 (guard falls back to greedy everywhere β open); price: ~2-3x compress time (txt 7.6s, texto_rep 2.2MB 140s in WSL2).
- Quota shortlist + rep_en fix (v3.4, current): DP candidates as quotas β top-12 by len + top-12 by save + top-8 by save among recent (distβ€4096) + 3 pins (32 total) β plus rep_en decision fixed to (boβ3)/hit instead of (boβ2) (a hit costs repbit+2b index = 3b; the extra +1/hit switched REP on in marginal blocks). Rejected: top-by-true-saving (compared 1 literal vs whole match β garbage ranking), len-bucket diversity (cost more than gained). Header version 14 (decodes v2..v14). bin β33, txt β53, binario_ls β34, zeros β752; misto β28 (still +660 vs v3.2, OPEN).
- Skip DP2 convergido (v3.6, current): pula o DP2 quando est1>=estA (DP2, que parte das tabelas/hist do DP1~=greedy, repetiria o DP1); guard e custos intactos, bytes idΓͺnticos Γ v3.4 em todo o corpus. DP2 pulado em 45/48 blocos no misto (tempo 100sβ29s), 0/7 no bin (DP1 vence sempre β sem atalho). Header version 15 (decodes v2..v15; v15 queimada pela v3.5 descartada, reutilizada aqui).
- Janela 512K + pedΓ‘gio greedy (v3.7, current): janela longa 128Kβ512K (slots lzip 34β38 sozinhos, resto genΓ©rico; ring 1MB, prev 2MB) + FAR_PEN=16 sΓ³ no greedy (matches far redundantes diluΓam tabelas). DP segue livre com fars e o guard decide. Tunado 8/16/24/32/64. DiagnΓ³stico: no txt o ganho (β1178) vem do DP2 achando estrutura fewer/longer com fars; no misto o estrago (+2806 sem pedΓ‘gio) vinha do greedy. Header version 16 (decodes v2..v16). txt β1.178, resto Β±ruΓdo (bin +38 downstream); lΓquido β1.087 no corpus.
- Matches longos atΓ© 65535 (v3.8, current): escape E==255 reservado (shorts atΓ© 257, longs 258+ via u16; custo extra 24b) + clamp 258β257+literal + greedy medindo atΓ© 258 (rΓ‘pido) com collect estendendo full-len sΓ³ nas 8 entradas mais recentes. Bugs pegos: (1) E==255 ambΓguo p/ len 258 (dessincronizava o decoder β truncation no bloco 4 do txt); (2) truesave comparando 1 literal vs match inteiro (ranking loteria, revertido p/ buckets e depois p/ cotas+extensΓ£o). Header version 17 (decodes v2..v17). texto_rep β12.656, zeros β5.149 (264B, abaixo do xz 284!), ja β347 (25.062, abaixo do xz 25.268!); preΓ§o estrutural da reserva do 255 no misto +1.283 (+0,19%).
- Tabelas singleton compactas (v3.9, current): framing kind nas Γ‘rvores Huffman (00 vazia, 01 singleton+sΓmbolo, 10 bitmap legado) β bloco degenerado pagava ~105b de bitmaps vazios. Valores idΓͺnticos (singleton = len 1, convenΓ§Γ£o do build); decoder dual por fver. Header version 18 (decodes v2..v18). zeros β68 (196B), resto Β±2b/tabela em blocos densos; lΓquido β51B.
π Empirical Benchmarks (Sep 26, 2026)
Tested directly on active binary machine code from the original MinGW toolchain (make.exe) and unformatted source assets (make.txt), the custom dynamic 3-bit engine outpaces classical platforms [π]:
π― 1. make.exe (Real MinGW Executable Bytecode)
- LZ77 Traditional Base: 110,557 bytes (Runtime: 1.13s brute-force)
- LZSS Industry Standard: 101,575 bytes
- LZSS v1.1 (Variable Baseline): 99,361 bytes
- LZSS v1.3 (Dual Window + Hash Chain): 93,480 bytes π (~15.4% space optimization β Runtime: 0.00s instant lookup) [π]
- LZSS v1.5 (Failsafe Blocks): 93,525 bytes (stored escape, no expansion on random)
- LZSS v1.6 (Lazy Parsing): 91,704 bytes on make.bin 166400 (55.11%, -1.95% over v1.5, same format)
- Okumura LZARI 1989 (LZ+Arithmetic): 91,268 bytes on make.bin β v1.6 fica +436B (+0.47%) sem Huffman
- LZSS v1.7 (Dynamic Huffman): 89,654 bytes on make.bin (53.88%, -2.2% over v1.6, beats LZARI by 1614B)
- LZSS v1.8a (REP per-block, 14-bit): 89,483 bytes on make.bin (-171 over v1.7)
- LZSS v1.8b (REP + 15-bit window): 88,990 bytes on make.bin (53.48%, -664 over v1.7, +3.7% over gzip-9 85,792; xz -e 76,656)
- LZSS v1.8c (short 10-bit / 1023B): 88,873 bytes on make.bin (53.42%, -781 over v1.7, +3.6% over gzip-9)
- LZSS v1.9 (flag-remap): 88,873 bytes on make.bin (remap stays off β lit-dominated, correct)
- π§ͺ LZSS v2.0a (experimental 128K window, raw 17b): 89,696 bytes on make.bin (+823 vs v1.9 β few far matches, tax not paid)
- π§ͺ LZSS v2.0b (128K + static offset codes, no FSE): 87,896 bytes on make.bin (-800 vs v2.0a, +2.45% over gzip-9 85,792)
- β
LZSS v2.0d (single-pass streaming, fixed ~1.6MB): 87,896 bytes on make.bin (bit-identical to v2.0b, 11/11 cmp+Adler PASS)
- β
LZSS v2.1 (REP-4 + magic): 87,866 bytes on make.bin (-30 vs v2.0d; -38 payload + 8 header)
- β
LZSS v2.2 (slots, current): 86,207 bytes on make.bin (-1,659 vs v2.1, -1.89%)
- β
LZSS v2.3 (range order-0 literals): 85,931 bytes on make.bin (-276 vs v2.2; gap to gzip-9 85,792 = 139B)
- β
LZSS v2.4 (range order-1 nibble-class, current): 85,868 bytes on make.bin (-63 vs v2.3; gap to gzip-9 = 76B; xz -e 76,656)
- β
LZSS v2.5 (MIX judge per literal): 85,866 bytes on make.bin (-2; mechanism proven, prize tiny)
- β
LZSS v2.6 (ctx flags, current): 85,642 bytes on make.bin (-224 vs v2.5; BEATS gzip-9 85,792 by 150B; xz -e 76,656)
- β
LZSS v2.7 (ctx slots, current): 85,288 bytes on make.bin (-354 vs v2.6; beats gzip-9 by 504B; xz -e 76,656)
- β
LZSS v2.8 (ctx lens, current): 84,572 bytes on make.bin (-716 vs v2.7; beats gzip-9 by 1220B; xz -e 76,656)
- β
LZSS v2.9: 84,572 bytes on make.bin (REP rejected on low-rep data, correct)
- β
LZSS v3.0 BCJ (current): 80,772 bytes on make.bin (-3.800 vs v2.9; gzip-9 beaten by ~5KB; xz -e 76,656, gap 4.144)
- β
LZSS v3.1 FIX (current): 80,772 bytes on make.bin (identical sizes, corruption fix; use this)
- β
LZSS v3.2 DP: 79,988 bytes on make.bin (-784 vs v3.1; gzip-9 beaten by ~5.8KB; xz -e 76,656, gap 3.360)
- β
LZSS v3.3 DP2: 78,635 bytes on make.bin (-1.353 vs v3.2; gzip-9 beaten by ~7.2KB; xz -e 76,656, gap 1.979)
- β
LZSS v3.4 SEL: 78,602 bytes on make.bin (-33 vs v3.3; gzip-9 beaten by ~7.2KB; xz -e 76,656, gap 1.946)
- β
LZSS v3.6 FAST: 78,602 bytes on make.bin (identical bytes to v3.4, faster where DP2 is wasted)
- β
LZSS v3.7 WIN: 78,640 bytes on make.bin (+38 vs v3.6 downstream noise; gzip-9 beaten by ~7.2KB; xz -e 76,656, gap 1.984)
- β
LZSS v3.8 LONG: 78,638 bytes on make.bin (-2 vs v3.7; zstd-19 80,401 beaten by 1,763; xz -e 76,656, gap 1.982)
- β
LZSS v3.9 TINY: 78,639 bytes on make.bin (+1 vs v3.8 kind-bits; zeros 264β196, beating xz 284)
- β
LZSS v3.12 ESC: 78,639 bytes on make.bin (payload byte-identical to v3.9 where no repeat; zeros 196β93)
- β
LZSS v3.13 FRAME: 78,631 bytes on make.bin (framing 2b: -8; zeros 93β33, beating xz 284 by 251 and zstd-19 53 by 20)
- β
LZSS v3.14 SPARSE: 78,631 bytes on make.bin (inalterado; texto_rep 625β541, gap pro xz cai pra 37)
- β
LZSS v3.15 REUSE: 78,624 bytes on make.bin (reuse: -7; texto_rep 541β434, xz -e 504 retomado por 70)
- β
LZSS v3.16 -9 (current): 78,620 bytes on make.bin (DP3: -4; levels -0..-9, mesma v22)
- Discarded: old v1.8 (Huffman Full 88,468) / v1.9 (Range Coder 87,045) β approached gzip, never beat it, complexity not worth it. v2.0c streaming also discarded (ring bug, corrupts >128K). v3.11 repeat-bit (v19) superseded before release by v3.12 len-0 escape (never published, do not use).
π 2. make.txt (Text Footprint)
- LZ77 Traditional Base: 172,618 bytes (Runtime: 0.66s brute-force)
- LZSS Industry Standard: 166,776 bytes
- LZSS v1.1 (Variable Baseline): 158,609 bytes
- LZSS v1.3 (Dual Window + Hash Chain): 142,584 bytes π (Over 30KB extracted over standard LZ77 β Runtime: 0.01s) [π]
- LZSS v1.5 (Failsafe Blocks): 142,608 bytes (+24B block headers, 7/7 PASS)
- LZSS v1.6 (Lazy Parsing): 140,103 bytes on make.txt 327528 (42.78%, -1.76% over v1.5, v1.5 decoder compatible)
- Okumura LZARI 1989 (LZ+Arithmetic): 143,724 bytes on make.txt β v1.6 ganha por 3,621B (-2.5%) sΓ³ no LZSS
- LZSS v1.7 (Dynamic Huffman): 132,893 bytes on make.txt (40.58%, -5.1% over v1.6, beats LZARI by ~10KB)
- LZSS v1.8a (REP per-block): 132,894 bytes on make.txt (+1, REP auto-disabled where useless)
- LZSS v1.8b (REP + 15-bit window): 127,983 bytes on make.txt (39.08%, -4,910 over v1.7, +6.7% over gzip-9 119,980)
- LZSS v1.8c (short 10-bit / 1023B): 126,715 bytes on make.txt (38.69%, -6,178 over v1.7, +5.6% over gzip-9)
- LZSS v1.9 (flag-remap, large=0 where dominant): 124,603 bytes on make.txt (38.05%, -2,112 over v1.8c, +3.9% over gzip-9 119,980)
- π§ͺ LZSS v2.0a (experimental 128K window, raw 17b): 119,702 bytes on make.txt (36.55%, -4,901 over v1.9 β first build to beat gzip-9 by 278B; offset codes planned as v2.0b to fix the bin regression)
- π§ͺ LZSS v2.0b (128K + static offset codes, no FSE): 118,801 bytes on make.txt (36.27%, beats gzip-9 119,980 by ~1%)
- β
LZSS v2.0d (single-pass streaming, fixed ~1.6MB): 118,801 bytes on make.txt (bit-identical to v2.0b, beats gzip-9 by ~1%)
- β
LZSS v2.1 (REP-4 + magic): 118,809 bytes on make.txt (payload bit-identical to v2.0d; +8 header)
- β
LZSS v2.2 (slots, current): 116,963 bytes on make.txt (-1,846 vs v2.1, -1.55%; beats gzip-9 119,980 by ~2.5%)
- β
LZSS v2.3/v2.4: 116,963 bytes on make.txt (new modes correctly rejected where they don't pay; binario_ls 64,014 β 63,869 in v2.4)
- β
LZSS v2.5: 116,964 bytes on make.txt (+1 litmode bit; MIX neutral here)
- β
LZSS v2.6 (current): 116,185 bytes on make.txt (-779 vs v2.5; gzip-9 119,980 beaten by ~3.8KB)
- β
LZSS v2.7 (current): 115,845 bytes on make.txt (-340 vs v2.6; gzip-9 beaten by ~4.1KB)
- β
LZSS v2.8 (current): 115,492 bytes on make.txt (-353 vs v2.7; gzip-9 beaten by ~4.5KB)
- β
LZSS v2.9/v3.0/v3.1: 115,492 bytes on make.txt (REP/BCJ correctly rejected on text)
- β
LZSS v3.2 DP: 115,409 bytes on make.txt (-83 vs v3.1; gzip-9 beaten by ~4.6KB)
- β
LZSS v3.3 DP2: 109,956 bytes on make.txt (-5.453 vs v3.2; gzip-9 beaten by ~10KB; xz -e 100,464, gap 9.492)
- β
LZSS v3.4 SEL: 109,903 bytes on make.txt (-53 vs v3.3; gzip-9 beaten by ~10KB; xz -e 100,464, gap 9.439)
- β
LZSS v3.6 FAST: 109,903 bytes on make.txt (identical bytes to v3.4, faster where DP2 is wasted)
- β
LZSS v3.7 WIN: 108,725 bytes on make.txt (-1.178 vs v3.6 via DP2+far; gzip-9 beaten by ~11KB; xz -e 100,464, gap 8.261)
- β
LZSS v3.8 LONG: 108,700 bytes on make.txt (-25 vs v3.7; gzip-9 beaten by ~11KB; xz -e 100,464, gap 8.236)
- β
LZSS v3.9 TINY: 108,706 bytes on make.txt (+6 vs v3.8 kind-bits; gzip-9 beaten by ~11KB)
- β
LZSS v3.12 ESC: 108,706 bytes on make.txt (payload byte-identical to v3.9 where no repeat)
- β
LZSS v3.13 FRAME: 108,688 bytes on make.txt (framing 2b: -18; gzip-9 beaten by ~11.3KB)
- β
LZSS v3.14 SPARSE: 108,688 bytes on make.txt (inalterado)
- β
LZSS v3.15 REUSE: 108,674 bytes on make.txt (reuse: -14)
- β
LZSS v3.16 -9 (current): 108,649 bytes on make.txt (DP3: -25; default -6: 109659@4.5s)
- Discarded: old v1.8 (Huffman Full 128,187) / v1.9 (Range Coder 127,335) β same reason as above.
π§ Memory Limits (v3.16, WSL2 verified β /usr/bin/time -v: enc 11264 kB, dec 2304 kB)
Compressor (fixed, independent of input size β β 10.8MB heap):
buf ring 1MB (RING_SIZE = 1<<20) β holds WS_LARGE + BLOCK_SIZE + 2 = 589,825B
head 65,536 Γ 4B = 256KB, prev 524,288 Γ 4B = 2MB, toks/toksSave/toksDP1 65,536 Γ 8B = 512KB each
- DP arena (v3.2/v3.3):
dpCost ~768KB + dpPar ~1.5MB + repHist ~1MB + snapshot h0head 256KB + h0prev 2MB
- Tables/scratch:
lcc+lcl 64KB each, lcb 256KB, rawsave 64KB, range model m1 ~16KB (+~2KB slot/len tables)
- v3.11 repeat-block adds no RAM (3 scalars; RC/range payloads go to
tmpfile on disk, not RAM). No malloc(file_size), no ftell (works >2GB/>4GB and on pipes β input needs only sequential fread). Output must be seekable (20B header backpatch magic + version + u64 total_len + u32 adler).
- Block 64KB, window long 524,287B + short 1,023B, match 3β65535B, file size up to 2^64-1.
- History: v2.2 ceiling was β 1.6MB (ring 256KB,
prev 512KB, no DP); v3.7 grew to ring 1MB + prev 2MB (512K window); v3.2/v3.3 added the ~6.5MB DP arena; v3.16 adds toksDP2 512KB (β 11.0MB heap).
π Compression Levels (v3.16, same v22 format at every level)
lzss -c [-0..-9] <input> <output> (default -6; -c <in> <out> = -6). Decoder and bitstream format are identical at all levels β levels only change encoder effort:
-0 stored only (instant, +~28B) Β· -1 fast greedy, no BCJ/DP/RC/RANGE (0.1β0.7s; nearly beats gzip-9 on binaries at 0.2s) Β· -2 +RC contexts Β· -3 +range trials Β· -4 +BCJ Β· -5 +DP1 Β· -6 +DP2 @depth128 (default) Β· -7/-8 depth 192/256 (-8 == v3.15 byte-identical, verified) Β· -9 +DP3 @depth256 (best-of-4, never worse than -8, verified -9 β€ -8 on 9/9).
Decompressor (fixed):
buf ring 1MB + range model ~16KB (β 2.3MB process RSS with bit-reader + Huffman tables). Streaming with per-block flush and incremental Adler-32. No malloc(output_size).
- v2.0b and older allocated the whole file (
malloc(total_len) / malloc(total_original_len)) β obsoleto.
π οΈ Automated Compilation & Verification
The environment is mapped directly under a linear Makefile layout to preserve proper processing synchronizations across shell routines:
# 1. Compile the source engine under absolute -O3 vectorizations
make
# 2. Run the dynamic target evaluations over real data payloads
make test
# 3. Purge operational artifacts
make clean
Stream Token Layout (lzss_v1.3)
- Literal (Flag 0):
[1 bit: 0] + [8 bits: Raw Uncompressed Byte Data] = 9 bits total [π]
- Short Match Normal:
[1 bit: 1] + [1 bit: Window Flag] + [3 bits: Size Mapping] + [9/14 bits: History Index] = 14 or 19 bits total [π]
- Long Escape Match:
[1 bit: 1] + [1 bit: Window Flag] + [3 bits: 111 Escape Marker] + [9/14 bits: History Index] + [8 bits: Extra Byte Offset] = 22 or 27 bits total (Unlocks matching runs from 10 up to exactly 258 sequential bytes without byte overflow) [π].
Us
######################################
LZSS v1.2 β Custom 3-Bit Dual Sliding Window Compressor
An ultra-efficient, production-grade derivation of Haruhiko Okumura's LZSS (1989), optimized for bit-level stream efficiency, architectural safety, and resilient cross-platform validation.
By replacing fixed-token byte structures with a unified bit-writer stream and deploying a synchronized hybrid search engine, this implementation achieves high data-density compression over both binary structures and text blocks without statistical encoding overhead.
π Today's Engineering Achievements
- Dual Sliding Window Integration (v1.2): Transitioned from a baseline single window to a dynamic, concurrent search architecture utilizing two distinct history radii:
- 9-Bit Short Window (WS: 511 bytes): Hyper-focused cache to eliminate localized spatial redundancies with nominal bit overhead.
- 14-Bit Long Window (WS: 16,383 bytes): Wide-angle historical sweep to feed maximum-length data blocks.
- Deterministic Bit-Cost Balancing: Implemented a specialized evaluation matrix determining selection based on true bit value. The engine only commits to the 14-bit window if the extra match sequence mathematically breaks even against the 5-bit overhead compared to the short window.
- 64-Bit Memory Expansion: Rewrote the stream parsers and internal mapping structs to support
uint64_t original lengths. The engine natively compresses multi-gigabyte structures while keeping runtime memory footprints bounded under 16KB.
- Adler-32 Integrity Anchor: Dedicated a fixed 12-byte layout to the absolute header sequence containing an Adler-32 checksum (honoring Mark Adler's contribution to compression science). The decompressor executes validation over the output block to guarantee byte-perfect restoration.
π Empirical Benchmarks (Sep 25, 2026)
Tested directly on active binary compilation sequences (make.bin) and unformatted source assets (make.txt), the custom dynamic 3-bit engine outpaces classical platforms:
π― 1. make.bin (Binary Structure)
- LZ77 Traditional Base: 110,557 bytes
- LZSS Industry Standard: 101,575 bytes
- LZSS v1.1 (Baseline): 99,361 bytes
- LZSS v1.2 (Dual Window): 93,480 bytes π (~15.4% space optimization over LZ77)
π 2. make.txt (Text Footprint)
- LZ77 Traditional Base: 172,618 bytes
- LZSS Industry Standard: 166,776 bytes
- LZSS v1.1 (Baseline): 158,609 bytes
- LZSS v1.2 (Dual Window): 142,584 bytes π (Over 30KB extracted over standard LZ77 parsing)
π οΈ Automated Compilation & Verification
The environment is mapped directly under a linear Makefile layout to preserve proper processing synchronizations across shell routines:
# 1. Compile the source engine under absolute -O3 vectorizations
make
# 2. Run the dynamic target evaluations over data payloads
make test
# 3. Purge operational artifacts
make clean
Stream Token Layout (lzss_v1.2)
- Literal (Flag 0):
[1 bit: 0] + [8 bits: Raw Byte Data] = 9 bits total
- Short Match Normal:
[1 bit: 1] + [1 bit: Window Flag] + [3 bits: Size Mapping] + [9/14 bits: History Index] = 14 or 19 bits total
- Long Escape Match:
[1 bit: 1] + [1 bit: Window Flag] + [3 bits: 111 Escape Marker] + [9/14 bits: History Index] + [8 bits: Extra Byte Offset] = 22 or 27 bits total (Unlocks matching runs from 10 up to 258 sequential bytes).