Skip to content

Skip UI render preparation an unchanged frame repeats - #3192

Closed
RestartFU wants to merge 1 commit into
devfrom
perf/ui-render-static
Closed

RestartFU wants to merge 1 commit into
devfrom
perf/ui-render-static

Conversation

@RestartFU

@RestartFU RestartFU commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

On a static HUD the published UI frame does not change, but the render thread redid work every frame that only the published frame or the views can change. This removes three such pieces. In the flat-world idle benchmark the UI render systems drop from about 8.3–9.5 µs to about 6.0–6.4 µs per frame.

What changes

  • Texture residency: preparing UI resources confirmed that the published catalog was resident by deep-comparing the whole texture allocation plan and location table, up to twice a frame. The texture store now remembers the catalog it last found resident, held weakly so a later catalog never reuses its address, together with an epoch that every residency change advances (prepare, failed font uploads, or replacing the store). While both match, it answers without comparing.
  • Pipeline queueing: queueing re-specialized every UI pipeline variant, scanned the batches several times and pruned four pipeline maps each frame. It now does nothing while the batches, buffers and each view's pipeline inputs (camera HDR, MSAA, output format, depth attachment, layer texture) match the last queue, as long as that queue found every pipeline. A missing pipeline, which may still be compiling, or a new device makes the next frame queue again. Hand coverage is still cleared every frame.
  • Layer preparation: preparing layers re-planned the screen passes to count their rasters and built a hash map of output writers each frame. The count is now planned once per batch list, and writers are counted without allocating.

Drawing and presenting are unchanged: the overlay still composites the retained UI layer and draws the crosshair over each frame's scene.

Measurements

Flat-world idle benchmark at 960×540 on CCD0. Each round ran dev and this branch back to back, one client each, under the shared benchmark lock, in alternating order. Both builds carry the same temporary per-system timing probe on the render thread (not part of this PR). "UI systems" is the sum of the UI render systems the probe times; "render thread" is that thread's CPU time per frame.

Round UI systems, dev (µs/frame) UI systems, this (µs/frame) Render thread, dev (µs/frame) Render thread, this (µs/frame) Host load (dev / this)
0 8.26 5.95 263.2 260.3 2.4 / 2.1
1 9.46 6.31 283.0 272.7 4.2 / 3.8
2 9.31 6.21 327.0 273.1 7.3 / 11.5
3 8.50 6.26 270.3 266.8 11.7 / 10.7
4 8.46 6.43 265.4 278.3 7.2 / 13.3

Per system, in the same rounds:

  • prepare_ui_resources: from 1.7–2.1 µs to about 0.6–0.7 µs.
  • queue_ui_overlay: from about 1.0 µs to about 0.25 µs.
  • prepare_ui_layers: from about 1.0 µs to about 0.5 µs.

Rounds 2 and 4 had uneven host load between the arms, which dominates their render-thread difference; the UI systems drop by 2.0 to 3.1 µs in every round.

Tests

  • shared_residency_follows_uploads_and_catalog_replacement checks that the remembered residency answers exactly as the full comparison does through a failed upload, a retry and a replaced catalog.
  • The render crate's UI tests pass.

How to see it

Nothing should look different.

Co-Authored-By: Dylan T. 14214667+dktapps@users.noreply.github.com

On a static HUD the render thread redid work every frame that only the
published frame or the views can change:

- Preparing UI resources deep-compared the whole texture allocation plan
  and location table to confirm the catalog was resident, up to twice a
  frame. The texture store now remembers the catalog it last found
  resident with an epoch that every residency change advances, and
  answers from that while both match.
- Queueing re-specialized every UI pipeline variant and pruned its
  pipeline maps. It now repeats nothing while the batches, buffers and
  each view's pipeline inputs match the last queue, provided that queue
  found every pipeline; a new device or a missing pipeline queues again.
- Preparing layers re-planned the screen passes to count their rasters
  and built a map of output writers. The count is planned once per batch
  list, and writers are counted without allocating.

Co-Authored-By: Dylan T. <14214667+dktapps@users.noreply.github.com>
@RestartFU RestartFU added the performance Faster or lighter, same behaviour label Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 60e08fca-3fc0-4764-9519-58c1546bef5a
Commits

Reviewing files that changed from the base of the PR and between bd7fe41 and 7ce15f2.

