refacto(exporter): draw maps at 4096 px/cell faster in smaller blocks, the output unchanged #84

Merged
Superkooka merged 3 commits from refacto/map-small-regions into main 2026-11-04 02:24:48 +00:00
Owner

Grid and PMTiles maps now draw blocks of 4 x 4 tiles, one per logical core from
2 to 32, instead of blocks of 16 x 16 tiles, 2 at a time. More regions keep the
cores busy, and a smaller block redraws fewer levels. Plain PNG bands stay at 2
at a time: a band holds 16 times a block's pixels.

Add --jobs to the map commands, 'auto' or a count, to set the regions drawn at
once. Each region's own loops still use every core, so it doesn't limit the CPU.
The region pools follow the count, and the manifest leaves the option out.

On 16 logical cores, Blackreach at 4096 px/cell goes from 213 s and 8.7 GB to
133 s and 6.6 GB, Skuldafn from 48 s to 45 s and Whiterun from 16 s to 15 s,
both from about 7 GB to under 5 GB. PNG hashes are identical, also on 4 and 8
logical cores on shorter runs. PMTiles archives differ in tile order only, with
no tile or pixel changed on Whiterun. Tamriel at 4096 px/cell was not run.

Grid and PMTiles maps now draw blocks of 4 x 4 tiles, one per logical core from 2 to 32, instead of blocks of 16 x 16 tiles, 2 at a time. More regions keep the cores busy, and a smaller block redraws fewer levels. Plain PNG bands stay at 2 at a time: a band holds 16 times a block's pixels. Add --jobs to the map commands, 'auto' or a count, to set the regions drawn at once. Each region's own loops still use every core, so it doesn't limit the CPU. The region pools follow the count, and the manifest leaves the option out. On 16 logical cores, Blackreach at 4096 px/cell goes from 213 s and 8.7 GB to 133 s and 6.6 GB, Skuldafn from 48 s to 45 s and Whiterun from 16 s to 15 s, both from about 7 GB to under 5 GB. PNG hashes are identical, also on 4 and 8 logical cores on shorter runs. PMTiles archives differ in tile order only, with no tile or pixel changed on Whiterun. Tamriel at 4096 px/cell was not run.
refacto(exporter): draw grid maps in smaller blocks, one per logical core, the output unchanged
Some checks failed
/ docs (push) Successful in 5s
/ format (push) Successful in 2m43s
/ test (push) Successful in 3m23s
Benchmarks / compare (pull_request) Has been cancelled
56f0fadfae
Grid and PMTiles maps now draw blocks of 4 x 4 tiles, one per logical core from
2 to 32, instead of blocks of 16 x 16 tiles, 2 at a time. More regions keep the
cores busy, and a smaller block redraws fewer levels. Plain PNG bands stay at 2
at a time: a band holds 16 times a block's pixels.

Add --jobs to the map commands, 'auto' or a count, to set the regions drawn at
once. Each region's own loops still use every core, so it doesn't limit the CPU.
The region pools follow the count, and the manifest leaves the option out.

On 16 logical cores, Blackreach at 4096 px/cell goes from 213 s and 8.7 GB to
133 s and 6.6 GB, Skuldafn from 48 s to 45 s and Whiterun from 16 s to 15 s,
both from about 7 GB to under 5 GB. PNG hashes are identical, also on 4 and 8
logical cores on shorter runs. PMTiles archives differ in tile order only, with
no tile or pixel changed on Whiterun. Tamriel at 4096 px/cell was not run.
refacto(exporter): decide a region's levels before drawing it, the output unchanged
All checks were successful
/ docs (push) Successful in 5s
/ format (push) Successful in 2m26s
/ test (push) Successful in 3m19s
Benchmarks / compare (pull_request) Successful in 19m15s
9e618f01f9
A region now asks which levels change before it draws its background. Where
none does, it draws like a map of one level: the terrain leaves its colors until
a layer reads them, and nothing is copied per level. LevelCut.Differs walks only
the rows and columns that enter a new cell or floor sample.

Blackreach at 4096 px/cell goes from 133 s and 6.6 GB to 125 s and 6.4 GB,
DLC1DarkfallPassageWorld at 2048 from 14.8 s to 13.8 s, in one run each. PNG
hashes are identical on both.

Benchmarks

Base 41436065 against head f8d07131, alternating over 5 rounds on the same runner.
Times are per operation, the fastest round of each side. A change counts only when every round shows it beyond the error margins of both runs; otherwise it is marked as noise.
A shared runner is noisy: trust the allocations more than the times, and confirm a time on an idle machine.

