Mova0.6 pre-release

Compression: prepare, then a fast zstd

Mova keeps big stores: PubMed Central texts, OpenAlex works, math web text, Wikidata. They were stored as they came: gzip tars, parquet with snappy or zstd, bz2, jsonl.zst. mova-pack (pack/) is the storage layer that prepares the data first and then compresses it with a fast zstd level. This page says how it works, how to run it, what it measured on our data and where it stops.

The idea

A general compressor finds repeats inside a window. It does not know that a JSON record is a fixed set of keys, that a field holds one of six values, or that two files of the same site share their boilerplate. Preparation tells it:

The format is exact: unpacking gives the original bytes, every time, checked against the original's sha256.

Every container is cut into blocks of whole records (documents for token files, lines for JSON lines and TSV), about 1 MiB of original text each, and each block decodes alone. A separate offset index, <name>.idx.zst, maps record keys to the block and the offset inside it, so one document is read by decoding one index chunk and one block.

How to run it

cargo build --release -p mova-pack
mova-pack pack works.jsonl works.mpk          # verify, then write
mova-pack get works.mpk 12345                 # one record, one block decoded
mova-pack unpack works.mpk works.jsonl
mova-pack dict --kind json --out DICTS part-*.jsonl.gz     # one dictionary for a dataset
mova-pack pack part-0007.jsonl.gz part-0007.mpk --tdict DICTS/<sha>.tdict --zdict DICTS/<sha>.zdict --dicts DICTS
mova-pack repack part-*.jsonl.gz --dicts DICTS            # in place, originals moved aside
mova-pack gc STORE --dicts DICTS                          # dry run; --apply removes

mova-pack repack train.tok.zst --min-free 100             # train.tok.mpk + train.tok.idx.zst
mova-pack cat train.tok.mpk | READER -                    # the original, byte for byte, as a stream
mova-pack get train.tok.mpk --id "Ada Lovelace"           # one document by its # doc
mova-pack repack rows.jsonl --id json:/id --id doc=json:/source/doc   # two named keys
mova-pack get rows.jsonl.mpk --key doc=D17                # every record of one document

pack and repack write the streaming container (format 2: one pass, bounded memory, any input size) and its index; the kind is detected (tok, json, lines) and the preparation is kept only when it makes the sample at least 3 % smaller. Keys are given with --id [NAME=]SPEC: tok:doc (the default for token files), tok:sent, json:KEY, json:/pointer, tsv:N, prefix:TEXT. --min-free GB keeps a floor of free space on the target filesystem; --source PATH reads an original that was already moved elsewhere (for example to another filesystem while the new container is written).

repack writes the new container beside the old file, reads it back in full and checks its content hash (and looks up a sample of records through the new index), then moves the original to .pack-aside/ and renames the new files into place; every step goes to .pack-aside/journal.tsv. gc removes moved-aside originals only after the grace period (7 days by default) and only when the replacement still carries the journaled hash; it also removes stale temporary files, failed candidates and dictionaries no container references. Without --apply it only prints.

The measurements below come from mova-pack bench (build with --features parquet for the parquet samples).

Measured (2026-11-11)

One representative unit of each store, measured on one core of the shared box while other jobs ran, so speeds are rough. Sizes, hashes and verdicts are deterministic: repeated runs gave byte-identical report.json files (PMC and Wikidata twice, OpenAlex and FineMath three times). Every row checked its round trip byte for byte; every prepared and dictionary row ran a negative control (a deliberately broken decoder, a corrupted dictionary) and it went red. Ratio = canonical bytes / stored bytes. "Global" dictionaries (templates, typical values) are counted once at zstd-19.

Samples:

  1. PMC: comm-txt-00100.tar.gz, 5 289 articles, 303.7 MB tar (the canonical original).
  2. OpenAlex: one works-slim partition (updated_date=2026-10-12/part_0000.parquet), 304 973 rows. Parquet cannot be rebuilt byte for byte, so the canonical original is a deterministic JSON-lines export of every column (317.1 MB).
  3. FineMath: finemath-4plus/train-00000-of-00064.parquet, 104 680 pages, export 651.6 MB.
  4. Wikidata: the first 1 GB of latest-all.json.bz2 (23 860 entities, cut at a line end); the current size is bzip2 -9 of that prefix.
  5. A quick check on Proof-Pile 2: open-web-math/validation-val.jsonl.zst (295 MB raw).

Solid (whole unit in one compressed stream)

