perf(gpu): look up root views in O(log n) and gate pending table remirrors #242
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!242
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-242"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Sheffy007 on GitHub · 2026-11-27 03:49 UTC · original
Sheffy007:perf/native-host-pool-lookup-and-remirror→main· +157 −10 · 6 files · 2 commits · merged 2026-11-27 03:57 UTCSummary
Reduces CPU time spent holding the native host
TITLElock duringExecuteCommandLists(NativeHost::execute), addressing two world-frame submission bottlenecks reported on #15 and #179:O(log n)pool lookup inNativeHost::root_view:PoolTable::generation(). Callingself.mapping_list()insideroot_viewrebuilt the entire ~96k-entry mapping snapshot (~1/3 of submit-thread CPU samples in #15) just to resolve a single address.PoolTable::mapping_at(BTreeMap::range(..=addr).next_back(), zero heap allocation) and feeds it directly toaddr::mapped_root_view.NativeHost::remirror_tables(NativeHeap::pending_mirror):73793f4, unmapped buffer descriptors and unrealized/undecodable table entries were left out ofNativeHeap::mirrored, causing every subsequent draw/dispatch to re-decode them and re-encodenull_viewinto the Metal heap even when nothing had changed.(record, pool_generation, resources_epoch)inNativeHeap::pending_mirrorso unchanged entries are skipped until the descriptor record,PoolTable::generation(), or registered resources (resources_epoch) actually advance.Tests
native::memory::tests::mapping_at_finds_single_address_without_snapshotnative::host::tests::root_view_looks_up_pool_table_without_rebuilding_mapping_listnative::tests::submission_retries_an_unchanged_buffer_descriptor_after_mapping(verifiesbuffer_writesis not repeated before mapping and retries once mapped)native::tests::submission_retries_an_unrealized_resource_descriptor_once_registeredcargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings(and--all-features) andcargo xtask policypass.@LakshanSivakumar on GitHub · 2026-11-27 03:57 UTC · original · approved these changes
Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). The ordered lookup matches the old scan, since mappings never overlap. I pushed one small fix to the remirror gate:
mirror()readmemory.generation()andresources_epochafterresolvehad failed. The pool table is written from title threads, so a pool mapped between the failed resolve and that read would record the entry as failed at the new generation, and it would stay null until some later change. Both values are now taken beforeresolve. Thanks!