Repository navigation
perf(planner): the sun bake reads the terrain grid in place and traces bands of tiles on every core - #2742
Merged
Conversation
…and traces bands of tiles on every core `terrain_grid` hashes each grid archive once and gives the bake a `Tiles` reader over the archives, so the step no longer writes a merged copy of the terrain. A tile comes from the archive of its zoom-11 tile. The command line reads one archive through the same reader. The horizons trace in bands of 16 zoom-12 tile rows on a thread per core. A band holds the heights of every level that a ray from it reaches: its rows, and a halo of the rows within `distance_m` at the band edge farther from the equator. This replaces the memory map of every zoom-12 pixel of the coverage. The index tiles and the overview tiles of each zoom also run on the threads. Every pool keeps the old tile order, so the archive bytes do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ives Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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. Comment |
…hreads to its cores, and tests its bands - `terrain_grid` reads the directories of each grid archive and refuses a tile that is not in the archive of its zoom-11 tile, as the rebuild did: `Tiles.get` looks only there. - The thread pools use the cores that the process may use (`step_pool.cores`). The terrain cache of the index bake holds the 25 tiles of each index tile in flight. - A test bakes bowl terrain, where every ray reads heights to its full distance, with bands of one tile row and with one band, and compares the archives. A halo of 2 pixels fails it. - The step test again checks that the grid archives hold no other tile, and that a tile in another archive stops the step. `tools/step_pool.py` is the same file as in #2741. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
planner/sunnow reads the terrain grid archives in place, holds the heights of one band of tile rows at a time, and runs every tile pass on a thread per core. Before, it wrote a merged copy of the terrain, memory-mapped every zoom-12 pixel of the coverage, and traced on 2 threads.terrain_gridhashes each grid archive once (on threads) and gives the bake aTilesreader. A tile comes from the archive of its zoom-11 tile. Before,materializehashed each object twice and the step wrote all tiles again into a temporaryterrain.pmtiles. A grid archive must be stored as it is (identity), whichpack_filealways does for.pmtiles.terrain_gridreads the directories of each grid archive and refuses a tile that is not in the archive of its zoom-11 tile, as the rebuild did.load_arraysholds, at every level, the rows of the band and the rows that a ray ofdistance_mfrom it reaches. The halo comes from the pixel size at the band edge farther from the equator, plus 2 pixels for the bilinear corners and the rounding. A height outside the arrays is unknown, as before outside the coverage, so the halo must reach every row that a ray reaches.step_pool.cores, fromsched_getaffinity):trace_tileisnogil. The index tiles of each zoom, the overview tiles of each zoom, and the tile decodes of a band also run on the threads: WebP decode and numpy release the interpreter lock. The terrain cache of the index bake holds 25 tiles per thread, because each index tile in flight reads 25 terrain tiles.planner_sun.py --terrainreads its one archive through the sameTilesreader.tools/step_pool.pyis the same file as in perf(planner): the climate bake runs its spatial chunks on every core #2741 (climate), which also moves the snow pool into it. Here the sun step uses onlycores(). Thesuites.tomltrigger line is the same in both PRs.planner-sun-tiles.mdand theplanner/sunrow ofobc-data.mdsay that the step reads the tiles from the grid archives. It no longer reconstructs an archive.Why
The DACH run of 2026-10-17 (
runs/2026-10-17-071235) did not reachplanner/sun. These figures come from the code and the DACH terrain layer:load_arrayswrote a 13.4 GB memory map: 25,521 zoom-12 tiles of coverage, 141 tiles wide.terrain_gridhashed 5.37 GB of grid archives twice and wrote them again as one archive.Estimates, not measured on DACH.
This is the sun part of the bake system review.
Tests
Byte check. I cut the tiles of a coverage box at zooms 0 to 12 from the DACH
terrain.mbtilesin the store, and gridded them withplanner_grid_maps.step. The develop code and this code ranplanner_sun.stepon the same grid.BAND=1andBAND=2make several bands with partial windows.distance_mBAND=16), 6.2 s (BAND=1)9aef8173…BAND=16), 9.7 s (BAND=2)a25c80e1…9aef8173…again, with all cores.bakeof one PMTiles archive, Grimsel) gives the same SHA-256 in both:35707f75….test_bands_of_one_tile_row_trace_what_one_band_tracesbakes bowl terrain, where every ray reads heights to its full distance (10 km, more than one tile row), with bands of one tile row and with one band. The archives must be the same. With a halo of 2 pixels, the test fails.tools/testssuite, as CI runs it (--group dev --group planner-snow --group planner-sun): 332 tests OK.obc suites check: OK.Not run: a real sun bake, because the machine runs other work.
Public docs: no change. The spec change is its own
docs(spec):commit.Requirements: none
🤖 Generated with Claude Code