store, unitcurrentzstd-7zstd-9zstd-19 --longprepared + zstd-7prepared + zstd-9best prepared + zstd-9prepared + zstd-19 --long
PMC tar (gzip)99.6 MB, 3.0584.6 MB, 3.5982.5 MB, 3.6870.6 MB, 4.3083.5 MB, 3.6481.5 MB, 3.7381.5 MB, 3.73 (streams)70.2 MB, 4.33
OpenAlex (parquet zstd)54.7 MB, 5.8056.2 MB, 5.6454.1 MB, 5.8643.4 MB, 7.3149.1 MB, 6.4647.4 MB, 6.6943.1 MB, 7.36 (id-sorted columns)39.7 MB, 7.98
FineMath (parquet snappy)286.3 MB, 2.28172.4 MB, 3.78167.2 MB, 3.90135.4 MB, 4.81170.4 MB, 3.82165.4 MB, 3.94145.8 MB, 4.47 (host-grouped columns)133.8 MB, 4.87
Proof-Pile 2 OWM (jsonl.zst)87.4 MB, 3.38โ€“77.4 MB, 3.81โ€“โ€“77.5 MB, 3.8176.0 MB, 3.88 (columns)โ€“

"Prepared" is the main variant: template lines (family) for JSON, front/body/references streams grouped by journal for PMC. Compression speed of the prepared rows on this box: 9-60 MB/s per core including preparation (plain zstd-9: 26-44 MB/s; zstd-19 --long: 1.3-3 MB/s); decompression 80-550 MB/s (plain: 450-1 500 MB/s).

How much of the bytes is pure JSON structure (keys, braces, quotes, commas, literals): OpenAlex 42.6 %, Wikidata 51.6 %, FineMath 3.7 %, OWM 0.4 %, a PMC metadata shard 16.6 %.

Parquet rewritten (DuckDB, the same files)

as storedparquet zstd-9parquet zstd-9, sortedparquet zstd-19, sorted
OpenAlex partition54.7 MB (zstd, default level)47.0 MB43.1 MB (by id)38.7 MB
FineMath file286.3 MB (snappy)159.7 MB145.0 MB (by host, url)โ€“

COPY (SELECT * FROM f ORDER BY ...) TO g (FORMAT parquet, COMPRESSION zstd, COMPRESSION_LEVEL 9), 4 threads, one run each. Row order changes; the rows do not.

Record access (held-out 20 %)

Records with index % 5 == 4; dictionaries trained on the other 80 %.

PMC articleOpenAlex rowFineMath page
per record, zstd-7, no dictionary2.951.792.62
per record, zstd-9 + global dictionary3.354.273.62
per record, zstd-7 + per-domain dictionaries3.254.153.54
per record, template lines + zstd-9 + dictionaryโ€“4.843.67
256 KiB blocks grouped by domain + dictionary, zstd-73.325.133.84
solid zstd-7 (no access, reference)3.465.503.79
mova-pack container, 1 MiB blocks, zstd-9 (whole unit)3.476.063.68

A get decodes one block (up to 1 MiB of record text): 0.8-15 ms per record on this box, the slowest being OpenAlex template decoding.

Wikidata (first 1 GB)

1 000.0 MB of entity lines, 23 860 entities. Two runs gave identical reports.

variantbytesratiocompress MB/sdecompress MB/s
current: bzip2 -9101.2 MB9.88โ€“โ€“
zstd-7 / zstd-9 plain104.1 / 100.4 MB9.61 / 9.96141 / 711 190 / 733
zstd-19 --long plain79.5 MB12.582.51 497
template lines (family) + zstd-7 / zstd-988.0 / 85.9 MB11.36 / 11.64980-86
template lines (exact) + zstd-987.9 MB11.38751
typed columns + zstd-984.9 MB11.781193
template lines (family) + zstd-19 --long74.1 MB13.493.988
mova-pack container, 1 MiB blocks, zstd-992.6 MB10.8010120
per entity, zstd-9 + dictionary (held-out)8.3746983
per entity, template lines + zstd-9 + dictionary (held-out)9.8951134

The global template dictionary is 1.33 MB compressed (counted once): Wikidata's labels, descriptions, aliases, sitelinks, claims, qualifiers and reference snaks are maps (more than 32 distinct keys), so their keys travel as values and one template covers each statement shape; without maps the exact templates take 8.8 MB. \uXXXX escapes are stored as UTF-8. Reading one entity takes 28-32 ms (one block decoded).

