Commit e1f47e1
committed
perf(osm): parallel ring assembly + linestring resolution
`relation_to_admin` does two independent expensive passes per
admin relation:
1. `assemble_rings(outer)` and `assemble_rings(inner)` — endpoint-
matching ring stitcher. Each ring set is independent; outer +
inner have no shared state.
2. `ring_to_linestring(ring, node_coords)` for each ring — node-id
to coord lookup. Each ring resolves independently against the
shared (read-only) `node_coords` cache.
Both passes ran sequentially. Big admin relations (coastlines
stitched from thousands of ways, country borders with deep
hierarchies) bottlenecked on the ring assembly pass — observed
~1-2 s wall-clock for some relations on a single thread, blocking
the parent blob's `par_bridge` worker.
Two surgical edits inside `relation_to_admin`:
- `rayon::join` runs outer + inner ring stitching in parallel.
Free for cheap relations (one side returns immediately) and
cuts wall-clock by ~50% on relations with substantial rings on
both sides.
- `into_par_iter()` over each ring set's `ring_to_linestring`
resolution. Per-ring work is independent; rayon's work-stealing
pool spreads the linear-scan node lookups across cores.
Both calls live inside an already-parallel context
(`parallel_admin_relations` -> `par_bridge`), so we're nesting
parallelism inside rayon. rayon handles this correctly via its
work-stealing scheduler — there's no thread blow-up.
Combined with the per-tile-write parallelism (620fc35), the OSM
critical path now scales close to linearly with cores on the
two passes that previously dominated wall-clock (relations
~120 s of a 633 s DE bench, tile encode ~30 s).
Workspace tests stay green; clippy clean.1 parent 620fc35 commit e1f47e1
1 file changed
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1541 | 1541 | | |
1542 | 1542 | | |
1543 | 1543 | | |
1544 | | - | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
1545 | 1554 | | |
1546 | 1555 | | |
1547 | 1556 | | |
1548 | 1557 | | |
1549 | 1558 | | |
1550 | | - | |
1551 | 1559 | | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
1552 | 1565 | | |
1553 | | - | |
| 1566 | + | |
1554 | 1567 | | |
1555 | 1568 | | |
1556 | 1569 | | |
1557 | 1570 | | |
1558 | 1571 | | |
1559 | 1572 | | |
1560 | 1573 | | |
1561 | | - | |
| 1574 | + | |
1562 | 1575 | | |
1563 | 1576 | | |
1564 | 1577 | | |
| |||
0 commit comments