Repository navigation
Undo of an erase: each restored object's draw depth is found at its handle's place, not by walking the order - #3469
Merged
HakanSeven12 merged 2 commits intoNov 23, 2026
Conversation
Undoing an erase gives each entity back the label its block's order kept for it, and the entry was looked for by walking the order from its start. These tests ask for an entity the sort table left alone to be found at the place of its own handle, for one the table moved to be found all the same, and for an erase and its undo to leave every draw depth as it was. The lookup now goes through two functions, of which the first still finds nothing: the first test fails. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Undoing an erase of 100,000 objects spent two seconds giving them their draw depths back, where assigning the depths of twice as many from scratch takes 25 ms. Each restored entity's label is kept in its block's order, and the order was walked from its start for every one. The order is sorted by effective key, then by handle, and an entity's key is its own handle unless the block's sort table files it under another. The entry is now looked for by a binary search at the place of the handle; only an entity the sort table moved is still searched for through the order. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
How it shows up
Refs #3231 ("lag ... at times more than a few seconds" when working on groups in large files). There is no file there, so this is a synthetic drawing of 100,800 objects (14,400 cells of five lines, a circle and a text). Select the 100,440 in view, ERASE, then Undo: the objects take 3 seconds to come back. Two seconds of that are one line of the
PERFlog:Assigning the draw depths of twice as many objects from scratch takes 25 ms (
[perf] draw-depth 25.3ms entries=201240, after a COPY of the same selection).Cause
Scene::draw_depth_mapkeeps each block's draw order as a list of entries with stable labels, and an erased entity's entry stays in it so that Undo gives it the same label back. To restore one, the list was searched from its start:That is one walk through the block's order for every restored entity: 100,440 walks through 100,800 entries.
The change (
src/scene/mod.rs)The list is sorted by effective key, then by handle, and an entity's key is its own handle unless the block's sort table files it under another (DRAWORDER). So:
draw_depth_entry_at_own_keylooks for the entry by a binary search for the handle as both key and handle;draw_depth_entryfalls back to the walk for an entity the sort table moved, whose entry is elsewhere in the list.The entry found is the same one as before in every case, so the depths do not change.
Measured
Release builds, Windows 11, RTX 3070, Direct3D 12,
PERF=1.mainis 0ca0345 with the lock file of #3459 so that it builds. "Frame" isnav-prepare elapsed, from the command to the prepared frame. One run of each build; a second and a third run ofmaingave 3,019 and 3,023 ms for the first row.maindraw-depth-patchdraw-depth-patchdraw-depth-patchdraw-depth-patchThe redo walks further because the order then holds 201,240 entries.
The same view captured after each step of a sequence in both builds (MOVE of everything, its undo, ERASE of everything, its undo, MOVE of scattered objects, its undo: 11 captures). The drawing area is the same pixel for pixel in ten of them; in the one after the MOVE, which this change does not touch, two pixels are one level of 255 apart.
mainTests (
src/scene/journal_tests.rs)a_draw_depth_entry_is_found_at_the_place_of_its_own_handle: every entry of a seeded order of 5,000 is found bydraw_depth_entry_at_own_key, and a handle the order does not hold gets none. Fails on the first commit, where that function still finds nothing and the walk does the work.a_draw_depth_entry_the_sort_table_moved_is_still_found: two entries filed under another key are not at their handle's place, anddraw_depth_entryfinds them and every other one.undoing_an_erase_gives_every_entity_its_draw_depth_back: 300 lines, all but each seventh erased and restored; the depth map is the one from before the erase, with no relabelling.cargo test --workspace --no-fail-fast, with the lock file of Cargo.lock: gpu-allocator is back on thewindowscrate wgpu-hal uses, somainbuilds on Windows #3459: 7,758 passed, 1 failed, 49 ignored.app::control::spellcheck::tests::speller_survives_com_unload_reload_cyclesfails the same way onmainon this machine.cargo check --target wasm32-unknown-unknown --libpasses.Limits
maindoes until Cargo.lock: gpu-allocator is back on thewindowscrate wgpu-hal uses, somainbuilds on Windows #3459 is in.OCS
mainat 0ca0345, Windows 11.🤖 Generated with Claude Code