perf: reduce water nuke terrain update spikes - #5011
Conversation
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review. WalkthroughTerrain row spans now merge into bounded rectangles and include unchanged gap tiles in uploads. Water graph rebuilding is deferred for one tick after water terrain conversions. ChangesTerrain and water update behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This PR reduces terrain-update and water-simulation spikes while preserving terrain results and adding focused coverage; no actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant WaterManager
participant TerrainConversionQueue
participant WaterGraph
WaterManager->>TerrainConversionQueue: Process pending conversions
TerrainConversionQueue-->>WaterManager: Report conversion occurred
WaterManager-->>WaterGraph: Skip rebuild on conversion tick
WaterManager->>WaterGraph: Rebuild on next eligible tick
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
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 |
Description
Water nukes could cause noticeable frame and simulation spikes when large terrain deltas were applied.
This PR reduces those spikes in two ways:
Previously, each changed row produced a separate
texSubImage2Dcall for each of the three terrain textures. Compact crater-shaped deltas can now be uploaded as a single rectangle. Unchanged texels inside a merged rectangle are uploaded using their current terrain value, so the rendered result remains unchanged.Rectangles are only merged when the additional upload area is bounded:
Performance
Synthetic WebGL2 benchmark using Giant World Map-sized textures (
4108×1948). The benchmark mirrors the production terrain-delta path: RGBA terrain encoding followed by uploads to the terrain, railroad, and shared terrain-byte textures.Each result is the median of 11 samples, with 50 uploads per sample. Results were reproduced across three browser runs.
For a hydrogen-bomb-shaped delta, the number of WebGL upload calls is reduced by 99.5%, from 603 to 3.
On Giant World Map, separating terrain finalization from water-graph rebuilding also reduced the measured worst water-nuke simulation tick:
Correctness
Tests
npx vitest run tests/client/render/frame/derive/terrain-row-spans.test.ts tests/nukes/WaterNukes.test.tsnpx tsc --noEmitPlease complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
aotumuri