FSST
Fast Static Symbol Tables compression for Elixir.
FSST is a string compression algorithm designed for database-style workloads:
many short strings compressed with a shared static symbol table. This package
provides a pure Elixir implementation and an optional Rustler backend powered by
fsst-rs.
Installation
def deps do
[
{:fsst, "~> 0.1.0"}
]
endUsage
table = FSST.train!(["hello", "hello world", "hello there"])
compressed = FSST.compress!(table, "hello world")
"hello world" = FSST.decompress!(table, compressed)Prefer the non-bang functions when handling user input:
with {:ok, table} <- FSST.train(samples),
{:ok, compressed} <- FSST.compress(table, input),
{:ok, decompressed} <- FSST.decompress(table, compressed) do
{:ok, decompressed, compressed}
endBackends
FSST.Pureis always available and contains the Elixir implementation.FSST.Rustwrapsfsst-rsthrough Rustler when the NIF is available.FSST.backend/1uses:autoby default, preferring Rust when available and otherwise falling back to pure Elixir.
Select a backend explicitly:
table = FSST.train!(samples, backend: :pure)
table = FSST.train!(samples, backend: :rust)Training options
Pure training accepts tuning options:
FSST.train!(samples, max_symbol_size: 8, sample_bytes: 65_536):max_symbol_sizecontrols candidate symbol length.:sample_byteslimits training input for large corpora. Use:infinityto train on all provided bytes.
Benchmarks
mix run bench/fsst_bench.exsLicense
MIT © 2026 Danila Poyarkov