What mattered

  1. The codec, not the preparation, for text. gzip โ†’ zstd-9 saves 17 % on PMC, snappy โ†’ zstd-9 saves 42 % on FineMath. On prose, preparation adds 1-4 %; only a larger window (zstd-19 --long, at 1-3 MB/s) adds another ~20 %.
  2. Grouping similar records. FineMath grouped by site: โˆ’9 % at the same level. OpenAlex sorted by id: โˆ’5 % on top of columns (ids become small deltas). This is the biggest single transform for web text and catalog rows.
  3. Templates for JSON. Against plain zstd-9 of the same JSON: OpenAlex โˆ’12 % (template lines) and โˆ’16 % (typed columns), Wikidata โˆ’14 % and โˆ’15 %. The structure is 43-52 % of the raw bytes, but zstd already removes most of it; what the template takes away is the remainder. Per record the template matters more: a Wikidata entity alone compresses 18 % better as template lines than as JSON with the same kind of trained dictionary.
  4. Trained dictionaries matter for small units only. Per OpenAlex row: 1.79 โ†’ 4.27 with a dictionary; with 1 MiB blocks or whole files: 0-4 %. Per-domain dictionaries (top 32 domains) did not beat one global dictionary on held-out records once their own size is counted; without it they gain 1-7 % (OpenAlex 4.20 โ†’ 4.41, Wikidata 8.21 โ†’ 8.79), which only a whole store could amortize.
  5. Level 9 vs 7: 2-4 % smaller, at about half the compression speed of 7 on this box; decompression is the same.

So the hypothesis "prepare the data right and zstd-7 matches zstd-19" holds for structured catalog data (OpenAlex: id-sorted columns at zstd-7, 43.9 MB, equal the plain zstd-19 --long, 43.4 MB, at ~10x the speed). It does not hold for text-heavy stores (PMC, FineMath, Proof-Pile), where the bytes are prose and the large window still wins; grouping by site recovers about half of that gain at fast levels.

Projected savings (from the samples)

Applying each sample's ratio to its whole store, assuming the unit is representative:

storenowparquet rewrite (sort + zstd-9)mova-pack, zstd-9cold: zstd-19 --long
PMC OA text, 65 GB gzip65 GBโ€“53 GB solid prepared (โˆ’12 GB); 57 GB with 1 MiB blocks (โˆ’8 GB)46 GB (โˆ’19 GB)
OpenAlex works-slim, 68 GB parquet68 GB54 GB (โˆ’14 GB)59 GB template lines (โˆ’9 GB); 65 GB with 1 MiB blocks48 GB as sorted parquet zstd-19 (โˆ’20 GB)
FineMath, 83 GB parquet snappy83 GB42 GB (โˆ’41 GB)42 GB host-grouped (โˆ’41 GB); 51 GB with 1 MiB blocks39 GB (โˆ’44 GB)
Proof-Pile 2, 51 GB jsonl.zst51 GBโ€“44-45 GB (โˆ’6 to โˆ’7 GB)not measured
Wikidata dump, 103.5 GB bz2103.5 GBโ€“88 GB template lines (โˆ’16 GB); 95 GB with 1 MiB blocks76 GB template lines + zstd-19 --long (โˆ’28 GB)

Together 370 GB โ†’ about 281 GB with fast levels (โˆ’89 GB, best variant per store), most of it from FineMath's snappy.

Mova's corpora (2026-11-18)

Choosing the format (samples)

One core-busy box (load 25-40 on 20 cores), so speeds are rough; sizes are deterministic. Ratio = original bytes / stored bytes. "Lines" is a format-2 container with the same 1 MiB blocks and trained dictionary but no preparation; "tok" adds the token-stream preparation.

sampleoriginalzstd-9 solidzstd-19 solidlines, 1 MiBtok, 1 MiBtok, 4 MiB
Wikipedia .tok (first 256 MiB of the 300M slice, 618 articles)268.4 MB42.5 MB, 6.3234.6 MB, 7.7745.2 MB, 5.9428.6 MB, 9.3727.9 MB, 9.63
Gutenberg history book .tok40.7 MB4.59 MB, 8.863.22 MB, 12.65.00 MB, 8.133.50 MB, 11.6โ€“
Taskmaster-2 dialogues .tok150.0 MB12.0 MB, 12.57.36 MB, 20.413.2 MB, 11.411.7 MB, 12.9โ€“
task items (morphology) .tok99.2 MB2.50 MB, 39.72.05 MB, 48.32.46 MB, 40.22.54 MB, 39.1โ€“
early modern English .conllu38.5 MB5.41 MB, 7.134.16 MB, 9.266.01 MB, 6.413.62 MB, 10.6โ€“
Taskmaster-2 dialogues .jsonl (json templates)29.8 MB3.89 MB, 7.663.06 MB, 9.734.26 MB, 7.003.96 MB, 7.54โ€“