Files selected for processing: 6

  • crates/render/src/ui_render/composite.rs
  • crates/render/src/ui_render/model_depth.rs
  • crates/render/src/ui_render/overlay.rs
  • crates/render/src/ui_render/resources.rs
  • crates/render/src/ui_render/textures.rs
  • crates/render/src/ui_render/textures_tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

RestartFU added a commit that referenced this pull request Nov 26, 2026
RestartFU added a commit that referenced this pull request Nov 26, 2026
Test branch combining every open OptiFine-parity performance PR at its current
head, reviewed or not; not for merging into dev. Base: dev ce130a4, now also dev bd7fe41 (carried in by
#3181 and #3182).

Cinnabar PR heads (merge commits; later merges refresh earlier ones):
- #3137 ad46fe9 #3138 aae7e71 #3139 2be1fa4 #3140 ccd0826
- #3141 01e0678 #3143 96561fd #3145 89ec8ea #3146 ee0c1cc
- #3150 74aa97a (contains #3148 d349dfe, #3149 acedbdc)
- #3151 501c1cd #3152 ee428ff #3153 7a31ccb #3155 18df597
- #3156 ef06a4a #3164 ac33bde #3169 d9afd19 #3171 342339d
- #3170 bc9c2fd, first merged at e200c56 (contains #3167 5579f31, #3166 70410fe, #3163 7166a0c,
  #3162 b9f8bc7)
- UI stack, merged layer by layer: #3147 2fb64e8, #3154 38d272a,
  #3159 2a5de0f, #3160 94f5e10, #3161 eb70e81, #3168 e9d648c,
  #3174 e8767a3 (on #3168; merged by 9ade819)
- #3178 0d0c0a9 Trim idle per-frame work in map requests, portal contact and
  scene stacks (merged by 75c6453; equipment.rs export list unioned)
- #3179 35cd071 Skip raw-input readers on frames without raw input (merged by
  eb8e28a)
- #3180 9f608c5 Skip idle screen input drivers once their state has settled
- #3181 d70cd43 Trim per-frame item checks
- #3182 f73298c Skip the spawner display pass while no spawner is in reach
  (merged by 78ebaff)
- #3183 70e81f0 Skip the shield and trim observation of quiet repeated
  dressings, on #3174 (merged by ffe7244)
- #3184 bdac654 Poll the render device in the frame tail after handing the
  render app back (on #3143; its own Bevy pin dropped for the integration pin)
- #3185 49e57c3 Skip the weather, lightning, media screen and entity shadow
  systems while they have nothing to do (merged by a8159c2)
- #3186 f0cb7db Skip the particle systems while no particle is drawn,
  pending or settling
- #3187 23fda87 Skip the mod rendering systems while no mod content is drawn
  or releasing (merged by a87763b)
- #3188 3a45677 Read the cached adapter info in the per-frame chunk queues
- #3189 551b1b8 Pace the launcher service pass during play behind a hidden
  menu (merged by 56c42af)
- #3190 7eaaf9d Keep an equal empty actor frame unpublished (first merged
  at 1f717d9)
