PSeitz / lz4_flex

Fastest pure Rust implementation of LZ4 compression/decompression.
MIT License
441 stars 28 forks source link

improve safe frame compression performance 7-15% #74

Closed PSeitz closed 1 year ago

PSeitz commented 1 year ago

The frame encoding uses a fixed size hashtable. By creating a special hashtable with a Box<[u32; 4096]> size, in combination with the bit shift of 4, which is also moved into a constant, the compiler can remove the bounds checks. For that to happen, the compiler also needs to recognize the >> 48 right shift from the hash algorithm (u64 >> 52 <= 4096), which is the case. Yey