perf(worldgen): per-world wonder profile — undo the #698–#709 hot-path cost - #713
Merged
Conversation
…h cost (#712) Pure refactor, bit-identical terrain (verified via an FNV height/band/tunnel hash sweep over every planet type x seeds x continents on/off): - WonderProfile cached per world (CalibFor pattern + lock-free instance fast path): feature gates, PlanetSeed, terrain grain, hybrid thresholds, continent profile and the lowered style resolve once per world instead of per column — no more per-column ToLowerInvariant allocations or Noise.Hash world rolls. - Tunnel worms are built once per cell (static cache + instance slot) instead of per column; AddSegmentSpan gains an XZ bounding reject. - Sea stacks / hoodoos / cenotes check distance BEFORE computing their RawSurfaceHeight anchor (and the stack swell probe) — every column of a feature-bearing cell used to pay the full anchor. Measured: harness sweep 2174 -> 1472 ms (-32%); local fast tier 7m05 -> 5m31. Co-Authored-By: Claude Fable 5 <[email protected]>
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.
Pure refactor of the terrain-wonders hot path — bit-identical terrain, verified by an FNV hash sweep (surface heights + extra bands + tunnel spans) over every planet type × two seeds × continents on/off, captured before the refactor and matched after every step.
What was slow
SurfaceHeight— the hottest function in the codebase (256 columns/chunk, ~17k-sample per-world calibration, rivers, previews, placement) — re-derived per COLUMN what is constant per WORLD: feature gates withToLowerInvariant()string allocations,Noise.Hashworld rolls, repeated planet-key hashing. Worse, the tunnel carver rebuilt its whole worm polyline (dozens of xorshift rolls) for every column of every tunnel-bearing cell (half the map), and sea stacks/hoodoos/cenotes computed a fullRawSurfaceHeightanchor before checking whether the column is even inside the feature.The fix
WonderProfile, cached per world like the calibration (static dict + lock-free instance fast path): planet seed, terrain grain, hybrid thresholds, continent profile, lowered style and one boolean per feature family. Per-column code reads booleans and doubles only.Measured
closes #712
🤖 Generated with Claude Code