Description
Reproduced on: SolidCraft 0.24.0, built from source at 3ad5a360 (main), release profile, Linux x86_64, Vulkan.
Design: an imported STEP assembly with about 400 bodies spread across many nested sub-assemblies, with the top-level occurrence active. Timings were taken with SOLIDCRAFT_PROFILE_FRAMES=1 plus temporary frame timers. Stack traces were sampled with gdb.
Steps
- Open a large STEP assembly whose parts sit several levels deep in nested sub-assemblies, and wait for loading to finish.
- Keep the Browser shown, with Select bodies on.
- Click a body near the top of the tree. It selects at once.
- Click a body several levels deep.
Expected
A deeply nested body selects as quickly as one near the top, within a frame or two.
Actual
The window freezes for about 4.4 s, every time such a body is clicked:
| Body clicked | Pick | Browser | Highlight build | GPU upload | Total |
|---|---|---|---|---|---|
| Near the top of the tree | 1–44 ms | 1–3 ms | 10–31 ms | ~13 ms | < 0.1 s |
| Several levels deep | 1–7 ms | 1,360–1,520 ms | 2,865–2,900 ms | small | ~4.4 s |
The pick, the GPU upload and the drawing are cheap, and the world state is not placed again (its cache does not miss). The time goes into listing the bodies under occurrences.
Where the time goes
Session::occurrence_bodies costs (subtree size) × (design size)
occurrence_bodies(path, true) → expand_occurrence_bodies calls occurrence_placement once for every occurrence in the subtree (crates/engine/src/occurrences.rs:195–252). Each call does work proportional to the whole design:
- it builds a new
WorldNames(hash maps over every occurrence and every body), then frees it (crates/doc/src/assembly.rs:439,occurrences.rs:173, 191); - it filters every model body to find the component's own (
model_body_component(b) == component); - it walks the path with linear
finds overdoc.occurrences.
Every stack sample taken during the stall was inside this expansion: either building WorldNames (WorldNames::new) or freeing it at the end of occurrence_placement.
Browser reveal: about 1.5 s (confirmed by stack samples)
After a viewport pick, reveal_pick sets tree.reveal. While drawing, each component row then calls reveals_in_occurrence (crates/ui-egui/src/browser.rs:656). That function runs occurrence_bodies(path, true) on the row's whole subtree, just to test whether the picked body is in it:
WorldNames::new crates/doc/src/assembly.rs:439
occurrence_placement crates/engine/src/occurrences.rs:173
occurrence_children crates/engine/src/occurrences.rs:205
expand_occurrence_bodies crates/engine/src/occurrences.rs:252
occurrence_bodies_shared crates/engine/src/occurrences.rs:224
occurrence_bodies crates/engine/src/occurrences.rs:210
reveals_in_occurrence crates/ui-egui/src/browser.rs:656
occurrence_rows_inner crates/ui-egui/src/browser.rs:1325
occurrence_rows / component_rows crates/ui-egui/src/browser.rs:1311, 1284, 1175
The deeper the body, the more rows get asked, and each row's question costs a subtree expansion.
Highlight build: about 2.9 s (indicated by timers; not stack-sampled)
All of this time falls in the first section of build_highlight (crates/ui-egui/src/viewport.rs:3180–3201). The only costly call there is occurrence_bodies(active_occurrence_path, true) (viewport.rs:3192). With the top-level occurrence active, that lists the whole assembly.
The answer is cached in occurrence_bodies_shared, but the cache holds at most OCCURRENCE_BODIES_CACHED = 256 paths and is cleared entirely once full (occurrences.rs:46, 226). The reveal's row-by-row queries most likely fill it, which evicts the active occurrence's entry, so the next highlight build expands the whole assembly again.
The same active-occurrence query also runs during picking (crates/ui-egui/src/view_pick.rs:131) and scene building (viewport.rs:1192, 4910). The context menu, select.set and Browser hover call occurrence_bodies too.
Fix suggestions
These are suggestions only; they are independent, and maintainers may prefer other approaches.
- Name every placed body once per design and evaluated model. Build a placement index in one walk: each occurrence path's component and bodies' world names, and each parent's children. Do it the way
Document::body_frames_with_sourceand the world-state build already do, with oneWorldNamesand bodies grouped by component once.occurrence_placementandexpand_occurrence_bodieswould then look things up instead of rebuilding them, so a listing costs the subtree's size, not subtree × design. Names depend on neither pending moves nor the active component, so the index could be keyed on the document and model alone. Keeping today's walk as a fallback aboveMAX_PLACEMENTSwould keep the current limits and errors. - Open the Browser from the picked body's path instead of asking every row. Find the revealed body's occurrence path once (
browser_model::Model::body_pathalready does this for Find in Browser), then open a row when that path starts with the row's own. No engine query per row, and the reveal no longer fills the shared cache. - Evict single entries from
OccurrenceBodiesCacheinstead of clearing it. Once the first suggestion is in, a cleared cache costs little. Without it, keeping the active occurrence's entry would avoid the full re-expansion seen here.
Related work
- The open viewport and render PRs (Viewport: hold the blocks the sorted glass stream was taken from #6970, Viewport: write hover edges as one record per line, colours interned once #7416, Viewport: leave bodies out of the view out of their blocks' draws #7436, Render preview: extract the product scene only when what it shows changes #7465, Render preview: editing an appearance no longer rebuilds every vertex #7468, Render preview: PBR materials in the palette #7474) change scene building, uploads and culling. None of them touches
occurrence_bodies,WorldNamesor the Browser reveal, so they don't address this stall. - The merged Assembly: name placed bodies without rescanning the design #7380 made
WorldNamesthe way to name many placed bodies at once, for the world-state build. The paths above still build oneWorldNamesper occurrence. - Open PRs touch nearby code:
- Align: add Components mode for occurrence placement (#7223) #7224 calls
occurrence_placement; - Selection: a Selection mode on the navigation bar chooses what a click on the model picks (#4255) #6326 builds on
browser_model::Model::body_path; - Reuse placement-independent model results (#6525) #6527 keeps the evaluated model's
Arcacross placement-only changes.
- Align: add Components mode for occurrence placement (#7223) #7224 calls
STEP File Used for Testing
https://github.com/bigtreetech/BIGTREETECH-Kraken/blob/master/3D/BIGTREETECH%20Kraken%20V1.0.zip
Activity
dahakbuilds commentedon Oct 27, 2026
Triage by Dahak (agent): confirmed in source at
38dedcca(upstream/main, checked 2026-10-27); the stall itself is GUI-interaction so it was not re-clicked here, but every mechanism in the report checks out against current main (line numbers shifted slightly since3ad5a360):Session::occurrence_placement(crates/engine/src/occurrences.rs:143) builds a freshWorldNames::new(&self.doc, &state)on every call (occurrences.rs:173).WorldNames::new(crates/doc/src/assembly.rs:433) is O(design): hash maps over every occurrence plus a set over every model body. It also filters every model body per call and does linearfinds overdoc.occurrencesper path element.expand_occurrence_bodies(occurrences.rs:241) pops every occurrence in the subtree and callsoccurrence_children→occurrence_placementper child, so a descendant listing costs (subtree size) × (design size), as reported.reveals_in_occurrenceis now atcrates/ui-egui/src/browser.rs:730and still runsoccurrence_bodies(path, true)on each row's subtree to test containment.build_highlight(crates/ui-egui/src/viewport.rs:3179) callsoccurrence_bodies(active_occurrence_path, true)atviewport.rs:3191; the same query also runs inview_pick.rs:131and scene building (viewport.rs:1192,viewport.rs:4899).OCCURRENCE_BODIES_CACHED = 256(occurrences.rs:46); once full,occurrence_bodies_sharedreplaces the whole cache with a fresh empty one (occurrences.rs:226) rather than evicting single entries, so the row-by-row reveal queries evict the active occurrence's entry and the next highlight re-expands the whole assembly.Not a kernel-paused area (engine/UI performance), so this is fixable independently of the kernel pause. The report's own timings (Browser reveal ~1.5 s, highlight build ~2.9 s on a ~400-body STEP assembly) were taken by the reporter on
3ad5a360with frame timers and gdb samples.github-actions commentedon Oct 27, 2026
Claimed by @dahakbuilds through #7694. The claim lapses after 14 days without pushes.
Assembly: name placed bodies from a per-design index, reveal the Brow…
Assembly: deeply nested body selection no longer stalls the window (t…
Sketch drag: drop the second document copy per frame
Sketch drag: drop the second document copy per frame (tangency-labs#1…