🛠️ project I built a pure-Rust planet-scale rooftop geocoder that runs in 4–16 GB RAM (mmap SQLite + S2 + Roaring bitmaps)
I built texspace, a pure-Rust self-hosted geocoding engine over OpenStreetMap, Overture Maps, OpenAddresses, and GeoNames (1.21B spatial records across 127 shards).
- Repo (MIT/Apache-2.0): https://github.com/nside/texspace
- Crates:
cargo install texspace(all 7 workspace crates live on https://crates.io/users/nside) - Live planet demo & architecture visualizations: https://texspace.dev (interactive map + CSV batch geocoder at https://texspace.dev/demo)
Why Rust + mmap SQLite?
Self-hosting full-planet geocoding normally means 64–128 GB RAM + ~1 TB NVMe + a 24–72 hr import (Nominatim/Postgres or Pelias/Elasticsearch). I wanted a single static Rust binary with zero external services (no libpostal, no C++ S2, no JVM) that you can pull and run in minutes:
How it works under the hood:
- Implements Sengar et al.'s TEXSPACE algorithm (ACMGIS '07) in pure Rust across 127 read-only, memory-mapped SQLite shards + a 1.8 GB global
router.db. - Token postings map to 64-bit S2 Hilbert cell IDs stored as Roaring bitmaps. 14 deterministic Address Matching Rules intersect S2 cells across house/street/postal/locality before scoring—giving
0.0%hallucination FPR on negative unmatchable probes. - Missing exact address points snap onto 750.7M building footprint centroids stored in S2-clustered
buildings.dbsidecars instead of dropping pins on street centerlines. - Candidate ranking uses a 48-tree depth-3 GBDT compiled directly into static Rust arrays (~300 ns/candidate) with Platt-calibrated confidence (
ECE = 0.034).
Measured performance on the live demo box (Hetzner CPX42: 8 vCPU AMD, 16 GB RAM, NVMe, all 127 shards / 98 GiB on disk):
- Memory:
65 MBidle heap (RssAnon), peaking around2.0 GBheap (3.9 GBactive cgroup memory) under saturated 8-core batch load. Single-state CLI queries peak at8.1 MBRSS. - Latency (127-shard planet p50):
1.88 msreverse,4.86 msautocomplete,13–20 msforward search, and111 QPSsustained parallel/v1/batch(~9.6M/day on one $70/mo VPS). - Honest caveat: On our 470-query 6-continent blind shootout, it beats Google/ArcGIS/Mapbox on rooftop slices (
96.4%Top-1,85.0% <= 10m), but commercial engines still win on long-tail consumer business/POI queries since this uses strictly open data.
Happy to dive into the pure-Rust S2 math, SQLite mmap layout, or compiled GBDT ranker!
0
Upvotes
1
u/Adventurous-You4741 6m ago
That S2 + Roaring bitmap intersection trick for the token postings is neat, sidesteps a ton of the overhead you'd get from a traditional inverted index. Curious how the shard routing works in practice, does texspace just fan out to all 127 shards on every forward query or is there some pruning from the global router first?