Show HN: misa77 - a codec that decodes 2x faster than LZ4 (at better ratios)
It has the following characteristics:
- SOTA decompression throughput in its ratio class
- Decent ratios (comparable to LZ4 at high effort levels)
- Slow compression
Most of the gains can be attributed to reducing branches and making decompression very friendly to out-of-order cores, by using a smart format.Results on the tarred Silesia corpus on Intel x86-64 follow:
codec decode ratio encode
misa77 -0 5219 MB/s 42.64% 54.5 MB/s
misa77 -1 4274 MB/s 39.65% 51.2 MB/s
lz4 2505 MB/s 47.59% 371 MB/s
lz4hc -12 2531 MB/s 36.45% 7.31 MB/s- danlark1 - 6567 sekunder sedanIt's a somewhat known tradeoff, you can streamline and make the format friendlier to do memcpy which this library targets, the more memcpys you do, the faster it is overall to decode. On highly compressible data lz4, snappy become faster. Snappy on level 2 has faster decompression speed
But you have to pay the price that you need a slower encoding, because finding matches, putting restrictions on match lengths, putting things in different streams have costs you need to pay upfront.
Anyway good work, there is probably a need for that.
// Currently own Google's snappy and do compression at Google
P.S. if you want better snappy's results, compile with clang.
P.S.S you can optimize aarch64 speed by movemasks from shrn instruction. https://developer.arm.com/community/arm-community-blogs/b/se...
- purple-leafy - 4031 sekunder sedanCompression is so tricky.
I got really into compression experimenting while I was developing my browser game.
I was trying to compress entire human gameplay matches into a QR code, for upto 60 minutes of gameplay both single player and multiplayer.
My game is a fast paced, grid based, snake x scrabble word game.
My first compression attempt was to do run length encoding and cardinal directions, encoded into 1 byte. This was really compressible data.
The best approach was to use relative direction changes instead of cardinal directions. Compressed even better as the raw data was more consistent (for the most part you are moving forward etc).
Some other attempts were: zone based encoding, double movement pattern encoding (much smaller raw data but less compressible), triple movement pattern encoding, interrupt encoding.
I am at a point where I can fit all 30 minute single player games into a QR code, some 60 minute games, and with a special encoding scheme I can fit 15 minute N player multiplayer matches in a QR code
For reference qr code max size is about ~3000 bytes
- wolf550e - 9912 sekunder sedanFrom status in readme in github:
- misa77's format may change unexpectedly as it's still v0.x.y.
- The decoder assumes that the input is a valid misa77 stream. Invalid input is UB and I offer no guarantees for whatever misa77 does in this case.
- It's been through some local fuzzing but is not hardened, so treat it as experimental.
- mijoharas - 8251 sekunder sedanSo, I couldn't see it in the readme, apologies if I missed it but why?
It's a very significant speedup in decompression speed (albeit with a compression speed slowdown as a trade-off), but what's the insight that makes it faster? What was the idea or approach behind it?
- scottchiefbaker - 10935 sekunder sedanAlmost double the decompression speed, *and* a higher compression ratio than LZ4? That's very promising.
I don't see much in your README that talks about how a developer would integrate misa into their code. I might suggest some basic code samples to help a developer integrate misa decode into their project.
Congrats, looks like a cool project.
- logdahl - 11405 sekunder sedanNice results, I will keep a watch on this! Would be interesting to see benchmarks vs Oodle compression, I think the most similar one is Selkie?
- Sesse__ - 11327 sekunder sedanInteresting, but if you are not robust to corrupted/malicious data, it is really in a different class of algorithm and it is hard to compare speeds directly.
From memory, 2505 MB/sec also sounds on the low side for LZ4 on a modern CPU?
- kazinator - 10204 sekunder sedan> It offers particularly high decompression throughput on highly compressible files.
You know, you would expect that this is commonly observed. You'd expect, say, simple RLE (run length encoding) to be like this. It's more expensive to produce output requiring the processing of a large number of RLE opcodes that produce short sequences than one opcode that produces one long sequence.
- bootlegbilly - 14474 sekunder sedanthis is super interesting! im excited to give this a look this afternoon, since I specifically have wanted faster throughout for decompressing maps in a game engine.
- avph - 7108 sekunder sedanThis looks awesome for boot firmware. How large is the decompressor code?
- zX41ZdbW - 9184 sekunder sedanIt is slower than LZ4 on AArch64.
- mervz - 3071 sekunder sedanhow does it compare to macklin71?
- zuzululu - 7315 sekunder sedanso whats the actual use case for this ? streaming ? games?
- throwaway74747 - 11408 sekunder sedanWhat's the Weissman score?
Nördnytt! 🤓