[GH-ISSUE #480] [performance] Clouds cost up to ~1.8 ms of CPU per frame and grow with Cloud Distance (370 vs 1,150 FPS standing still) #135

Closed
opened 2026-11-02 15:36:40 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Enzerot on GitHub (Oct 16, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/480

What happens

With clouds on, the frame rate is CPU-bound by the clouds, and the cost grows with Cloud Distance roughly as its square. Standing still in a creative world, the default Cloud Distance of 128 takes the game from about 1,150 FPS (clouds off) to about 370 FPS, while the GPU stays at 0.12 to 0.14 ms per frame. The cost doesn't go away when the camera doesn't move, so the cloud mesh looks rebuilt every frame on the main thread.

For comparison, vanilla 26.3 on the same machine with clouds on (Cloud Distance 64, the rest of the video settings the same) runs at 1,000+ FPS. Horizon with clouds off runs at the same ~1,000+ FPS.

Measurements

Horizon v2026.10.16.03, a fresh creative world (seed 1234), the player standing still at spawn after every chunk loaded, render distance 12, window 1280x720, VSync off, unlimited frame rate (maxFps:260), present mode Immediate. Each row is horizon-ctl bench 6; only the cloud options change between rows.

Clouds Cloud Distance avg FPS CPU ms/frame prepare ms render ms GPU ms/frame
Fancy 128 362 2.36 1.45 0.73 0.14
Fast 128 424 2.00 1.03 0.82 0.14
Fancy 64 700 1.07 0.57 0.39 0.13
Fast 64 767 1.00 0.48 0.42 0.13
Fast 32 1,027 0.70 0.33 0.29 0.12
Off - 1,132 0.61 0.29 0.25 0.12

Other observations:

  • Render distance doesn't change it: with Fancy clouds at 128, render distance 2, 6 and 12 give 412, 395 and 386 FPS, with the same ~1.35 ms in prepare.
  • The process uses about 0.9 of a core while standing still; the worker threads are idle (nothing queued in streaming), so this is the main thread, not #271.
  • Entity shadows, particles and smooth lighting make no measurable difference next to the clouds.

As far as I know, vanilla's CloudRenderer keeps its built mesh and only rebuilds it when the camera's cloud cell, its position relative to the cloud layer or the cloud type changes, which would explain why vanilla doesn't pay this every frame.

How to reproduce

  1. horizon-ctl launch --world CloudProbe --seed 1234 --creative --wait, then wait until nothing is queued.
  2. horizon-ctl options-set renderClouds true, horizon-ctl options-set cloudRange 128, horizon-ctl bench 6.
  3. horizon-ctl options-set renderClouds false, horizon-ctl bench 6, and compare.

Machine

Windows 11 Pro (26200), AMD Ryzen 7 9800X3D (8 cores, 16 threads), 32 GB RAM, AMD Radeon RX 7900 XTX (AMD proprietary driver 26.8.1, LLPC), Vulkan backend.

Originally created by @Enzerot on GitHub (Oct 16, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/480 ## What happens With clouds on, the frame rate is CPU-bound by the clouds, and the cost grows with Cloud Distance roughly as its square. Standing still in a creative world, the default Cloud Distance of 128 takes the game from about 1,150 FPS (clouds off) to about 370 FPS, while the GPU stays at 0.12 to 0.14 ms per frame. The cost doesn't go away when the camera doesn't move, so the cloud mesh looks rebuilt every frame on the main thread. For comparison, vanilla 26.3 on the same machine with clouds on (Cloud Distance 64, the rest of the video settings the same) runs at 1,000+ FPS. Horizon with clouds off runs at the same ~1,000+ FPS. ## Measurements Horizon v2026.10.16.03, a fresh creative world (seed 1234), the player standing still at spawn after every chunk loaded, render distance 12, window 1280x720, VSync off, unlimited frame rate (`maxFps:260`), present mode Immediate. Each row is `horizon-ctl bench 6`; only the cloud options change between rows. | Clouds | Cloud Distance | avg FPS | CPU ms/frame | prepare ms | render ms | GPU ms/frame | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | Fancy | 128 | 362 | 2.36 | 1.45 | 0.73 | 0.14 | | Fast | 128 | 424 | 2.00 | 1.03 | 0.82 | 0.14 | | Fancy | 64 | 700 | 1.07 | 0.57 | 0.39 | 0.13 | | Fast | 64 | 767 | 1.00 | 0.48 | 0.42 | 0.13 | | Fast | 32 | 1,027 | 0.70 | 0.33 | 0.29 | 0.12 | | Off | - | 1,132 | 0.61 | 0.29 | 0.25 | 0.12 | Other observations: - Render distance doesn't change it: with Fancy clouds at 128, render distance 2, 6 and 12 give 412, 395 and 386 FPS, with the same ~1.35 ms in `prepare`. - The process uses about 0.9 of a core while standing still; the worker threads are idle (nothing queued in `streaming`), so this is the main thread, not #271. - Entity shadows, particles and smooth lighting make no measurable difference next to the clouds. As far as I know, vanilla's `CloudRenderer` keeps its built mesh and only rebuilds it when the camera's cloud cell, its position relative to the cloud layer or the cloud type changes, which would explain why vanilla doesn't pay this every frame. ## How to reproduce 1. `horizon-ctl launch --world CloudProbe --seed 1234 --creative --wait`, then wait until nothing is queued. 2. `horizon-ctl options-set renderClouds true`, `horizon-ctl options-set cloudRange 128`, `horizon-ctl bench 6`. 3. `horizon-ctl options-set renderClouds false`, `horizon-ctl bench 6`, and compare. ## Machine Windows 11 Pro (26200), AMD Ryzen 7 9800X3D (8 cores, 16 threads), 32 GB RAM, AMD Radeon RX 7900 XTX (AMD proprietary driver 26.8.1, LLPC), Vulkan backend.
Author
Owner

@ludovic111 commented on GitHub (Oct 16, 2026):

Thank you @Enzerot, this was an excellent report: the per-row measurements and the pointer to vanilla's rebuild rule made the fix straightforward.

You were right: Horizon rebuilt every cloud quad on the main thread every frame. #487 keeps the mesh as vanilla 26.3's CloudRenderer does. It is rebuilt only when the camera's cloud cell, its side of the cloud layer, the cloud type or the Cloud Distance changes. Each frame the shader moves it by the offset into the cell. The clouds look the same: compared frame by frame from below, inside and above the layer and while flying through it, frames are identical or differ in at most 3 pixels by 1/255, with no popping.

Same setup as yours (horizon-ctl bench 6, fresh creative world seed 1234, standing still, render distance 12, 1280x720, VSync off, unlimited FPS), measured on a Mac mini M4 Pro (Metal, offscreen), average of two runs each:

Before (origin/main)

Clouds Cloud Distance avg FPS CPU ms/frame prepare ms render ms
Fancy 128 466 2.13 1.10 0.91
Fast 128 493 2.01 0.78 1.13
Fancy 64 1,375 0.72 0.32 0.35
Fast 64 1,456 0.68 0.23 0.41
Fancy 32 2,361 0.40 0.14 0.23
Fast 32 2,286 0.40 0.11 0.26
Off - 2,456 0.29 0.07 0.18

After (this PR)

Clouds Cloud Distance avg FPS CPU ms/frame prepare ms render ms
Fancy 128 1,588 0.34 0.09 0.20
Fast 128 1,577 0.31 0.08 0.19
Fancy 64 1,812 0.29 0.07 0.18
Fast 64 2,328 0.26 0.07 0.17
Fancy 32 2,441 0.26 0.07 0.17
Fast 32 2,440 0.27 0.07 0.17
Off - 2,476 0.27 0.07 0.16

With clouds on, CPU time is now within ~0.07 ms of clouds off at every Cloud Distance. What's left at 128 is GPU time to draw the clouds. A run on your Windows/Vulkan machine once it's merged would be very welcome.

<!-- gh-comment-id:6214511953 --> @ludovic111 commented on GitHub (Oct 16, 2026): Thank you @Enzerot, this was an excellent report: the per-row measurements and the pointer to vanilla's rebuild rule made the fix straightforward. You were right: Horizon rebuilt every cloud quad on the main thread every frame. #487 keeps the mesh as vanilla 26.3's `CloudRenderer` does. It is rebuilt only when the camera's cloud cell, its side of the cloud layer, the cloud type or the Cloud Distance changes. Each frame the shader moves it by the offset into the cell. The clouds look the same: compared frame by frame from below, inside and above the layer and while flying through it, frames are identical or differ in at most 3 pixels by 1/255, with no popping. Same setup as yours (`horizon-ctl bench 6`, fresh creative world seed 1234, standing still, render distance 12, 1280x720, VSync off, unlimited FPS), measured on a Mac mini M4 Pro (Metal, offscreen), average of two runs each: **Before (origin/main)** | Clouds | Cloud Distance | avg FPS | CPU ms/frame | prepare ms | render ms | | --- | ---: | ---: | ---: | ---: | ---: | | Fancy | 128 | 466 | 2.13 | 1.10 | 0.91 | | Fast | 128 | 493 | 2.01 | 0.78 | 1.13 | | Fancy | 64 | 1,375 | 0.72 | 0.32 | 0.35 | | Fast | 64 | 1,456 | 0.68 | 0.23 | 0.41 | | Fancy | 32 | 2,361 | 0.40 | 0.14 | 0.23 | | Fast | 32 | 2,286 | 0.40 | 0.11 | 0.26 | | Off | - | 2,456 | 0.29 | 0.07 | 0.18 | **After (this PR)** | Clouds | Cloud Distance | avg FPS | CPU ms/frame | prepare ms | render ms | | --- | ---: | ---: | ---: | ---: | ---: | | Fancy | 128 | 1,588 | 0.34 | 0.09 | 0.20 | | Fast | 128 | 1,577 | 0.31 | 0.08 | 0.19 | | Fancy | 64 | 1,812 | 0.29 | 0.07 | 0.18 | | Fast | 64 | 2,328 | 0.26 | 0.07 | 0.17 | | Fancy | 32 | 2,441 | 0.26 | 0.07 | 0.17 | | Fast | 32 | 2,440 | 0.27 | 0.07 | 0.17 | | Off | - | 2,476 | 0.27 | 0.07 | 0.16 | With clouds on, CPU time is now within ~0.07 ms of clouds off at every Cloud Distance. What's left at 128 is GPU time to draw the clouds. A run on your Windows/Vulkan machine once it's merged would be very welcome.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
horizon-rust/horizon#135
No description provided.