Repository navigation
Conversation
…UNTERS) LEONIDA_AB compares switch settings by turns in one run, but its phase lines carried only frame times, the card's idle time and the submitting thread's work: an A/B could not split by arm the time spent changing memory protections, refreshing, or waiting. The frame lines' counters (watch's ASKS and FAULT_ASKS, host's SPLIT) were emptied with swap(0) by the frame line, which runs on its own thread at its own pace, so a phase could not read them. They are now running totals, never reset; no writer changes. The frame line takes what came since its last take (ab::take, a fetch_max on a second array, so two takers never count the same amount twice) and prints the same numbers. Each A/B phase snapshots the totals where it reads the card's idle time and logs one more line, "A/B counters phase N bits b:", with each counter that moved, per frame, named next to its array (nanoseconds as ms). Diagnostics builds only, as before.
|
Independent check on Windows (not the author), at
Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, NVIDIA RTX 4070 Ti SUPER (driver 621.01), Rust 1.98.1 pinned. AI-assisted: yes (opencode). |
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: D3D12-AB-COUNTERS (#2570 (comment))
What and why
LEONIDA_ABturns switches on and off by turns inside one run, so that both sides are measured in the same scene. Its phase lines carry only frame times, the card's idle time and the submitting thread's work.Testers asked for more. In #2701, the time spent changing memory protections could not be split by arm. Their wish: "
LEONIDA_ABfor what does not depend on time".The frame lines' counters could not be read per phase:
ASKS(asking about title memory, protections),FAULT_ASKS(the title's faults) andSPLIT(the submitting thread's preparing) were emptied withswap(0)each time the frame line was written.This change:
turns those three arrays into running totals, never reset. No writer changes: every
tally,fault_countandSPLIT[i].fetch_addstays as it is;makes the frame line take what came since its last take (
ab::take), so it prints the same numbers. It usesfetch_maxon a second array (*_TAKEN), so two takers at once never count the same amount twice;has each A/B phase snapshot the totals where it already reads the card's idle time, then log one more line after the existing one, which is unchanged so no parser breaks:
Only counters that moved are listed, per frame over the phase's counted frames, with nanoseconds as ms. Each counter is named in a table next to its array (
ASK_NAMES,FAULT_NAMES,SPLIT_NAMES).As before, all of this is in diagnostics builds only. The hot paths are unchanged: each tally is still one relaxed
fetch_add.Tested
On Windows 11, from
d3d12\:--features diagnostics, the feature these counters live behind):watch::tests::a_running_total_survives_the_frame_lines_take: a total survives the frame line's take. It compiles onmain, where it fails by assertion ("the take emptied the total"), becauseasks()swaps the counter to 0. With the change it passes.ab::tests::a_take_counts_what_came_since_the_last_one_and_the_totals_stay.ab::tests::takers_at_once_count_everything_once: 4 threads × 10,000 adds and takes; the takes sum to the total exactly.ab::tests::a_phase_tells_what_moved_per_frame: the line's format, and one name per counter.cargo test -p leonida-gpu --locked --features diagnostics: 659 passed, 52 ignored. Without diagnostics: 579 passed.cargo clippy -p leonida-gpu --all-targets --locked --features diagnostics: nothing in the changed lines.git diff --checkandcheck_no_game_data.pyare clean.git merge-tree: no new conflict with the open pull requests on these files (d3d12: a guard page fails a copy and stays a guard page (D3D12-GPU-SAFECOPY-GUARD-PAGE-REARM) #2709, d3d12: forget write-combined and GPU read-only regions over a released allocation (D3D12-WC-REGIONS-ON-RELEASE) #2703, D3D12-SHADER-FAST-HASH: hash the translator's tables with a multiply hasher, not SipHash (-10 to -15 % of full-archive translate time) #2750). D3D12-CLIPPY-LEONIDA-GPU: fix all clippy warnings in leonida-gpu #2682 and runtime, d3d12: memory leak fixes from one sweep (RT-LEAK-SWEEP) #2569 have the same conflicts withmainas with this branch.LEONIDA_ABrun's counters line here.GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140, Windows 11 Pro 10.0.26300 (unit tests).
AI-assisted: yes
Checklist
mainand merges cleanly.docs/design.md, with how it was confirmed. (Not applicable: no translator change.)