Skip to content

Performance ​

Read throughput ​

Count all 59M elements in Denmark extract (461 MB), best of 3 runs, fat LTO, on plantasjen at commit 90df51f:

ToolModeTimeNotes
pbfhoggparallel0.31spar_map_reduce on all cores
osmpbf 0.3parallel0.53supstream crate, same API
pbfhoggpipelined1.3sfor_each_pipelined, preserves file order
Planetiler 0.10parallel2.0sJava, OsmInputFile + thread pool
pbfhoggsequential2.8sfor_each
pbfhoggblobreader2.9sBlobReader sequential decode
osmpbf 0.3sequential5.6supstream for_each
osmium 1.19cat to opl5.7sosmium cat -f opl -o /dev/null
Planetiler 0.10sequential8.7sJava, OsmInputFile single-threaded

par_map_reduce is fastest when order does not matter. for_each_pipelined is the fastest ordered read and the production hot path.

Write throughput ​

Decode all 59M elements then write through BlockBuilder + PbfWriter to /dev/null, on plantasjen at commit def80d9:

CompressionSyncPipelinedNotes
none6.2s6.2sdecode + wire-format serialization floor
zstd:38.1s6.2spipelined hides compression cost
zlib:614.5s6.3s2.3x speedup from parallel compression

With pipelined writes, all compression modes converge to ~6.2s - the decode + wire-format serialization floor. All element types are encoded directly to protobuf wire format using reusable scratch buffers (no per-element allocation, no external protobuf dependencies).

CLI command benchmarks ​

Denmark (487 MB indexed file, 59M elements), pbfhogg commit 53360af4 against osmium 1.19.1 on bygg, 2026-11-09. Both tools read the same indexed file (pbf.indexed) with default options, and each run starts with that file (and the change file) evicted from the page cache. Each figure is the median of three single runs, the tools alternating, and is the tool process's own wall, without the bench's cache-eviction preparation. Where defaults differ in what is promised, osmium is given the flag that matches pbfhogg: --fsync on every command that writes a PBF, and --keep-member-nodes on add-locations-to-ways. osmium has one add-locations-to-ways mode, so both add-locations-to-ways rows time the same osmium command against pbfhogg's two index types. The commands are the vs-osmium bench, benches/compare/vs-osmium.lua.

The figures below were recorded with each tool's default compression (zlib level 6 on both). The bench now pins that on both sides explicitly on every row that writes a PBF (--compression zlib:6 for pbfhogg, pbf_compression=zlib,pbf_compression_level=6 for osmium), so a change of either tool's default cannot move the comparison. The timings do not establish that the two tools' outputs are equivalent: a successful exit proves the command ran. Whether the outputs agree is checked by the verifier, brokkr run --with pbfhogg pbfhogg-verify -- CHECK, whose checks run the same commands against osmium (reference/verify.md lists what each establishes). To rerun the table, scripts/vs-osmium.sh PAIRS DATASET OSC runs every row as PAIRS alternating single-iteration pairs (the inspect row, pbfhogg only), with OSC an explicit key in the dataset's OSC table for the apply-changes row; all three arguments are required.

Commandpbfhoggosmiumspeedup
inspect (indexdata)111 ms--answers from indexdata; no osmium counterpart
sort (already sorted, indexdata)305 ms7681 ms25.2x
apply-changes (indexdata)308 ms4484 ms14.5x
tags-filter -R w/highway=primary162 ms360 ms2.2x
tags-filter -R amenity=restaurant229 ms802 ms3.5x
cat --type way (raw passthrough)162 ms1488 ms9.2x
inspect tags (bare, every key)208 ms1029 ms5.0x
inspect tags --type way161 ms389 ms2.4x
getid (9 elements)119 ms619 ms5.2x
add-locations-to-ways (sparse)1401 ms7486 ms5.3x
add-locations-to-ways (external)1938 ms7479 ms3.9x

The largest speedups come from blob passthrough (sort, apply-changes, cat --type) where pbfhogg avoids decompressing and re-compressing unmodified blobs entirely. The commands that answer from indexdata (inspect, inspect tags --type way, getid) spend most of their cold time walking the blob headers. Each header's position comes from the one before it, so on a cold cache the walk reads ahead in 1 MiB windows on files of small blobs like this one, rather than paying one device latency per blob; a walk whose headers are already cached reads them alone.

