Merge adjacent fills and cache fill_scratch lookups (VICTORY_MERGE_FI… #473
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/473"
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?
Imported from readmet3xt-lab/foxhound. Originally posted by GValdezN on 2026-12-02T15:13:37Z.
Merge adjacent fills and cache fill_scratch lookups (VICTORY_MERGE_FILLS)
When
VICTORY_MERGE_FILLS=1, fills queued inBatch::fill()are sorted by destination address before the copy loop. Adjacent entries whose source and destination are both contiguous are merged into a singlecopy_mappedcall, reducing per-fill overhead and giving the hardware prefetcher longer sequential runs.fill_scratch()gets a 4-entry stack-local most-recent-hit cache (always active, no switch) in front of theHashMaplookup. The four slots cover the typical working set of scratch allocations within a single list's recording; a hit avoids the hash, the probe chain, and theHashMap's pointer indirection.Batch::fill()sits on the frame's critical path: SPLIT[7] (copies and fills) measures 4–8 ms/frame in heavy scenes. The wide path dispatches fills towide_eachworkers (2–8 threads,victory-wide-N), so reducing per-entry overhead scales across threads. WithVICTORY_SEND_BAR=1(ReBAR), merged fills produce longer sequential writes over PCIe, which fill write-combining buffers more efficiently; the scatter pairs that dominate the ReBAR cost path are unaffected.Merge is off by default (
VICTORY_MERGE_FILLS=1to enable) so it can be measured before becoming the default. The sort is stable and in-place on the existingVec; no new allocations.Complements #478 (prefetch in fill loop + Vec::with_capacity) — merged fills + prefetch together reduce SPLIT[7] overhead.
Test plan:
cargo test -p victory-gpu(620 passed, 0 failed);cargo check -p victory-gpuclean.🤖 Generated with Claude Code
Imported from readmet3xt-lab/foxhound. Originally posted by tillo88 on 2026-12-02T21:06:03Z.
Replay-bench measurement: no measurable difference on v0.8.3.3
Measured: PR head
b4468e0merged onto release v0.8.3.3 (same code as main7dbcdcb), withVICTORY_MERGE_FILLS=1, 2 measured runs (after a warm-up run that is not counted), against 3 runs of v0.8.3.3 without the PR, same route (~6.5 min).Mean fps: release 36.38, PR 36.31 (-0.2%). That is below the 2-3% we treat as a real change, so: no measurable difference on this route. Only 3 release runs so far, so the release's own spread is not established yet.
Crashes: none in the PR runs and none in the release runs (no host GPU failure, no device lost).
Note: two earlier release runs the same evening, with identical switches, were much slower for most of the route (6-9 fps average); the cause is not known yet and they are left out of the comparison above. No PR run fell into that state.
Config: RTX 5070 Ti 16 GB, Ryzen 7 9800X3D, 32 GB, Windows 11; default
play-foxhound.ps1settings (Series X profile, 1440p, DLSS balanced, no frame generation), fullscreen, no frame cap.Measured unattended on a replay bench (same save, recorded controller input); numbers and text prepared with Claude.
Imported from readmet3xt-lab/foxhound. Originally posted by GValdezN on 2026-12-03T01:36:29Z.
Thanks for testing this one too, @tillo88! Makes sense that the merge-fills optimization doesn't show on this route — it benefits scenes with many fragmented small fills where the per-fill overhead adds up. The replay bench route at steady state likely has fewer, larger fills that don't fragment enough to hit the merge path often.
Would be interesting to see if it shows up on a route through a denser area with more draw calls, but no regression is the important part for now.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.