Skip to content

perf(ingest): store node locations in a sorted Vec - #2746

Open
timohueser wants to merge 1 commit into
developfrom
claude/practical-albattani-e8eae0
Open

timohueser wants to merge 1 commit into
developfrom
claude/practical-albattani-e8eae0

Conversation

@timohueser

Copy link
Copy Markdown
Owner

Summary

The OSM ingest kept every node of a source in a HashMap<i64, (i32, i32)>. On a large leaf, this map is most of the ingest peak, and it doubles while it grows.

This change adds NodeCoords to obc_places::osm. It is a Vec<(i64, (i32, i32))> sorted by id, with binary search for lookups (16 bytes per node). A sorted PBF fills it in id order, so freeze does not sort. On a duplicate id, the first location wins. This is also the rule for a merge of sources. obc_draw::ingest and obc_places::osm::harvest both use it, because they share resolve_coords.

Measurements

Leaf europe/dach 0037-0033 (2.5 GB PBF). obc_draw::ingest::ingest_osm_ways with CELL_SCHEMA. glibc mallinfo2 heap in use (uordblks + hblkhd), sampled every 250 ms. Both binaries were built from clean private target dirs, base = dfdc377.

base this PR
pass 1 (nodes) peak heap 12.83 GiB 4.44 GiB
pass 2 (ways) peak heap 17.73 GiB 12.84 GiB
ingest wall time 909 s 364 s
SHA-256 of ingest output (features, coastlines, POIs, links, routable ways) 2262f4fb… 2262f4fb… (same)

The remaining pass-2 peak is the features (30.2 M) and routable ways (8.0 M) that the ingest returns, plus the 3.8 GiB node store.

Output bytes

I replayed the whole device/coarse/0037-0033 cells step with this branch, from the stored receipt layers/87bc80d9b47c….json and its PBF and land-polygons objects. 31/31 files match the stored SHA-256, with no extra files. On this base, the whole-step peak is still the LOD 8 polygonize (26.4 GiB), which #2731 removes. With #2731, ingest now stays under the step's next-largest peak.

Checks

  • obc test -p obc-places (47 passed, including the new node_coords_first_location_wins)
  • obc test -p obc-draw (102 passed)
  • cargo clippy -p obc-places --all-targets -- -D warnings, cargo clippy -p obc-draw --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • Not run: other harvest callers (obc-pack, obc-network, obc-search-bake) and their suites. harvest gets the same lookup semantics.

Public docs did not change.

Requirements: none

🤖 Generated with Claude Code

The OSM ingest of obc-draw and the place harvest of obc-places kept every
node of a source in a HashMap<i64, (i32, i32)>. A sorted Vec with binary
search takes 16 bytes per node, and a sorted PBF fills it without a sort.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 917e10dd-bee4-4a91-86d7-a1c0ce23ccde
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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