by jakozaur · 5y ago · 0 comments
Still zstd offers way better compression and got variable difficulty factor: https://github.com/facebook/zstd Decompression is always fast, but you can trade off compression vs. ratio factor.
In general if send data over network zstd is quite profitable. Even network attached disk AWS EBS or AWS S3 it can be a hugely profitable.
This is the case in ClickHouse: if data is compressed, we decompress it in blocks that fit in CPU cache and then perform data processing inside cache; if data is uncompressed, larger amount of data is read from memory.
Strictly speaking, LZ4 data decompression (typically 3 GB/sec) is slower than memcpy (typically 12 GB/sec). But when using e.g. 128 CPU cores, LZ4 decompression will scale up to memory bandwidth (typically 150 GB/sec) as well as memcpy. And memcpy is wasting more memory bandwidth by reading uncompressed data while LZ4 decompression reads compressed data.
I'm not into C/C++ for years though and now I wouldn't grok the code, sadly.
LZ4 is one of the algorithms supported by Zram in Linux. It's fairly popular for people using things like a Raspberry PI that have a smaller amount of RAM.
https://www.techrepublic.com/article/how-to-enable-the-zram-...
I configure my own kernel on Arch and Zswap is enabled by default there, too.
I can't quite see why - perhaps the logic to decide which pages to compress is different, or there is too much code in the swap subsystem that slows down the compression/decompression process...
[0] https://klarasystems.com/articles/openzfs1-understanding-tra...
This article refers to the padding on the final record as "slack space" and states that you need to enable compression to eliminate the slack space.
https://arstechnica.com/information-technology/2020/05/zfs-1...
See also:
https://old.reddit.com/r/zfs/comments/gzcysy/h264_h265_media...
For image, video and audio there are more efficient compressions taking advantage of those formats.
That said it can be quite tricky to rewrite something to efficiently work on compressed data.
I always assume S3 storage was compressed on the fly by AWS regardless of how the client chooses to store his/her data.