- #3191 6dcaa19 Extract and upload only marked chunk instances
- #3193 b47b917 Share the cached local equipment input instead of cloning it
- #3192 7ce15f2 Skip UI render preparation an unchanged frame repeats
- #3172 db432c8 Check the launcher core for an exit before a Realm
  membership reply advances the dialog (follow-up stacked on #3156)
- #3173 40a5350 Point the guard revision's documentation at stable_window
  (follow-up stacked on #3169; this commit)
Conflict resolved: #3155 and #3171 each add a SceneTarget field; both kept.
Integration fix a4dfa72 (also on #3143 as 96561fd).
Not taken: bevy#25 and winit#1/#2 (no measured gain); pin-only #3142 and #3144 and the fork pins inside #3139/#3143;
#3175 and #3176, which rewrite #3143's and #3145's code differently (to be
restacked on them; they duplicate #3143 and #3145).
Debug build loads and renders the flat world without a panic.

Bevy: cinnabar-mc/bevy integration/optifine-parity 0a834ddbc (pinned by
4869e5c), from
cinnabar-v0.20 5f0dc3907 with merges of bevy#8 5acd7a24da, #11 2693622c90,
#9 4dd7d481d4, #10 6b0ac4e581, #7 1f3e7f4d35, #13 2ce6ba5649, #14 ad6ea05088,
#12 7091d7d5a9 (first merged at 1540ab28d4), #15 b64ea92769, #16 404d96719a,
#17 08fa75746a, #19 ff0fc85d6a, #20 16800e704c, #21 6a907e2dd2 (its first head
676a16dba9 panicked at startup and was reverted, then reapplied with the fix),
#23 5c8d693808 (contains #22 7ee9ce4b60), #26 e975d10437, #24 2c5cdbb70c
(the measured head, itself a merge of bevy#22; imports conflict with #23
resolved by taking #24's superset). bevy#18 is closed.

winit: dev's pin, cinnabar-mc/winit b1e59b0d5a. winit#1 f167f7d61a was pinned
from edff0fa and dropped again in b2824e4 (no measured gain).

wgpu: cinnabar-mc/wgpu integration/optifine-parity 5fde9ac98, from
cinnabar-v30 a775a0719 with merges of wgpu#28 9a5fd37a40, wgpu#26 b3212eb220.

Bevy pin cfc5793. Earlier measurement arms: 0ac8bb9, 9ff5af1, 7704dd9,
574bab2, 0c1a48d, cfc5793, eb8e28a, dbdd6e5, edff0fa (panics; bevy#21), 5596f00, 78ebaff, ffe7244, a8159c2, a87763b, 56c42af, 4869e5c, 9753579, 0ba2428. The fork-pin reachability checks fail by design.

Co-Authored-By: Dylan T. <14214667+dktapps@users.noreply.github.com>
RestartFU added a commit that referenced this pull request Nov 26, 2026
Test branch combining every open OptiFine-parity performance PR at its current
head, reviewed or not; not for merging into dev. Base: dev ce130a4, then bd7fe41 (carried in by #3181
and #3182), now dev 8ae394f (carried in by #3200).

Cinnabar PR heads (merge commits; later merges refresh earlier ones):
- #3137 ad46fe9 #3138 aae7e71 #3139 2be1fa4 #3140 ccd0826
- #3141 01e0678 #3143 96561fd #3145 89ec8ea #3146 ee0c1cc
- #3150 74aa97a (contains #3148 d349dfe, #3149 acedbdc)
- #3151 501c1cd #3152 ee428ff #3153 7a31ccb #3155 18df597
- #3156 ef06a4a #3164 ac33bde #3169 d9afd19 #3171 342339d
- #3170 bc9c2fd, first merged at e200c56 (contains #3167 5579f31, #3166 70410fe, #3163 7166a0c,
  #3162 b9f8bc7)
- UI stack, merged layer by layer: #3147 2fb64e8, #3154 38d272a,
  #3159 2a5de0f, #3160 94f5e10, #3161 eb70e81, #3168 e9d648c,
  #3174 e8767a3 (on #3168; merged by 9ade819)
- #3178 0d0c0a9 Trim idle per-frame work in map requests, portal contact and
  scene stacks (merged by 75c6453; equipment.rs export list unioned)
- #3179 35cd071 Skip raw-input readers on frames without raw input (merged by
  eb8e28a)
- #3180 9f608c5 Skip idle screen input drivers once their state has settled
- #3181 d70cd43 Trim per-frame item checks
- #3182 f73298c Skip the spawner display pass while no spawner is in reach
  (merged by 78ebaff)
- #3183 70e81f0 Skip the shield and trim observation of quiet repeated
  dressings, on #3174 (merged by ffe7244)
- #3184 bdac654 Poll the render device in the frame tail after handing the
  render app back (on #3143; its own Bevy pin dropped for the integration pin)
- #3185 49e57c3 Skip the weather, lightning, media screen and entity shadow
  systems while they have nothing to do (merged by a8159c2)
- #3186 f0cb7db Skip the particle systems while no particle is drawn,
  pending or settling
- #3187 23fda87 Skip the mod rendering systems while no mod content is drawn
  or releasing (merged by a87763b)
- #3188 3a45677 Read the cached adapter info in the per-frame chunk queues
- #3189 551b1b8 Pace the launcher service pass during play behind a hidden
  menu (merged by 56c42af)
- #3190 7eaaf9d Keep an equal empty actor frame unpublished (first merged
  at 1f717d9)
- #3191 6dcaa19 Extract and upload only marked chunk instances
- #3193 b47b917 Share the cached local equipment input instead of cloning it
- #3192 7ce15f2 Skip UI render preparation an unchanged frame repeats
- #3172 db432c8 Check the launcher core for an exit before a Realm
  membership reply advances the dialog (follow-up stacked on #3156)
- #3173 40a5350 Point the guard revision's documentation at stable_window
  (follow-up stacked on #3169)
- #3200 c653d90 Read the stage trace's thread id once per thread (this
  commit)
Conflict resolved: #3155 and #3171 each add a SceneTarget field; both kept.
Integration fix a4dfa72 (also on #3143 as 96561fd).
Not taken: bevy#25 and winit#1/#2 (no measured gain); pin-only #3142 and #3144 and the fork pins inside #3139/#3143;
#3175 and #3176, which rewrite #3143's and #3145's code differently (to be
restacked on them; they duplicate #3143 and #3145).
Debug build loads and renders the flat world without a panic.

Bevy: cinnabar-mc/bevy integration/optifine-parity 0a834ddbc (pinned by
4869e5c), from
cinnabar-v0.20 5f0dc3907 with merges of bevy#8 5acd7a24da, #11 2693622c90,
#9 4dd7d481d4, #10 6b0ac4e581, #7 1f3e7f4d35, #13 2ce6ba5649, #14 ad6ea05088,
#12 7091d7d5a9 (first merged at 1540ab28d4), #15 b64ea92769, #16 404d96719a,
#17 08fa75746a, #19 ff0fc85d6a, #20 16800e704c, #21 6a907e2dd2 (its first head
676a16dba9 panicked at startup and was reverted, then reapplied with the fix),
#23 5c8d693808 (contains #22 7ee9ce4b60), #26 e975d10437, #24 2c5cdbb70c
(the measured head, itself a merge of bevy#22; imports conflict with #23
resolved by taking #24's superset). bevy#18 is closed.

winit: dev's pin, cinnabar-mc/winit b1e59b0d5a. winit#1 f167f7d61a was pinned
from edff0fa and dropped again in b2824e4 (no measured gain).

wgpu: cinnabar-mc/wgpu integration/optifine-parity 5fde9ac98, from
cinnabar-v30 a775a0719 with merges of wgpu#28 9a5fd37a40, wgpu#26 b3212eb220.

Bevy pin cfc5793. Earlier measurement arms: 0ac8bb9, 9ff5af1, 7704dd9,
574bab2, 0c1a48d, cfc5793, eb8e28a, dbdd6e5, edff0fa (panics; bevy#21), 5596f00, 78ebaff, ffe7244, a8159c2, a87763b, 56c42af, 4869e5c, 9753579, 0ba2428, 19c77db. The fork-pin reachability checks fail by design.

Co-Authored-By: Dylan T. <14214667+dktapps@users.noreply.github.com>
RestartFU added a commit that referenced this pull request Nov 26, 2026
Test branch combining every open OptiFine-parity performance PR at its current
head, reviewed or not; not for merging into dev. Base: dev ce130a4, then bd7fe41 (carried in by #3181
and #3182), now dev 8ae394f (carried in by #3200).

Cinnabar PR heads (merge commits; later merges refresh earlier ones):
- #3137 ad46fe9 #3138 aae7e71 #3139 2be1fa4 #3140 ccd0826
- #3141 01e0678 #3143 96561fd #3145 89ec8ea #3146 ee0c1cc
- #3150 74aa97a (contains #3148 d349dfe, #3149 acedbdc)
- #3151 501c1cd #3152 ee428ff #3153 7a31ccb #3155 18df597
- #3156 ef06a4a #3164 ac33bde #3169 d9afd19 #3171 342339d
- #3170 bc9c2fd, first merged at e200c56 (contains #3167 5579f31, #3166 70410fe, #3163 7166a0c,
  #3162 b9f8bc7)
- UI stack, merged layer by layer: #3147 2fb64e8, #3154 38d272a,
  #3159 2a5de0f, #3160 94f5e10, #3161 eb70e81, #3168 e9d648c,
  #3174 e8767a3 (on #3168; merged by 9ade819)
- #3178 0d0c0a9 Trim idle per-frame work in map requests, portal contact and
  scene stacks (merged by 75c6453; equipment.rs export list unioned)
- #3179 35cd071 Skip raw-input readers on frames without raw input (merged by
  eb8e28a)
- #3180 9f608c5 Skip idle screen input drivers once their state has settled
- #3181 d70cd43 Trim per-frame item checks
- #3182 f73298c Skip the spawner display pass while no spawner is in reach
  (merged by 78ebaff)
- #3183 70e81f0 Skip the shield and trim observation of quiet repeated
  dressings, on #3174 (merged by ffe7244)
- #3184 bdac654 Poll the render device in the frame tail after handing the
  render app back (on #3143; its own Bevy pin dropped for the integration pin)
- #3185 49e57c3 Skip the weather, lightning, media screen and entity shadow
  systems while they have nothing to do (merged by a8159c2)
- #3186 f0cb7db Skip the particle systems while no particle is drawn,
  pending or settling
- #3187 23fda87 Skip the mod rendering systems while no mod content is drawn
  or releasing (merged by a87763b)
- #3188 3a45677 Read the cached adapter info in the per-frame chunk queues
- #3189 551b1b8 Pace the launcher service pass during play behind a hidden
  menu (merged by 56c42af)
- #3190 7eaaf9d Keep an equal empty actor frame unpublished (first merged
  at 1f717d9)
- #3191 6dcaa19 Extract and upload only marked chunk instances
- #3193 b47b917 Share the cached local equipment input instead of cloning it
- #3192 7ce15f2 Skip UI render preparation an unchanged frame repeats
- #3172 db432c8 Check the launcher core for an exit before a Realm
  membership reply advances the dialog (follow-up stacked on #3156)
- #3173 40a5350 Point the guard revision's documentation at stable_window
  (follow-up stacked on #3169)
- #3200 c653d90 Read the stage trace's thread id once per thread
- #3202 04ee75f Submit the render graph in the frame tail after handing the
  render app back (on #3184; its own Bevy pin dropped for the integration pin;
  this commit)
Conflict resolved: #3155 and #3171 each add a SceneTarget field; both kept.
Integration fix a4dfa72 (also on #3143 as 96561fd).
Not taken: bevy#25 and winit#1/#2 (no measured gain); pin-only #3142 and #3144 and the fork pins inside #3139/#3143;
#3175 and #3176, which rewrite #3143's and #3145's code differently (to be
restacked on them; they duplicate #3143 and #3145).
Debug build loads and renders the flat world without a panic.

Bevy: cinnabar-mc/bevy integration/optifine-parity f12cd3db7 (pinned by the
parent of this commit), from
cinnabar-v0.20 5f0dc3907 with merges of bevy#8 5acd7a24da, #11 2693622c90,
#9 4dd7d481d4, #10 6b0ac4e581, #7 1f3e7f4d35, #13 2ce6ba5649, #14 ad6ea05088,
#12 7091d7d5a9 (first merged at 1540ab28d4), #15 b64ea92769, #16 404d96719a,
#17 08fa75746a, #19 ff0fc85d6a, #20 16800e704c, #21 6a907e2dd2 (its first head
676a16dba9 panicked at startup and was reverted, then reapplied with the fix),
#23 5c8d693808 (contains #22 7ee9ce4b60), #26 e975d10437, #24 2c5cdbb70c
(the measured head, itself a merge of bevy#22; imports conflict with #23
resolved by taking #24's superset), #27 2c2fe0e3d3 (on bevy#22 and #9).
bevy#18 is closed.

winit: dev's pin, cinnabar-mc/winit b1e59b0d5a. winit#1 f167f7d61a was pinned
from edff0fa and dropped again in b2824e4 (no measured gain).

wgpu: cinnabar-mc/wgpu integration/optifine-parity 5fde9ac98, from
cinnabar-v30 a775a0719 with merges of wgpu#28 9a5fd37a40, wgpu#26 b3212eb220.

Bevy pin cfc5793. Earlier measurement arms: 0ac8bb9, 9ff5af1, 7704dd9,
574bab2, 0c1a48d, cfc5793, eb8e28a, dbdd6e5, edff0fa (panics; bevy#21), 5596f00, 78ebaff, ffe7244, a8159c2, a87763b, 56c42af, 4869e5c, 9753579, 0ba2428, 19c77db, 2e60a50. The fork-pin reachability checks fail by design.

Co-Authored-By: Dylan T. <14214667+dktapps@users.noreply.github.com>
@RestartFU RestartFU closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Faster or lighter, same behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant