Repository navigation
Card hash passes after ranges go up: each piece once by default (VICTORY_CARD_REHASH_RUNS=0 as before, =1 touching pieces joined) - #1298
Conversation
|
One in-game data point for
So joining cut the passes to about a third with no frame-time change. That fits the card not being the limit there: in a timing run on the same tree the card was about 53% busy, idle behind the submitting thread. One run per arm and scene variance applies. We haven't run this PR's new default, so the |
|
A note on how the tables above were measured. Four unrelated CPU-bound processes were running on the machine during those runs, so the machine was not quiet. I re-ran The card times match the published ones:
The ordering is the same in every row. A few rows from the re-run (card µs,
None of the conclusions change. AI use: Claude Code (Claude Opus 5.5) ran the re-measurement and wrote this note. 🤖 Generated with Claude Code |
|
Thanks @HLVM04, that's a useful data point. It matches the benchmark: with the card ~53% busy and idle behind the submitting thread, cutting hash passes (1,071 → 316) can't move the median frame on a 5070 Ti. This PR mostly helps where the card is the limit: on the Intel UHD the per-page card time drops 363 → 36.5 ms, and on the RTX 4060 Laptop 15.1 → 0.43 ms. It also saves ~1.3 ms of submitting-thread time per 16k-run page on the RTX. So on fast cards I'd expect no frame change, and on smaller cards or iGPUs the frame should move. If anyone has a lower-end card (or an iGPU) in the world, an unset vs AI use: Claude Code (Claude Opus 5.5). |
|
A data point from a lower-end card, though not the unset vs |
|
Correction to my comment above: the 90 ms tail is the long-tail case on my machine (about one sample in five); the median tail is 28-40 ms, and the title's own phase after the present returns is usually the longer part. Details: CuteBooty/victory-8gb#1 (comment). |
…ORY_CARD_REHASH_RUNS=0 as before, =1 touching pieces joined) With VICTORY_CARD_REHASH_RUNS unset, every range sent up to a copy in the card's memory had a hash pass of its own, so a 64 KiB piece holding 16,384 changed runs (fork issue fxceless#1083) was hashed 16,384 times: 14-15 ms of an RTX 4060 Laptop's time, 362 ms of an Intel UHD's (synthetic, card alone). - Unset (the new default): runs of pieces that share a piece are one pass (Rehash::Sharing), so each piece is hashed once: 0.43 / 36.5 ms for that page. - =1 keeps the touching join (Rehash::Touching). It is not the default because CARD_COMPARE gives a pass's pieces one thread each in a single group: 16 touching pieces with one range each took 179 us of the RTX's time as 16 passes and 266 us as one (Intel 1.15 / 1.23 ms). - =0 is the old pass a range; alt still alternates =1 and =0. - joined_piece_runs takes `touching`; the frame-rate line names the way. Tests: rehash_tests::joined_rehash_leaves_the_hashes_a_pass_a_range_does (GPU, ignored) runs 56 random cases on three copies, one per way, and checks the card bytes and every piece hash are identical across ways, equal to a CPU model of CARD_COMPARE for touched pieces and unchanged for the others (RTX, Intel UHD, WARP; also with VICTORY_CARD_HASH_WIDE=1). rehash_bench (ignored) prints the table. Host::card_sync_timed and Shadow::card_put_runs are test only (card_sync_timed is the same helper as in PR fxceless#1295). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
08a4e9b to
2e575c2
Compare
|
Rebased on Does e4245f3 supersede it? No.
Re-measured on e4245f3 (median of 15 rounds, 9 on WARP). The description's tables are updated, and the
So the wide hash and this PR stack. With the wide hash, The GPU test passes again on RTX, Intel and WARP. Note for whoever merges: #1295 adds the same test-only helper AI use: Claude Code (Claude Opus 5.5). |
Problem
With
VICTORY_CARD_REHASH_RUNSunset (the default),Host::card_beforegives every range sent up to a copy in the card's memory its ownCARD_COMPAREhash pass. A 64 KiB page with thousands of changed runs, as in #1083 (up to about 16,000), gets one pass per run over the same piece. In a synthetic test that is 14–15 ms of an RTX 4060 Laptop's time for one page, and 362 ms on an Intel UHD.=1joins the passes. The fork's own diagnostic runs all set it, and #867 (item 4) proposes making it the default. But=1also joins pieces that only touch. The narrowCARD_COMPARE(the default;VICTORY_CARD_HASH_WIDEis off) gives each of a pass's pieces one thread in a single group. So 16 neighbouring pieces with one range each run as one wave instead of 16, and that is slower: 179 → 266 µs on the RTX.Change
VICTORY_CARD_REHASH_RUNSnow has three ways:Rehash::Sharing1Rehash::Touching0Rehash::Apartalt1and0every 20 s (unchanged)joined_piece_runstakes atouchingflag. The frame-rate line "our passes over copies in the card's memory" names the way in use. Nothing else changes: the same pieces are hashed with the same shader and constants. Only the number of dispatches they are split into changes.Measurements
Synthetic
host::rehash_tests::rehash_bench, release build, onmaine4245f3 (re-measured after the rebase; nine unrelated single-threaded CPU jobs were running), card time from timestamps aroundcard_before's lists, median of 15 rounds (9 on WARP). The three ways run in rotating order inside each round. Cases are pages × runs: runs of 2 bytes, evenly spaced, in each of the first pages 64 KiB pieces of a 1 MiB copy. Values are=0 / =1 / new default.Card time, µs:
Submitting thread (
card_before), µs, RTX: 1 × 16384 6895 / 5085 / 5171; 4 × 16384 28467 / 22618 / 22024. Small cases are within ±10 µs. Intel and WARP follow the same pattern (raw tables below).What the numbers show:
=0: on RTX and Intel, the new default is never slower beyond noise, and it is 35× (RTX) and 9× (Intel) faster on the RTX 3070 8 GB + 16 GB RAM, Series S profile: what each switch and recent PR did on main (3973179 → ca8829f) #1083-like page. Where=0and the default record the same passes (2/4/16 × 1), the cells differ only by noise (Intel 4 × 1: 1303 / 1521).=1: the new default is never slower beyond noise on RTX and Intel, and it is faster wherever neighbouring pieces each hold few ranges.=1is ahead there on 2/4/16 × 1. WARP is not a target for play.VICTORY_CARD_HASH_WIDE=1(one group per piece; e4245f3 measured it in game with=alt, card -10 ms a frame, but kept it off by default): every pass is cheaper, but the pass count is the same, so joining still pays. The new default and=1are equal within noise, and both beat=0: RTX 1 × 16384 1038 / 278 / 280 µs, Intel 50870 / 38765 / 38660 µs. The touching penalty of=1(16 × 1) is gone with this hash form. Table:Raw logs
The tables were produced by
cargo test --release -p victory-gpu --lib rehash_tests::rehash_bench -- --ignored --nocapture(REHASH_BENCH_ROUNDS=9on WARP). On WARP:--features diagnostics,VICTORY_D3D12_WARP=1,--test-threads=1. The Intel adapter was picked with a local-only adapter-selection hook (not in this PR).RTX, VICTORY_CARD_HASH_WIDE=unsetRTX, VICTORY_CARD_HASH_WIDE=1Intel, VICTORY_CARD_HASH_WIDE=unsetIntel, VICTORY_CARD_HASH_WIDE=1WARP, VICTORY_CARD_HASH_WIDE=unsetWARP, VICTORY_CARD_HASH_WIDE=1Correctness
host::rehash_tests::joined_rehash_leaves_the_hashes_a_pass_a_range_does(GPU,#[ignore]) sets up three copies with the same bytes, one per way. Then, for 56 random cases (1 to 5,000 runs; lengths from 1 byte to just over a piece; sorted and unsorted; overlapping; crossing piece edges), it checks:CARD_COMPARE(narrow hash), and untouched pieces keep their earlier hash.The test was run on:
--features diagnostics, single-threaded): passes.VICTORY_CARD_HASH_WIDE=1: passes (the CPU model check is skipped there; the cross-way equality is not).Pass counts over the 56 cases: 30,950 a range each, 96 touching, 386 each piece once.
A mutation that drops the last piece of a joined run fails at case 1.
Unit test.
piece_runs_join_without_losing_or_adding_piecesnow checks bothtouchingvalues.Suite and lints.
cargo test -p victory-gpu(on e4245f3): 222 passed on RTX and on Intel. WARP,--features diagnostics --test-threads=1, release: 238 passed; 3profile::testsfail, and the same three fail on unmodifiedmaine4245f3 in the same build (this PR does not touchprofile). The GPU test above passes again on RTX, Intel and WARP on e4245f3.cargo clippy -p victory-gpu --all-targets [--features diagnostics] -- -D warnings: clean.rustfmt --checkdifferences are pre-existing neighbouring lines.Host::card_sync_timed(test-only) is the same helper as in #1295. If both land, the second one should drop its copy.What is not measured
=1shows about 457 passes over 1,169 pieces per frame. With the new default that becomes somewhere between 457 and 1,169 dispatches, each covering fewer pieces.Request for an A/B
@MKmajster, @CuteBooty (#1083): could you run your opening scene three times:
VICTORY_CARD_REHASH_RUNS=0(the old default);1?Please compare the frame log's card meter "send-and-hash lists" and the frame time. The line "our passes over copies in the card's memory per frame" shows the pass count for each way.
AI use: Claude Code (Claude Opus 5.5) read the code paths, wrote the change and tests, and ran the benchmarks and test suites on the hardware above. No game data was used.
🤖 Generated with Claude Code