Pages are mapped side by side: eight threads stand in the host's queue instead of one

Mapping and unmapping a view wait for what every protection change of a
view takes too (about 100,000 a second, the guards'): 0.2-4 ms a page, all
on the one thread the title loads with. Scatter maps and the GPU's
page-mapping copies go in groups of up to 64 pages, noted before and after
on the caller's thread, the system calls on up to eight
(VICTORY_MAP_THREADS=1: one after the other, as before).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 04:31:31 -06:00
1 parent 0d065d3521
commit 565f4a5603
4 files changed
+458 -29

No files matched your search

+12
View File
@@ -919,6 +919,15 @@ extern "system" fn copy_page_mappings(
unsafe { std::slice::from_raw_parts(batches, count as usize) }
});
let mut ok = true;
let many = crate::resource::many_page_mapper();
let mut gathered: Vec<(u64, u64, u64)> = Vec::new();
let mut map = |to: u64, from: u64, len: u64| match many {
Some(_) => {
gathered.push((to, from, len));
true
}
None => map(to, from, len),
};
for b in batches.into_iter().flatten() {
if b.ranges.is_null() {
continue;
@@ -940,6 +949,9 @@ extern "system" fn copy_page_mappings(
at += len;
}
}
if let Some(many) = many {
ok &= many(&gathered);
}
if !ok {
static ONCE: std::sync::Once = std::sync::Once::new();
ONCE.call_once(|| tracing::warn!(pool = format_args!("{pool:#x}"), "a page mapping failed"));
+14
View File
@@ -947,6 +947,20 @@ pub fn use_page_mapper(mapper: PageMapper) {
let _ = PAGE_MAPPER.set(mapper);
}
/// As a [`PageMapper`], many at once: `(to, from, len)` each, in order.
pub type ManyPageMapper = fn(&[(u64, u64, u64)]) -> bool;
static MANY_PAGE_MAPPER: std::sync::OnceLock<ManyPageMapper> = std::sync::OnceLock::new();
/// The runtime's mapper of many pages at once.
pub fn use_many_page_mapper(mapper: ManyPageMapper) {
let _ = MANY_PAGE_MAPPER.set(mapper);
}
pub(crate) fn many_page_mapper() -> Option<ManyPageMapper> {
MANY_PAGE_MAPPER.get().copied()
}
pub(crate) fn page_mapper() -> Option<PageMapper> {
PAGE_MAPPER.get().copied()
}