Skip to content

Add wiki_prefixes bench: catamorphisms on prefix-closed Wikipedia titles - #187

Draft
adamv-symbolica wants to merge 1 commit into
Adam-Vandervorst:masterfrom
adamv-symbolica:adam/wiki-prefixes-bench
Draft

adamv-symbolica wants to merge 1 commit into
Adam-Vandervorst:masterfrom
adamv-symbolica:adam/wiki-prefixes-bench

Conversation

@adamv-symbolica

@adamv-symbolica adamv-symbolica commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Adds benches/wiki_prefixes.rs, which times catamorphisms on a map holding every prefix of every English Wikipedia article title. In a head-to-head of the cata implementations in #31 and its merkle-cata predecessor, this was the real-world dataset where caching shared nodes under valued paths mattered most.

What it measures

The bench builds a PathMap<()> in which every non-empty prefix of every title in the English Wikipedia title dump holds a value. The dump used below has 19,359,924 titles, which give 173,370,009 values.

It builds that map twice:

  • the first copy is timed as built, so no node in it is shared;
  • the second is merkleized in place before timing. merkleize turns each repeated subtrie, such as the endings _(disambiguation) or _(album), into one shared node. Because every path holds a value, every shared node sits below a path that holds a value.

On each copy it times:

  • map.val_count();
  • map.read_zipper().into_cata_cached(f) and map.read_zipper().into_cata_jumping_cached(f), where f returns the sum of its children's results plus one if the path holds a value, so both return the number of values;
  • map.read_zipper().hash().

It also times merkleize() in place on a freshly built map. Building the maps and dropping them are outside every timing.

Data

The dump is not committed (~110 MB download, ~400 MB unpacked):

curl -L https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-all-titles-in-ns0.gz \
  | gunzip > benches/enwiki-latest-all-titles-in-ns0

The bench reads it from BENCH_DATA_DIR (default benches/, where the file name is now gitignored). Without the file it prints the command above and exits 0, so cargo bench and CI are unaffected. WIKI_TITLES=<n> keeps an evenly spaced sample of about n titles. A full run takes 7–10 minutes and peaks at 33–38 GB, so the bench is not in bench_ab.py's default set.

Results

AMD EPYC 9B45, one core, median of 5 samples. All three branches were built from one checkout and target directory and run on the same machine.

operation map master (4e1c424) PR 31 head (3a4f241) merkle-cata (2dae7d1)
val_count as built 5.10 s 0.99 s 1.08 s
merkleized 2.43 s 3.98 s 2.01 s
into_cata_cached as built 5.29 s 0.99 s 1.48 s
merkleized 7.96 s 3.95 s 2.38 s
into_cata_jumping_cached as built 7.67 s 0.99 s 1.10 s
merkleized 10.31 s 3.96 s 2.08 s
hash as built 6.06 s 3.48 s 4.16 s
merkleized 9.40 s 5.79 s 2.86 s
merkleize fresh build 30.6 s 34.7 s 34.9 s

@adamv-symbolica
adamv-symbolica marked this pull request as draft November 13, 2026 15:56
Builds a map in which every non-empty prefix of every English Wikipedia
article title holds a value (19.4M titles, 173M values) and times
PathMap::val_count, into_cata_cached, into_cata_jumping_cached and hash on two
copies: the map as built, in which no node is shared, and a separately built
copy merkleized in place, in which every shared node hangs below a path that
holds a value. Also times merkleize in place on a freshly built map.

The title dump is not in the repository: the bench reads it from
BENCH_DATA_DIR (default benches/), and without it prints how to fetch it and
exits. WIKI_TITLES=<n> keeps an evenly spaced sample of about n titles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adamv-symbolica
adamv-symbolica force-pushed the adam/wiki-prefixes-bench branch from 112f39b to 64e7df1 Compare November 13, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant