native: count the descriptor records remirrored at submission (VICTORY_TRACE_DESCRIPTORS) #119

Merged
Olima34 merged 1 commit from upstream-pr/119 into main 2026-11-26 18:09:23 +00:00
Olima34 commented 2026-11-26 17:24:32 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T17:24:32Z.


First measuring PR for #43, as you suggested: how many descriptor records the title rewrites with plain stores, which no device call reports.

What. NativeHost::remirror_tables already compares each bound table's records with those it last mirrored, at every draw and dispatch. With VICTORY_TRACE_DESCRIPTORS set (any value):

  • it counts, per heap (keyed by its first descriptor address), the records it checked and those it found different;
  • NativeHost::execute counts submissions with a drop guard (error returns too), and the most records changed in one submission;
  • the 64-frame frame log (native draws so far) is followed by a descriptor remirror line: changed and checked since the last line, per frame, submissions, most in one submission, and the heaps sorted by records changed.

Off, the cost is one OnceLock read per table remirror and per submission.

Limits (in the doc bullet).

  • It sees only what that check sees: the first 16 entries per bound table, or more when the metadata says so.
  • It does not say which code wrote the records.
  • A record seen for the first time counts as changed, so the first lines after a load are high; the steady-state lines are the ones to read.

Next. A second PR finds the store sites themselves:

  • write-protect the pages of the shader-visible heaps between submissions;
  • on a write fault, record the title RIP (as an image offset) when the address is inside a descriptor range;
  • unprotect the page and resume the store. Host and HLE writes, and title stores that only share the page, are let through the same way.
    That answers "how many patch sites". I'll post it separately so this one stays small.

Test. native::descriptor_trace::tests::counts_add_up_by_heap_and_submission checks per-heap sums, the most per submission, the summary text and the sort order.

victory-gpu tests (arm64), Windows clippy and cargo xtask policy pass. One unrelated flake showed up once and passed on two reruns: texture_tests::a_texture_uploaded_blank_is_probed_at_each_submission, under a full parallel run. It shares the global title with other tests.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6631900077 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/119). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-26T17:24:32Z. --- First measuring PR for #43, as you suggested: how many descriptor records the title rewrites with plain stores, which no device call reports. **What.** `NativeHost::remirror_tables` already compares each bound table's records with those it last mirrored, at every draw and dispatch. With `VICTORY_TRACE_DESCRIPTORS` set (any value): - it counts, per heap (keyed by its first descriptor address), the records it checked and those it found different; - `NativeHost::execute` counts submissions with a drop guard (error returns too), and the most records changed in one submission; - the 64-frame frame log (`native draws so far`) is followed by a `descriptor remirror` line: changed and checked since the last line, per frame, submissions, most in one submission, and the heaps sorted by records changed. Off, the cost is one `OnceLock` read per table remirror and per submission. **Limits (in the doc bullet).** - It sees only what that check sees: the first 16 entries per bound table, or more when the metadata says so. - It does not say which code wrote the records. - A record seen for the first time counts as changed, so the first lines after a load are high; the steady-state lines are the ones to read. **Next.** A second PR finds the store sites themselves: - write-protect the pages of the shader-visible heaps between submissions; - on a write fault, record the title RIP (as an image offset) when the address is inside a descriptor range; - unprotect the page and resume the store. Host and HLE writes, and title stores that only share the page, are let through the same way. That answers "how many patch sites". I'll post it separately so this one stays small. **Test.** `native::descriptor_trace::tests::counts_add_up_by_heap_and_submission` checks per-heap sums, the most per submission, the summary text and the sort order. victory-gpu tests (arm64), Windows clippy and `cargo xtask policy` pass. One unrelated flake showed up once and passed on two reruns: `texture_tests::a_texture_uploaded_blank_is_probed_at_each_submission`, under a full parallel run. It shares the global title with other tests.
LakshanSivakumar commented 2026-11-26 18:09:51 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T18:09:51Z.


Merged together with #127, which builds on it, thanks.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7200126595 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/119#issuecomment-7200126595). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T18:09:51Z. --- Merged together with #127, which builds on it, thanks.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS!119
No description provided.