IronCompress

Multi-algorithm compression for Java, powered by Rust via FFM. No JNI, no preview flags, just speed.

9
Algorithms
0
JNI Code
15x
Faster Brotli
4x
Faster Deflate
View on GitHub

Architecture

Java calls Rust directly through FFM downcall handles. No JNI wrappers, no generated code, no --enable-preview.

Java Application

IronCompress API
MemorySegment (Arena)
Off-heap allocation

FFM Downcall

Linker.downcallHandle()
Zero-copy MemorySegment
No byte[] marshalling

Rust cdylib

catch_unwind firewall
Algorithm dispatch
Pure-Rust crates

9 Algorithms

From blazing-fast LZ4 to maximum-compression Brotli. All fully implemented with roundtrip-tested correctness.

LZ4

lz4_flex
Level: N/A (always fast)
Best for: real-time streaming

Snappy

snap
Level: N/A
Best for: low-latency storage

Zstd

zstd
Level: 1-22 (default 3)
Best for: general purpose

Gzip

flate2
Level: 1-9 (default 6)
Best for: web content, HTTP

Brotli

brotli
Level: 0-11 (default 6)
Best for: static web assets

LZMA2

xz2
Level: 0-9 (default 6)
Best for: archival, max ratio

Bzip2

bzip2
Level: 1-9 (default 6)
Best for: text compression

LZF

lzf
Level: N/A
Best for: embedded, lightweight

Deflate

flate2
Level: 1-9 (default 6)
Best for: ZIP, PNG

Benchmark Results

100 MB compressible text, macOS ARM64, JDK 25, Rust 1.93. Zero-copy API where available.

Algorithm IronCompress Ratio Java Lib Ratio IC Compress (ms) Java Compress (ms) Speedup
LZ4 254.96x 254.97x 5.1 4.0 0.8x
Snappy 21.02x 21.02x 7.2 6.1 0.8x
Zstd 10,859x 10,859x 9.1 11.0 1.2x
Gzip 343.62x 343.54x 84.9 282.0 3.3x
Brotli 509,017x 478,802x 66.2 1,004.4 15.2x
LZMA2 6,795x 6,795x 2,135.4 751.2 0.4x
Bzip2 3,338x 4,609x 10,056.3 20,834.0 2.1x
LZF 85.56x 81.61x 50.5 7.5 0.1x
Deflate 343.64x 343.56x 77.0 306.7 4.0x

IronCompress wins at Gzip (3.3x), Deflate (4.0x), Brotli (15.2x), and Bzip2 (2.1x). LZ4/Snappy/LZF are faster via JNI-optimized native libraries. Results vary by hardware and data.

Get Started

Simple high-level API or zero-copy MemorySegment for maximum performance.

High-Level API
Stateful API
Zero-Copy API
import io.ironcompress.IronCompress;
import io.ironcompress.model.Algorithm;

byte[] data = "Hello world! ".repeat(10_000).getBytes();

// Compress with LZ4
byte[] compressed = IronCompress.compress(Algorithm.LZ4, -1, data);

// Decompress
byte[] restored = IronCompress.decompress(Algorithm.LZ4, compressed, data.length);
import io.ironcompress.IronCompressor;
import io.ironcompress.model.Algorithm;

// Reuses internal off-heap buffers across calls
try (var compressor = new IronCompressor()) {
    byte[] compressed = compressor.compress(Algorithm.ZSTD, 3, data);
    byte[] restored = compressor.decompress(Algorithm.ZSTD, compressed, data.length);
}
import io.ironcompress.IronCompress;
import io.ironcompress.model.Algorithm;
import java.lang.foreign.*;

try (Arena arena = Arena.ofConfined()) {
    MemorySegment input = arena.allocate(data.length);
    input.copyFrom(MemorySegment.ofArray(data));

    long maxOut = IronCompress.estimateMaxOutputSize(Algorithm.GZIP, 6, data.length);
    MemorySegment output = arena.allocate(maxOut);

    // Zero byte[] copies across FFI boundary
    long compressedSize = IronCompress.compress(Algorithm.GZIP, 6, input, output);
}

Cross-Decompression Compatibility

Can data compressed by IronCompress (Rust) be decompressed by Java libraries?

AlgorithmCompatibleNotes
GzipYesStandard gzip format
Bzip2YesStandard bzip2 format
LZMA2YesBoth use XZ format
ZstdYesStandard zstd frame format
BrotliYesStandard brotli format
LZ4Nolz4_flex vs lz4-java differ in block format
SnappyNosnap vs snappy-java differ in framing
LZFNoCustom flag prefix (raw/compressed)
DeflateNoRaw deflate vs zlib-wrapped format