Random access string compression with FSST and Rust
blog.spiraldb.com
blog.spiraldb.com
It’s a quite neat algorithm. I saw compression ratios in the 2-3x range. However, I remember that the algorithm for finding the dictionary was a bit unclear. I wasn’t convinced that what was explained in the paper found the “optimal” dictionary. With some slight tweaks I got widely different results. I wonder if this implementation improves on this.
1. Always promoting single-bytes by boosting their scores by a factor of 8 in candidate search
2. Boosting the calculated gains of single-byte candidates by a factor of 8 to prevent them from falling off in later generations
3. Having an adaptive threshold for which symbols are included as the rounds go on
I didn't document these in the blog post to keep the content accessible, but it's definitely something you find once you start digging into compression ratios! Perhaps they will end up in a part 2 at some point.
[1]: https://github.com/spiraldb/fsst/blob/develop/src/builder.rs...
German-style strings/views are not a compression algorithm, they're just a way for storing string data and making it quick to compare them in-memory. You can in fact store views, while storing the corresponding full-length strings in compressed format with FSST. We don't currently do that but we're working on it.
[1] https://arrow.apache.org/docs/format/Columnar.html#variable-...
[2] https://db.in.tum.de/~freitag/papers/p29-neumann-cidr20.pdf
EDIT: Question about FSST--lets say I build a strings table like:
struct Strings {
compressor: fsst::Compressor,
compressed: Vec<Vec<u8>>
}
Is there some optimal length for compressed given the 255 symbols limit?[1] https://github.com/spiraldb/vortex [2] https://github.com/apache/datafusion
We ended up not using it in production because the worst cases were absolutely terrible compared to our dumber skippable zstd.
It’s a format for handling bulk columnar data.
[1] https://docs.rs/fsst-rs/0.4.1/fsst/struct.Compressor.html#me... [2] https://docs.rs/fsst-rs/0.4.1/fsst/struct.Compressor.html#me... [3] https://docs.rs/fsst-rs/0.4.1/fsst/struct.Compressor.html#me... [4] https://docs.rs/fsst-rs/0.4.1/fsst/struct.Decompressor.html#...