Skip to content

perf(runtime): look up mounted nodes in a dense table bounded by the tree - #1069

Merged
Hona merged 2 commits into
devfrom
fp-bounded-index
Nov 21, 2026
Merged

Hona merged 2 commits into
devfrom
fp-bounded-index

Conversation

@Hona

@Hona Hona commented Nov 16, 2026

Copy link
Copy Markdown
Member

Mounted nodes are looked up in a dense table sized by the tree, not in a hash map. Rebuilding the index costs a third as much on large trees.

What changes

  • NodeIndex (runtime/node_index.rs) replaces HashMap<NodeId, usize> for node positions. Sequential live IDs go straight to a slot without hashing. Live IDs from older generations that share a slot go to an overflow map.
  • Bounded by the tree, not by history. The table is sized from the tree being placed. A virtual list can mint millions of IDs with a few dozen mounted, and neither the table nor the overflow grows with retired paths.
  • Unchanged: place and pruning rebuild the index at the same points, and exiting nodes are still appended. No commit or paint pass skips nodes.

Evidence

Rebuild, standalone release microbench Hash map Dense table
478 sequential nodes 1.96 µs 0.74 µs
4,996 sequential nodes 26.81 µs 8.67 µs
478 nodes, colliding generations 1.78 µs 0.86 µs
4,996 nodes, colliding generations 17.28 µs 9.06 µs

These are rebuild costs on one quiet blade window, not key-frame savings.

  • Existing Rune tests: Mac 3,079 passed at 15f33064. Windows full suite: see the comment below before merge.
  • App output: paired scene, mid-input snapshot and debug paint-keep soak captures, against the parent. Results go in a comment as they return.

…f the tree

place and prune still rebuild the index at the same points, and exiting nodes are still appended. Sequential live ids use direct slots; colliding live ids from different generations use an overflow map. Neither the table nor overflow scales with the number of paths a window has retired. No commit or paint pass skips nodes.
Copilot AI balanced review requested due to automatic review settings November 16, 2026 10:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

# Conflicts:
#	crates/rune/src/runtime.rs
#	crates/rune/src/runtime/commit/memo_reuse.rs
#	crates/rune/src/runtime/commit/prune.rs
@Hona

Hona commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Brought up to dev (a2701b75, resolved into TreeState, exits.rs, prepare.rs, motion/{tracks,props}.rs, virtual_list/handoff.rs, and 1-line NodeIndex::default() constructor update in flatten_tests.rs so the existing test compiles; zero tests added/deleted/skipped/weakened). Added an empty-slots guard in NodeIndex::insert.

  • Farm check -p rune --all-targets: clean (exit 0).
  • Frame-loop benchmark (interaction_cost, --profile perf built on adais, RUNE_PERF=0, 6 interleaved A/B pairs × 9 samples × 120 frames, before 4a10c707 vs after a2701b75, µs unrounded):
    Scenario Before (µs) After (µs) Delta (µs) Floor (µs)
    wheel p50 302.9 298.1 -4.8 ±4.5 (won 6/6 pairs)
    wheel mean 306.5 302.8 -3.7 ±5.7 (won 5/6 pairs)
    press p50 598.2 607.3 +9.1 ±39.9
    press mean 616.6 621.0 +4.4 ±47.7
    idle p50 59.5 60.4 +0.8 ±2.0
    idle mean 61.9 61.5 -0.4 ±3.7
    Allocations/frame identical (press 1561.6917, wheel 43.3167, idle 0.1000).

@Hona
Hona merged commit 8d81d77 into dev Nov 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants