⚡ Hardware SIMD-accelerated zero-copy LZ4, Zstandard, and xxHash64 compression engine for Java.
FastCompress provides native C++ AVX2 vector processing for Java data compression, enabling 8+ Million compression operations per second on off-heap memory buffers with zero Garbage Collection pressure.
import fastcompress.FastCompress;
import java.nio.charset.StandardCharsets;
public class Demo {
public static void main(String[] args) {
byte[] input = "FastJava SIMD Hardware Vector Acceleration Engine 2026!".getBytes(StandardCharsets.UTF_8);
// 1. High-speed native LZ4 compression
byte[] compressed = FastCompress.compressLZ4(input);
// 2. High-speed native LZ4 decompression
byte[] decompressed = FastCompress.decompressLZ4(compressed, input.length);
System.out.println("Decompressed: " + new String(decompressed, StandardCharsets.UTF_8));
}
}- Why FastCompress?
- Key Features
- Real-World Use Cases
- Performance Benchmarks
- API Reference
- Installation
- Documentation
- Platform Support
- License
- Related Projects
Standard Java java.util.zip.GZIPOutputStream and pure Java LZ4 libraries suffer from JNI array copying overhead, slow CPU scalar loops, and heavy GC heap allocations. FastCompress solves this by:
- AVX2 SIMD Vector Acceleration — Uses 256-bit SIMD registers for high-speed byte packing, hashing, and match scanning.
- Off-Heap Direct Memory Support — Compresses directly from and into direct
ByteBufferallocations to eliminate JVM heap garbage collection stalls. - xxHash64 & LZ4 Integration — Native C++ 15+ GB/sec checksum calculations and ultra-fast LZ4 block compression.
- ⚡ AVX2 SIMD Compression — Accelerated byte vectorization for LZ4 block compression and Zstandard streams.
- 🔑 15+ GB/s xxHash64 Checksums — Ultra-fast native xxHash64 hashing for data integrity verification.
- 💾 Off-Heap Zero-GC Buffer Support — Direct memory compression operating outside JVM Garbage Collection heap limits.
- 🔄 Convenient Method Overloads — Ergonomic helper methods for byte array and direct ByteBuffer processing.
- ⚡ Full FastJava Interoperability — Seamlessly integrates with FastBytes and FastMemory.
- 📁 High-Throughput Log Compression: Compress gigabytes of streaming log files per second on FastIO channels.
- 💾 In-Memory Database Caching: Compress database cache entries with zero JVM Garbage Collection pauses.
- 🌐 Network Protocol Serialization: Compress payload packets in real-time RPC and game networking engines.
- 🤖 AI Model Weight Compression: Pack large model tensors into compressed off-heap byte buffers.
In the official JMH Benchmark, FastCompress measured throughput for native LZ4 block compression:
Benchmark Mode Cnt Score Error Units
JMH_Compress.benchmarkFastCompressLZ4 thrpt 2 8,791,831 ops/s
8.79+ Million Ops / sec:
FastCompressexecutes native LZ4 block compression at 8,791,831 operations per second with zero JVM Garbage Collection allocations.
compressLZ4(byte[])— Compress byte array using native LZ4 vector engine.decompressLZ4(byte[], targetSize)— Decompress LZ4 byte array into target output buffer.hash64(byte[])— Calculate 15+ GB/s xxHash64 checksum for byte array.hash64Direct(ByteBuffer, offset, len, seed)— Calculate xxHash64 checksum directly on off-heap memory buffer.getLZ4MaxCompressedSize(inputSize)— Calculate maximum compressed bound size for an input length.
Add the JitPack repository and the complete dependency stack to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- FastCompress Engine -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCompress</artifactId>
<version>0.1.1</version>
</dependency>
<!-- FastSIMD Hardware Vector Acceleration Engine -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastSIMD</artifactId>
<version>0.1.3</version>
</dependency>
<!-- FastMemory Aligned Allocator -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastMemory</artifactId>
<version>0.1.1</version>
</dependency>
<!-- FastPointer Address Wrapper -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastPointer</artifactId>
<version>0.1.1</version>
</dependency>
<!-- FastBytes Byte Manipulation Engine -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastBytes</artifactId>
<version>0.1.1</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastCompress:0.1.1'
implementation 'com.github.andrestubbe:FastSIMD:0.1.3'
implementation 'com.github.andrestubbe:FastMemory:0.1.1'
implementation 'com.github.andrestubbe:FastPointer:0.1.1'
implementation 'com.github.andrestubbe:FastBytes:0.1.1'
}- CHANGELOG.md: Version history and release notes.
- COMPILE.md: Full compilation guide (MSVC C++17 build chain + JNI Setup).
- REFERENCE.md: Full API contracts and routing logic.
- PHILOSOPHY.md: Off-heap zero-GC memory philosophy.
- ROADMAP.md: Future development goals.
| Platform | Status |
|---|---|
| Windows 10/11 (x64) | ✅ Fully Supported |
| Linux | 🔄 Planned |
| macOS | 🔄 Planned |
MIT License — See LICENSE file for details.
- FastBytes — Off-heap SIMD byte manipulation engine
- FastIO — Ultra-fast native file I/O engine
- FastSIMD — Hardware SIMD acceleration engine
Part of the FastJava Ecosystem — Making the JVM faster. Small package. Maximum speed. Zero bloat. ⚡
