Multi-algorithm compression for Java, powered by Rust via FFM. No JNI, no preview flags, just speed.
Java calls Rust directly through FFM downcall handles. No JNI wrappers, no generated code, no --enable-preview.
IronCompress API
MemorySegment (Arena)
Off-heap allocation
Linker.downcallHandle()
Zero-copy MemorySegment
No byte[] marshalling
catch_unwind firewall
Algorithm dispatch
Pure-Rust crates
From blazing-fast LZ4 to maximum-compression Brotli. All fully implemented with roundtrip-tested correctness.
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.
Simple high-level API or zero-copy MemorySegment for maximum performance.
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);
}
Can data compressed by IronCompress (Rust) be decompressed by Java libraries?
| Algorithm | Compatible | Notes |
|---|---|---|
| Gzip | Yes | Standard gzip format |
| Bzip2 | Yes | Standard bzip2 format |
| LZMA2 | Yes | Both use XZ format |
| Zstd | Yes | Standard zstd frame format |
| Brotli | Yes | Standard brotli format |
| LZ4 | No | lz4_flex vs lz4-java differ in block format |
| Snappy | No | snap vs snappy-java differ in framing |
| LZF | No | Custom flag prefix (raw/compressed) |
| Deflate | No | Raw deflate vs zlib-wrapped format |