On the Wikipedia sample the trained dictionary saves 2 % at 1 MiB blocks (29.2 โ†’ 28.6 MB) and nothing at 4 MiB (27.7 โ†’ 27.9 MB). Decoding the 268 MB sample: solid zstd-9 0.53 s; the tok container 1.72 s on one thread (156 MB/s, including its sha256), 0.56 s on 4, 0.39 s on 8; lines 0.82 s on one. Reading one article by its # doc (index chunk + one block, a fresh process each time, 200 reads): p50 7.8 ms, p95 12.4 ms with 1 MiB blocks; p50 25 ms, p95 59 ms with 4 MiB blocks.

So: 1 MiB blocks, zstd-9, a trained dictionary, the tok preparation for token files. Preparation is decided per file on its first 32 MB: kept when it is at least 3 % smaller. Highly repetitive templated data (task items) compresses better as plain text, because whole repeated sentences are long matches for zstd. JSON templates win little on prose-heavy dialogue records. Solid zstd-19 is still smaller on repetitive dialogue data, at the price of record access and of 1-3 MB/s compression.

The corpus folder living/ already stores JSON lines as zstd-19 frames of about 16 MB with its own index (corpuspack): repacked to zstd-9 1 MiB blocks it grows (OANC 24.4 โ†’ 30.2 MB, Europarl English 72.4 โ†’ 95.0 MB), so it stays as it is.

Repacked in place

mova-pack repack --min-free 100, one file at a time, smallest first, as systemd user units (nice 15, MemoryMax=8G), files of 1 MB and more. Every file was read back in full (sha256 of its content) and every 64th record looked up through its new index before the original moved aside.

corpusfilesbeforeafterratioindex
alice24.1 MB0.4 MB10.40.01 MB
sft3143.9 MB14.7 MB9.810.37 MB
gali-tasks241 390.2 MB89.4 MB15.620.1 MB
books-open1731 040.3 MB98.9 MB10.50.34 MB
dialog428 079.5 MB920.0 MB8.7842.7 MB
hard-cases.jsonl133.3 MB3.4 MB9.870.01 MB
wiki-v5-slice-300m-full (.tok.zst, dev.tok)22 660.8 MB1 779.6 MB1.50 (9.38 on the text)0.9 MB
wiki-v5-slice-300m-full shards (.tok.zst)183 373.1 MB2 265.4 MB1.491.4 MB
wiki-all-v5-full (train.tok.zst, dev.tok)240 074.8 MB27 060.9 MB1.48 (9.63 on the text)96.3 MB

"Before" is the file as it was (plain text, or zstd for the Wikipedia stores); "after" the container alone. The index is a separate file. Small .tok indexes (one key per document) cost 0.1-1 % of the container; TSV files indexed by their first column cost much more (the turns table of the book dialogues: 18.8 MB of index for a 27.0 MB container), since every line is a record.

The whole of Wikipedia (train.tok.zst, 260.6 GB of text, 6 779 957 articles, 229 120 blocks): packed in 54 min on 8 threads (80 MB/s of text), read back in 6.6 min (650 MB/s); one article by its # doc: p50 18 ms, p95 36 ms (200 reads). Together these files went from 56.8 GB to 32.2 GB, plus 162 MB of index.

Reading one record by key on the same busy box (100 reads, a fresh process each): Wikipedia slice p50 23 ms, p95 52 ms; book dialogues .tok p50 16 ms, p95 49 ms; their .jsonl p50 22 ms, p95 90 ms; their turns TSV p50 11 ms, p95 40 ms.

Recommendation

What a migration takes

  1. Train the dataset dictionaries on a sample (mova-pack dict), store them in the dataset's dictionary directory.
  2. mova-pack repack file by file in small waves (it is single-writer per directory; keep โ‰ค 4 threads), or a DuckDB COPY per parquet file followed by a row-count and content check.
  3. Switch the readers: .gz readers become mova-pack get/unpack or the pack library; parquet readers do not change.
  4. mova-pack gc after the grace period removes the moved-aside originals.

Rough cost on one core: FineMath and OpenAlex rewrites by DuckDB ~30 s per file at 4 threads (a few hours for both stores); mova-pack at 10-50 MB/s per core with the current encoder.

Limits

This page in Markdown https://md.mova.elamur.ai/free/en/docs/repo-docs/compression/