Benchmark Parameters Base Head Change Rounds Base allocated Head allocated
LandscapeRasterizerBenchmarks.Draw Kernel=bicubic 24.07 ns 18.02 ns -25.14 % (faster), allocations changed -40.13 % to -10.25 % 1 B 0 B
LandscapeRasterizerBenchmarks.Draw Kernel=bilinear 20.09 ns 16.21 ns -19.33 % (noise), allocations changed -31.71 % to +7.2 % 1 B 0 B
All benchmarks (10)
Benchmark Parameters Base Head Change Rounds Base allocated Head allocated
LandscapeRasterizerBenchmarks.Draw Kernel=bicubic 24.07 ns 18.02 ns -25.14 % (faster), allocations changed -40.13 % to -10.25 % 1 B 0 B
LandscapeRasterizerBenchmarks.Draw Kernel=bilinear 20.09 ns 16.21 ns -19.33 % (noise), allocations changed -31.71 % to +7.2 % 1 B 0 B
ObjectRasterizerBenchmarks.Draw Scenario=texture 53.03 ns 53.29 ns +0.49 % (noise) -8.02 % to +9.16 % 0 B 0 B
ObjectRasterizerBenchmarks.Draw Scenario=texture-blended 64.83 ns 65.34 ns +0.79 % (noise) -1.25 % to +27.08 % 24 B 24 B
ObjectRasterizerBenchmarks.Draw Scenario=texture-cut 29.87 ns 29.88 ns +0.04 % (noise) -2.1 % to +50.62 % 0 B 0 B
ObjectRasterizerBenchmarks.Draw Scenario=texture-lit 33.5 ns 33.78 ns +0.81 % (noise) +0.21 % to +90.84 % 0 B 0 B
ObjectRasterizerBenchmarks.Draw Scenario=wireframe 10.49 ns 10.49 ns +0.02 % (noise) -13.69 % to +197.24 % 0 B 0 B
ObjectTextureBenchmarks.Sample Kernel=bicubic 93.75 ns 93.89 ns +0.15 % (noise) -3.99 % to +27.96 % 0 B 0 B
ObjectTextureBenchmarks.Sample Kernel=bilinear 58.12 ns 56.72 ns -2.41 % (noise) -8.3 % to +12.85 % 0 B 0 B
PngEncoderBenchmarks.Encode 89.51 ns 89.39 ns -0.13 % (noise) -8.76 % to +5.49 % 4 B 4 B
<!-- benchmark-report --> ### Benchmarks Base `41436065` against head `f8d07131`, alternating over 5 rounds on the same runner. Times are per operation, the fastest round of each side. A change counts only when every round shows it beyond the error margins of both runs; otherwise it is marked as noise. A shared runner is noisy: trust the allocations more than the times, and confirm a time on an idle machine. | Benchmark | Parameters | Base | Head | Change | Rounds | Base allocated | Head allocated | |---|---|---|---|---|---|---|---| | `LandscapeRasterizerBenchmarks.Draw` | Kernel=bicubic | 24.07 ns | 18.02 ns | -25.14 % (faster), allocations changed | -40.13 % to -10.25 % | 1 B | 0 B | | `LandscapeRasterizerBenchmarks.Draw` | Kernel=bilinear | 20.09 ns | 16.21 ns | -19.33 % (noise), allocations changed | -31.71 % to +7.2 % | 1 B | 0 B | <details> <summary>All benchmarks (10)</summary> | Benchmark | Parameters | Base | Head | Change | Rounds | Base allocated | Head allocated | |---|---|---|---|---|---|---|---| | `LandscapeRasterizerBenchmarks.Draw` | Kernel=bicubic | 24.07 ns | 18.02 ns | -25.14 % (faster), allocations changed | -40.13 % to -10.25 % | 1 B | 0 B | | `LandscapeRasterizerBenchmarks.Draw` | Kernel=bilinear | 20.09 ns | 16.21 ns | -19.33 % (noise), allocations changed | -31.71 % to +7.2 % | 1 B | 0 B | | `ObjectRasterizerBenchmarks.Draw` | Scenario=texture | 53.03 ns | 53.29 ns | +0.49 % (noise) | -8.02 % to +9.16 % | 0 B | 0 B | | `ObjectRasterizerBenchmarks.Draw` | Scenario=texture-blended | 64.83 ns | 65.34 ns | +0.79 % (noise) | -1.25 % to +27.08 % | 24 B | 24 B | | `ObjectRasterizerBenchmarks.Draw` | Scenario=texture-cut | 29.87 ns | 29.88 ns | +0.04 % (noise) | -2.1 % to +50.62 % | 0 B | 0 B | | `ObjectRasterizerBenchmarks.Draw` | Scenario=texture-lit | 33.5 ns | 33.78 ns | +0.81 % (noise) | +0.21 % to +90.84 % | 0 B | 0 B | | `ObjectRasterizerBenchmarks.Draw` | Scenario=wireframe | 10.49 ns | 10.49 ns | +0.02 % (noise) | -13.69 % to +197.24 % | 0 B | 0 B | | `ObjectTextureBenchmarks.Sample` | Kernel=bicubic | 93.75 ns | 93.89 ns | +0.15 % (noise) | -3.99 % to +27.96 % | 0 B | 0 B | | `ObjectTextureBenchmarks.Sample` | Kernel=bilinear | 58.12 ns | 56.72 ns | -2.41 % (noise) | -8.3 % to +12.85 % | 0 B | 0 B | | `PngEncoderBenchmarks.Encode` | | 89.51 ns | 89.39 ns | -0.13 % (noise) | -8.76 % to +5.49 % | 4 B | 4 B | </details>
refacto(exporter): read the terrain pattern from per-texture tiles on power-of-two scales, the output unchanged
All checks were successful
/ docs (push) Successful in 5s
/ format (push) Successful in 2m42s
/ test (push) Successful in 3m22s
Benchmarks / compare (pull_request) Successful in 19m39s
f8d071310b
Superkooka changed title from refacto(exporter): draw grid maps in smaller blocks, one per logical core, the output unchanged to refacto(exporter): draw maps at 4096 px/cell faster in smaller blocks, the output unchanged 2026-11-04 02:22:45 +00:00
Superkooka deleted branch refacto/map-small-regions 2026-11-04 02:24:48 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Superkooka/SkyrimSourceExporter!84
No description provided.