What shaders wrote is landed on a few threads, beside the guards (VICTORY_LAND)
The relay's thread merged some 1,500 pieces of 64 KiB (98 MB) a frame one after the other: 45 ms in the frame's shape, of them 22 ms copying and merging, 18 ms the kernel's faults on the first write to each page of memory just made writable, 5 ms protection calls. Now one AVX2 pass a piece, in jobs on four threads, through a view of ours of the title's pages that is never guarded (VICTORY_LAND_BESIDE): 8 ms. The log splits a landing's time. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
da89c8a5a9
commit
590af7ca39
8 files changed
+1960
-82
No files matched your search
@@ -269,9 +269,12 @@ struct Views {
|
||||
views: BTreeMap<usize, (usize, usize, u64)>,
|
||||
/// Sections by handle: bytes, and whether made committed.
|
||||
sections: Vec<(usize, u64, bool)>,
|
||||
/// Our own view of a whole section, by its handle (0: the host gave
|
||||
/// none), made when first asked for ([`beside`]) and kept.
|
||||
whole: Vec<(usize, usize)>,
|
||||
}
|
||||
|
||||
static VIEWS: Mutex<Views> = Mutex::new(Views { views: BTreeMap::new(), sections: Vec::new() });
|
||||
static VIEWS: Mutex<Views> = Mutex::new(Views { views: BTreeMap::new(), sections: Vec::new(), whole: Vec::new() });
|
||||
|
||||
fn views() -> std::sync::MutexGuard<'static, Views> {
|
||||
VIEWS.lock().unwrap_or_else(|e| e.into_inner())
|
||||
@@ -282,6 +285,9 @@ fn views() -> std::sync::MutexGuard<'static, Views> {
|
||||
pub fn title_memory_section(section: usize, bytes: u64, committed: bool) {
|
||||
let mut v = views();
|
||||
v.sections.retain(|s| s.0 != section);
|
||||
// A handle's number given out again: the view was of the section that
|
||||
// had it before (it stays mapped: someone may be writing through it).
|
||||
v.whole.retain(|w| w.0 != section);
|
||||
v.sections.push((section, bytes, committed));
|
||||
}
|
||||
|
||||
@@ -343,6 +349,36 @@ pub(crate) fn cover(at: usize, len: usize) -> Cover {
|
||||
cover_in(&views().views, at, len)
|
||||
}
|
||||
|
||||
/// Another address of the title memory `[at, at + len)`, if it is a view of
|
||||
/// the title's pages, all of it one run of a section: in a view of ours of
|
||||
/// the whole section, which is never guarded (`crate::watch`) nor changed.
|
||||
///
|
||||
/// The section's pages are reserved and the runtime commits each before it
|
||||
/// shows it, which holds for every view of the section. The caller holds
|
||||
/// `crate::watch::title_memory_reading`: until it lets go the title sees
|
||||
/// the same pages at `at`.
|
||||
pub(crate) fn beside(at: usize, len: usize) -> Option<usize> {
|
||||
let mut v = views();
|
||||
let Cover::Run(section, offset) = cover_in(&v.views, at, len) else {
|
||||
return None;
|
||||
};
|
||||
let base = match v.whole.iter().find(|w| w.0 == section) {
|
||||
Some(w) => w.1,
|
||||
None => {
|
||||
let &(_, bytes, _) = v.sections.iter().find(|s| s.0 == section)?;
|
||||
// SAFETY: the whole of a section the runtime made; a view the
|
||||
// title sees is of it, so its handle is open.
|
||||
let base = unsafe { mem::MapViewOfFile(section as _, mem::FILE_MAP_WRITE, 0, 0, bytes as usize) }.Value as usize;
|
||||
if base == 0 {
|
||||
tracing::warn!(error = %std::io::Error::last_os_error(), "no view of the title's pages beside its own");
|
||||
}
|
||||
v.whole.push((section, base));
|
||||
base
|
||||
}
|
||||
};
|
||||
(base != 0).then(|| base + offset as usize)
|
||||
}
|
||||
|
||||
/// Whether `[at, at + len)` is private memory, all committed and
|
||||
/// read-write: what [`From::Part`] takes. One question to Windows (it
|
||||
/// walks the page tables to the end of the pages that share the first
|
||||
|
||||
Reference in new issue
Block a user