Extract benchmarks ​

Japan (2.4 GB, Tokyo bbox), indexed PBFs, on plantasjen at commit cadc3e6. Best of three runs (or single-sample where noted in the source): reference/performance/extract.md, Extract.

Strategypbfhogg
simple3.8s
complete-ways3.7s
smart4.7s

Simple extract uses a 3-phase barrier pipeline with parallel classification and raw frame passthrough. Complete-ways and smart use multi-pass parallel pread classification. Spatial blob filtering skips decompression of node blobs outside the extract region when indexdata is present.

Apply-changes at scale ​

apply-changes uses blob-level indexdata to classify blobs and passes unmodified blobs through without decompression. Runtime and memory depend on the input and change set; see the commit- and host-pinned measurements in reference/performance/README.md.

Apply-changes with LocationsOnWays ​

Denmark (501 MB with LocationsOnWays, daily diff), on plantasjen at commit e7bbfa2:

Pipelinepbfhoggosmiumspeedup
apply-changes --locations-on-ways3.9s8.3s2.1x
apply-changes + ALTW (separate)2.7s + 6.5s = 9.2s4.3s + 9.5s = 13.8s--

These figures predate the inline-location refresh (commit 81f3fbe4): at e7bbfa2 the flag did not update ways the diff left alone, so a node the diff moved left them stale, and the run did less work than it does now. Since the refresh, the flag replaces the two-step pipeline with a single command, provided the base was made with add-locations-to-ways --keep-untagged-nodes; see reference/performance/README.md for measurements of the current code.

Planet-scale pipeline ​

Runtime and resource use depend on the command, input snapshot, encoding, and host. See reference/performance/README.md for measured command runs and reference/performance/README.md for optimization history.

Performance tips ​

Use indexed PBFs ​

Generate an indexed PBF once with pbfhogg cat, then use it for all subsequent operations. Commands on indexed PBFs skip decompression of irrelevant blobs entirely, which is where the largest speedups come from.

Choose the right ALTW index type ​

sparse is fastest while the referenced nodes' working set fits the page cache; past that, external trades heavy scratch-disk use for bounded memory, and auto, the default, picks between them at run time (staying on sparse where it cannot read the host's memory). When to use each is in Advanced Topics, and measured comparisons between the strategies are in Performance.

O_DIRECT for planet-scale I/O ​

Planet-scale operations read and write 80 GB+, polluting the entire page cache. The --direct-io flag bypasses the page cache entirely. Wall time is typically unchanged at country scale (CPU-bound) - the benefit is cache hygiene at planet scale and avoiding eviction of useful data from co-resident processes.

O_DIRECT wins for concurrent read/write patterns (merge). For sequential single-file passthrough (cat), buffered I/O is actually faster because the page cache prefetch helps.

io_uring for large writes ​

The --io-uring flag replaces the synchronous writer thread with io_uring WriteFixed. Compare it with buffered writes on the intended workload; see the commit- and host-pinned measurements in reference/performance/README.md.

Compression choice ​

With pipelined writes (the production path), compression is dispatched to rayon and all modes converge to the decode + serialization floor. The choice mainly affects file size and downstream read speed:

  • none - fastest writes, largest files, ideal for intermediate files or erofs storage
  • zlib - standard PBF compression, compatible with all tools
  • zstd - better ratio and faster decompression, but not all consumers support it yet

System ​

The CLI command table was measured on bygg, AMD Ryzen 9 9950X3D2 (16c/32t), at commit 53360af4. The read throughput, write throughput, extract and apply-changes with LocationsOnWays tables were measured on plantasjen, AMD Ryzen 9 5900X (12c/24t), 32 GB DDR4, NVMe SSD, at the older commits each table names; they have not been re-measured since. Measured with brokkr, and cross-validated with brokkr run --with pbfhogg pbfhogg-verify -- for every command it compares against osmium (inspect tags is not among them).

Released under the Apache License 2.0. | Copyright folk@folk.wtf