VICTORY_HEAP_SYNC_AT_SUBMIT=1: the heaps' records asked for at the title's submit

Ported from Belobug/VIctory-Belobug-AMD 673be0e and a609a2f (renderer
port 7, its heaps' records part; the journal in 64 parts, which shares
the switch VICTORY_PORT_JOURNAL there, is not taken). There the lane
waited 4.5-5.2 ms a frame for the heaps' records and port 7 took 2.4 ms
off it. Here the submitting thread waited 2.7-5.8 ms a frame for them
(release run 233354).

A round of the heap-sync thread is asked for when the title submits
(Lane::push, round_after), so it runs while the submission waits in the
line (12-15 are in it when one is added), and the submitting thread waits
for that round (begin_sync_heaps_after), or for a later one if a wait of
its queue that was met in memory went since (the queue's floor in the
line), or a step of ours wrote, or may have written, a heap's title
memory while preparing an earlier submission (heap_marks::prep_wrote:
buffer copies into a heap, copies at their place, our own steps). Added
here: a submission that waited for flights to land begins a round of its
own after the wait, as without the switch. With the switch off nothing
is marked, asked or counted. VICTORY_HEAP_SYNC_FIRST applies only to a
submission without a mark.

Not behaviour-neutral in timing: a record the title writes for a
submission after submitting it (or after a wait behind which the
submission stands was met) is left to a later round, as the console's
card could miss it too. Off by default. The frame line "the heaps'
records asked for at the title's submit" gives the wait per frame, the
rounds asked at a submit, the preparings that found theirs asked earlier
or had to ask, and those that wrote a heap's memory. Tests: the round
given begins after the call (heap_marks), and the line's marks with
waits and parts taken along (queue::behind).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
readmet3xt-labandClaude Opus 5.5 committed 2026-11-27 01:11:03 +05:30
1 parent 96dfd9bb89
commit d2e24b3bc3
5 files changed
+458 -13

No files matched your search

+73
View File
@@ -290,6 +290,79 @@ pub(crate) fn begin_sync_heaps() -> SyncedHeaps {
SyncedHeaps(Some(mine))
}
/// [`begin_sync_heaps`] for a submission that needs round `mark` (one that
/// began after what it reads was written, `crate::heap_marks`): asked for if
/// it has not been. 0: as [`begin_sync_heaps`]. Ported from
/// Belobug/VIctory-Belobug-AMD 673be0e and a609a2f.
#[cfg(windows)]
pub(crate) fn begin_sync_heaps_after(mark: u64) -> SyncedHeaps {
if mark == 0 || !sync_aside() {
return begin_sync_heaps();
}
// (The thread is started by the first `begin_sync_heaps`.)
let mut rounds = SYNC_ROUNDS.0.lock().unwrap_or_else(|e| e.into_inner());
if rounds.1 == 0 && rounds.0 == 0 {
drop(rounds);
return begin_sync_heaps();
}
let asked = rounds.0 < mark;
rounds.0 = rounds.0.max(mark);
drop(rounds);
use crate::heap_marks::{EARLY_ROUNDS, LATE_ROUNDS, STATS};
if asked {
SYNC_ROUNDS.1.notify_all();
STATS[LATE_ROUNDS].fetch_add(1, std::sync::atomic::Ordering::Relaxed);
} else {
STATS[EARLY_ROUNDS].fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}
SyncedHeaps(Some(mark))
}
/// The number of a round of the heaps' records that begins after this call,
/// asked for if none is waiting to begin (at the title's submit: the round
/// runs while the submission waits in the line). 0 if the records are not
/// synced by a thread of their own (or it has not started yet).
#[cfg(windows)]
pub(crate) fn round_after_now() -> u64 {
if !sync_aside() {
return 0;
}
let mut rounds = SYNC_ROUNDS.0.lock().unwrap_or_else(|e| e.into_inner());
if rounds.1 == 0 && rounds.0 == 0 {
return 0;
}
let (round, ask) = crate::heap_marks::round_after(rounds.0, rounds.1);
if ask {
rounds.0 = round;
drop(rounds);
SYNC_ROUNDS.1.notify_all();
crate::heap_marks::STATS[crate::heap_marks::ROUNDS_ASKED].fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}
round
}
/// The number of the first round that begins after this call, not asked for
/// ([`begin_sync_heaps_after`] asks for it if nobody did).
#[cfg(windows)]
pub(crate) fn round_mark() -> u64 {
if !sync_aside() {
return 0;
}
let rounds = SYNC_ROUNDS.0.lock().unwrap_or_else(|e| e.into_inner());
if rounds.1 == 0 && rounds.0 == 0 {
return 0;
}
rounds.0 + 1
}
/// Whether `[at, at + len)` touches the title memory of a placed
/// shader-visible heap of descriptors.
#[cfg(windows)]
pub(crate) fn in_shader_heap(at: usize, len: usize) -> bool {
let (from, to) = (at as u64, at as u64 + len as u64);
SHADER_HEAPS.read().unwrap_or_else(|e| e.into_inner()).iter().any(|&(start, end, _)| from < end && start < to)
}
#[cfg(windows)]
impl Drop for SyncedHeaps {
fn drop(&mut self) {