Skip to content

Mark extracted scenes changed only when what they publish changes - #3203

Closed
RestartFU wants to merge 1 commit into
perf/chunk-textures-change-only-when-replacedfrom
perf/atmosphere-publish-only-changes
Closed

RestartFU wants to merge 1 commit into
perf/chunk-textures-change-only-when-replacedfrom
perf/atmosphere-publish-only-changes

Conversation

@RestartFU

@RestartFU RestartFU commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Saving: 0.9 µs per frame for this PR and #3201 together (paired frame time, median of 32 pairs, IQR 0.7–1.7 µs), measured on the integration/optifine-parity head baa9e60 on the idle flat world at 960x540. Main thread CPU 181.4 → 180.4 µs per frame, render thread 180.2 → 179.2 µs, about +27 fps at 5,480 fps.

Stacked on #3201, which does the same for ChunkTextureAssets.

Every resource below is extracted to the render world with ExtractResourcePlugin, which clones it into the render world whenever it counts as changed. An extract-dirtiness measurement on the idle flat world found each one marked changed on 99–100% of frames, while nothing it publishes changed. That happens because its writer took the resource mutably every frame, through DerefMut or an unconditional assignment. Each writer now marks the resource only when what the renderer reads from it differs.

Plain values use set_if_neq:

  • CloudVisibility, CloudDistanceChunks, SkyboxSettings, AtmosphereViewInputs, WorldLighting (atmosphere publisher)
  • UiGlintSettings, ChunkUploadBudget, ChunkArenaCapacityHint

Structured scenes compare what they publish:

  • VisibilityDiagnosticsInput: loading writes only the startup-probe flag, so the caller marks the input when that flag flips.
  • ModRenderScene: the no-runtime packet path reports whether its overlay buffers or personal output changed.
  • DrawingFrame: rebuilt into a reused scratch frame and swapped in only when it differs.
  • EntityShadowScene: marked when the caster list's revision moves.
  • ViewmodelScene: marked when the published token or bound fallback changes.
  • PanoramaScene: compares faces allocation and revision, view and visibility. The shared upload marker is the renderer's acknowledgement, so it is excluded.
  • DroppedItemScene: lists compare by allocation. The glint scroll is compared only while something is drawn. publish_terrain_instances no longer allocates a new empty list every frame.
  • ScreenOverlayScene: the renderer returns before reading the clock, fire projection and portal transform when no layer is drawn, so those are compared only while one is.
  • PrimitiveShapesScene: the renderer uploads only the clock rounded down to the hour. That rounding is now one scene method used by both sides, and the scene is marked when the hour, dimension, render distance or store handle changes.

Render-side readers of these resources read their values every frame rather than reacting to the change flag. None of them mutates its extracted copy.

Not changed, because they do change every frame: AtmosphereFrame, ActorRenderFrame, Time, FrameCount and the animation clocks.

Tests. System-level tests run a writer for several frames and assert that its resource counts as changed only on insertion or a real change; they fail without this change. The scene-level tests check that each comparison keeps an unchanged publication equal and still catches a real change.

  • environment::time_override::tests::unchanged_inputs_leave_extracted_outputs_unchanged
  • modding::anchors::tests::unchanged_availability_leaves_the_drawing_frame_unchanged
  • ui_runtime::presentation::forms::panorama::tests::steady_in_world_frames_leave_the_scene_unchanged
  • camera::overlay_publish::tests::steady_frames_without_layers_leave_the_scene_unchanged
  • publication::pressure_tests::the_budget_counts_as_changed_only_when_its_value_changes

Scene-level:

  • tests for dropped items, panorama, primitive shapes, screen overlays and the viewmodel, plus repeat-publish assertions for entity shadows and packet drawing.

How to see it: nothing visible changes.

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

Seventeen extracted resources were marked changed on every idle frame without their published
content changing, so extraction cloned each into the render world again every frame. Each
writer now compares before marking: plain values use set_if_neq, and the structured scenes
(viewmodel, panorama, dropped items, screen overlays, primitive shapes, entity shadows, mod
render scene, drawing frame) compare what the renderer reads from them.

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

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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: 9df02085-50e0-4c08-8ce7-0cbc4b860a0a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

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