VICTORY_SYNC_IN_PLACE=1: the heaps' records read where they are and compared as read
Ported from Belobug/VIctory-Belobug-AMD 15ab94e (and the test's type from 8822ed4; that commit's turning it on by default is not taken). The round of the heaps' records (descriptor::sync_heaps) read each changed page through the kernel into a copy, then compared the copy with the records last seen: two passes over every page. With the switch each record of 32 bytes is read in place once by the fault-safe copy code (safecopy::changed, AVX2), compared with the one last seen, and put over it where it differs; a page the title unmaps meanwhile fails the read as the kernel's read failed, the records before it taken as read. Measured there: copy 7.4 and compare 5.3 ms a frame of six threads for 35 MB. Here the round's reading and comparing was 2.6-3.1 ms a frame (release run 233354), and the submitting thread waits 2.7-5.8 ms a frame for rounds. Changes nothing of what is mirrored (the same records found changed); reads title memory in place instead of through the kernel. Off by default. With it on, the frame line "the heaps' records read where they are" counts pages and those not all there; the heaps' records line's "reading and comparing" and "ms waited for" show the gain. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
66f7e545e3
commit
769fe52887
3 files changed
+230
-20
No files matched your search
@@ -4713,6 +4713,48 @@ impl Copied<'_> {
|
||||
let last = unsafe { std::slice::from_raw_parts_mut(self.at.add(at), end - at) };
|
||||
changed_records(last, &records[..end - at], self.step, first, out);
|
||||
}
|
||||
|
||||
/// As [`Copied::changes`] for the `count` records of title memory at
|
||||
/// `title` (slot `first` on), 32 bytes each, read where they are, each
|
||||
/// once ([`crate::safecopy::changed`]); `bits` is room. False when a page
|
||||
/// of them could not be read: those before it are done, the others
|
||||
/// stay as last seen.
|
||||
///
|
||||
/// # Safety
|
||||
/// As [`Copied::changes`]; `title` is title memory (read by a copy that
|
||||
/// fails where a page is not there).
|
||||
pub(crate) unsafe fn changes_in_place(&self, first: u32, title: *const u8, count: usize, bits: &mut Vec<u64>, out: &mut Vec<u32>) -> bool {
|
||||
let at = first as usize * self.step;
|
||||
let count = count.min(self.len.saturating_sub(at) / 32);
|
||||
if self.step != 32 || count == 0 {
|
||||
return true;
|
||||
}
|
||||
bits.clear();
|
||||
bits.resize(count.div_ceil(64), 0);
|
||||
// SAFETY: within the records held; the caller's slots alone.
|
||||
let whole = unsafe { crate::safecopy::changed(title, self.at.add(at), count, bits) };
|
||||
for (n, &word) in bits.iter().enumerate() {
|
||||
let mut word = word;
|
||||
while word != 0 {
|
||||
out.push(first + (n * 64) as u32 + word.trailing_zeros());
|
||||
word &= word - 1;
|
||||
}
|
||||
}
|
||||
whole
|
||||
}
|
||||
|
||||
/// The `count` records last seen from slot `first` on (fewer where the
|
||||
/// heap ends).
|
||||
///
|
||||
/// # Safety
|
||||
/// As [`Copied::changes`]: no other call beside this one has any of
|
||||
/// these slots.
|
||||
pub(crate) unsafe fn seen(&self, first: u32, count: usize) -> &[u8] {
|
||||
let at = (first as usize * self.step).min(self.len);
|
||||
let len = (count * self.step).min(self.len - at);
|
||||
// SAFETY: within the records held; the caller's slots alone.
|
||||
unsafe { std::slice::from_raw_parts(self.at.add(at), len) }
|
||||
}
|
||||
}
|
||||
|
||||
/// The records (`step` bytes each, the first is slot `first`) that differ
|
||||
|
||||
Reference in new issue
Block a user