Skip to content

scripts/terrain: pack tiler worklist into a numpy int64 array#470

Merged
tridge merged 1 commit into
ArduPilot:masterfrom
tridge:tiler-numpy-worklist
Jun 19, 2026
Merged

scripts/terrain: pack tiler worklist into a numpy int64 array#470
tridge merged 1 commit into
ArduPilot:masterfrom
tridge:tiler-numpy-worklist

Conversation

@tridge

@tridge tridge commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

The worklist was a Python set of (z,x,y) tuples plus a redundant per_level dict of (x,y) tuples (~370 bytes/tile), so a 12.5M-tile z12 build held ~4.6GB in the parent and got OOM-killed on a small box. ProcessPoolExecutor.map also submitted the whole list eagerly, re-materialising it as futures.

Pack each tile into one int64 (z<<40|x<<20|y) in a numpy array, dedup+sort with np.unique (same lexicographic z,x,y order as the old tuple sort), build per_level availability only when writing layer.json, and feed the pool in 100k-tile batches so the parent never materialises all futures at once. A 12.5M worklist is now ~100MB. Output is unchanged: a 2x2deg z10-12 build matches the old code - layer.json byte-identical and all 2870 tiles identical when decompressed.

The worklist was a Python set of (z,x,y) tuples plus a redundant per_level dict
of (x,y) tuples (~370 bytes/tile), so a 12.5M-tile z12 build held ~4.6GB in the
parent and got OOM-killed on a small box. ProcessPoolExecutor.map also submitted
the whole list eagerly, re-materialising it as futures.

Pack each tile into one int64 (z<<40|x<<20|y) in a numpy array, dedup+sort with
np.unique (same lexicographic z,x,y order as the old tuple sort), build per_level
availability only when writing layer.json, and feed the pool in 100k-tile batches
so the parent never materialises all futures at once. A 12.5M worklist is now
~100MB. Output is unchanged: a 2x2deg z10-12 build matches the old code -
layer.json byte-identical and all 2870 tiles identical when decompressed.
@tridge
tridge merged commit 82fdcac into ArduPilot:master Jun 19, 2026
2 checks passed
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