GPU: pool title-memory dirty bitmaps, write page tables directly, and skip zero bitmap words #1865
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1865
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1865/head"
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?
@nathanbzrr on GitHub · 2026-11-24 23:46 UTC · original
nathanbzrr:gpu/memory-bitmap-pool-and-table-perf→main· +297 −47 · 1 files · 1 commits · merged 2026-11-25 21:52 UTCSummary
crates/victory-gpu/src/memory.rs): AddBITMAP_POOL(capped atBITMAP_POOL_CAP = 64),Bitmap::acquire(), andPooledBitmapRAII guard keeping each list's 256 KiB shared dirty-page bitmap owned acrossdefer_missedanddefer_afteruntilHostList::resetorDrop. On drop,PooledBitmapscans for and clears any stray non-zero words before returning the buffer to the pool (and drops overflow buffers outside the pool lock).write_table): Buildlevel1in stack memory ([0u32; LEVEL1]), shrink per-entry tracking fromOption<(usize, bool)>/Option<usize>to compactowner: Vec<u32>withNO_OWNER = u32::MAX, guardstart.checked_add(len)against overflow, and write level-1 and level-2 dwords sequentially into the mapped upload buffer (out) usingas_chunks_mut::<2>()without reading write-combined memory.has_missedto iterate set bits viatrailing_zeros()andbits &= bits - 1, and skip*mark == 0words indefer_afterwithout dirtying cache lines.table_skips_overflowing_and_out_of_range_copies,has_missed_checks_block_zero_out_of_range_unowned_and_owned, andbitmap_pool_reuses_and_zeroes_across_resets, and serialize GPU tests inmemory::testswithgpu_test_lock().Verification
cargo clippy --workspace --all-targets -- -D warnings: passed (exit 0)cargo clippy --workspace --all-targets --all-features -- -D warnings: passed (exit 0)cargo test -p victory-gpu memory --locked:11 passed; 0 failed; 0 ignored; 71 filtered outcargo test -p victory-gpu --all-features memory --locked:11 passed; 0 failed; 0 ignored; 74 filtered outVICTORY_WARP=1 cargo test -p victory-gpu memory --locked:11 passed; 0 failed; 0 ignored; 71 filtered outcargo test --workspace --locked: all workspace crates passed (victory: 1,victory-core: 11,victory-formats: 23/4 ignored,victory-game: 15,victory-gpu: 81/1 ignored,victory-hle: 97 + 2 integration,victory-loader: 22 + 3 integration,victory-pe: 7,victory-pipeline: 4,victory-shader: 209/2 ignored,xtask: 4)git diff --cached --name-only:crates/victory-gpu/src/memory.rscargo run -p xtask -- policy --staged:asset policy: 1 files ok@upipibi on GitHub · 2026-11-25 00:10 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
b58ed3c:cargo test -p victory-gpu --lockedgives 79 passed, 2 failed, 1 ignored. The two failures are the NVIDIA heap-cap onesmainalso has (descriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views, #1744), so there is nothing new on this hardware. Not run: a title.AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 07:18 UTC · original · edited 2026-11-25 20:20 UTC
Automated triage for the maintainers.
Merge candidate. The verdict is unchanged.
Since the last review (
c87e403→f9b27fd): this is a rebase onto currentmain(13f91ca). The only changes to the patch, which I checked with a range-diff:main's newLayout::bitsfield: thedefer_afterdestructure uses.., and thehas_missedtest fillsbits.a_submission_that_missed_leaves_the_copies_at_oncenow also takesgpu_test_lock.The substance is the same and still reads correct to me.
crates/victory-gpu/src/memory.rs, the 256 KiB dirty bitmaps come from a pool capped at 64 entries (Bitmap::acquire/PooledBitmap), and the pool is zeroed before reuse.write_tablewrites the page table straight into the mapped upload buffer and builds level-1 on the stack. It now also skips copies whose end would overflow.ownerbecomesu32withNO_OWNER, and the bitmap scans skip zero words.The earlier minor points still stand, none blocking:
marks.fill(0)inPooledBitmap::drop.memory::bindwithoutgpu_test_lockcould still makebitmap_pool_reuses_and_zeroes_across_resetsflaky, because the test assumes LIFO reuse of the global pool.CI: passing.
Generated by Claude Code
@tumbubu on GitHub · 2026-11-25 21:34 UTC · original
f9b27fdin the world on an RX 7900 XT (RDNA3): the bitmap scan this PR rewrites is about 8% of the submission thread's wall time onmain, and absent with this PR. Tests: 198 passed.--profile diag --features diagnostics) ofmain13f91caand of this PR, which is13f91caplusf9b27fd.VICTORY_LOG=info.Where the time goes. I sampled with
VICTORY_STACKS, a dump every 0.25 s from 105 s to 175 s, in the world. A dump of 96 threads takes about 1 s, so that came to 74 dumps onmainand 47 here. I symbolisedvictory.exeframes from the build's PDB. The thread that runsqueue::pump→Host::executeis the busy one. The title's threads are waiting in almost every dump.mainmemory::bind'sdefer_missedclosure (the old(0..32).filterscan)ZwReadVirtualMemory(refresh copies, not touched here)rustc -O, Ryzen host). Themainsamples are consistent with roughly 80 such scans in a ~760 ms frame.Frame lines (world: frame-rate lines under 10 fps with at least 500 draws):
main, 3 runsmainalone ranges from 712 to 918 ms here, so I do not claim a frame-level number. The samples are the measurement.mainrun, the 712 ms one, hadVICTORY_SHADER_LOOP_LIMIT=4096, which only changes shaders.Tests.
cargo test --locked -p victory-gpu --lib -- --test-threads=1on this PR: 198 passed, 0 failed, 1 ignored. That includes the three new tests, on hardware.AI-assisted (Claude Code); every run was on this machine. Only timings and VIctory's own function names are posted, no game files.