Each path test opens its own device and compiles the path pipeline. On a cold driver cache that takes minutes and gigabytes per compile, and libtest ran one per CPU thread side by side: on NVIDIA the solidcraft-gpu tests ran for hours and committed ~80 GB. Executor::new now holds a process-wide lock while it compiles; the first compile fills the driver's cache and the waiting ones get the pipeline from there. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
41d6a9244a
commit
2aa45ef3ee
2 files changed
+30
No files matched your search
@@ -217,6 +217,7 @@ impl Executor {
|
||||
lost.store(false, Ordering::Release);
|
||||
log::warn!("gpu-path device lost ({reason:?}); executor unavailable: {message}");
|
||||
});
|
||||
let compiling = one_compile_at_a_time();
|
||||
let scopes = scopes(&device);
|
||||
let shader =
|
||||
device.create_shader_module(wgpu::ShaderModuleDescriptor { label: Some("gpu-path"), source: wgpu::ShaderSource::Wgsl(SHADER.into()) });
|
||||
@@ -251,11 +252,21 @@ impl Executor {
|
||||
cache: None,
|
||||
});
|
||||
checked(scopes)?;
|
||||
drop(compiling);
|
||||
warm_up(&device, &queue, &pipeline, &placeholder_bind(&device, &layout, 7)?, &healthy)?;
|
||||
Ok(Self { context: Arc::new(Context { healthy, device, queue, pipeline, layout, denoise: std::sync::OnceLock::new() }) })
|
||||
}
|
||||
}
|
||||
|
||||
/// Native drivers compile the path pipeline for minutes and gigabytes on a cold shader cache.
|
||||
/// Executors opened side by side (parallel tests, each on its own device) compiled it together
|
||||
/// until memory ran out (#6706). One compile at a time per process: the first fills the driver's
|
||||
/// cache, and the waiting ones then get it from there.
|
||||
fn one_compile_at_a_time() -> std::sync::MutexGuard<'static, ()> {
|
||||
static COMPILE: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
||||
COMPILE.lock().unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
}
|
||||
|
||||
// Small zeroed bindings: binding 0 is a uniform whose zero work count makes every
|
||||
// invocation return at once; the others are storage buffers.
|
||||
fn placeholder_bind(device: &wgpu::Device, layout: &wgpu::BindGroupLayout, count: u32) -> Result<wgpu::BindGroup> {
|
||||
|
||||
@@ -593,6 +593,25 @@ fn path_devices_are_vulkan_or_metal_only() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #6706: executors opened side by side never compile the path pipeline at the same time.
|
||||
#[test]
|
||||
fn path_pipelines_compile_one_at_a_time() {
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
let inside = AtomicUsize::new(0);
|
||||
let most = AtomicUsize::new(0);
|
||||
std::thread::scope(|scope| {
|
||||
for _ in 0..8 {
|
||||
scope.spawn(|| {
|
||||
let _compiling = one_compile_at_a_time();
|
||||
most.fetch_max(inside.fetch_add(1, Ordering::SeqCst) + 1, Ordering::SeqCst);
|
||||
std::thread::sleep(Duration::from_millis(5));
|
||||
inside.fetch_sub(1, Ordering::SeqCst);
|
||||
});
|
||||
}
|
||||
});
|
||||
assert_eq!(most.load(Ordering::SeqCst), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn viewport_path_backends_keep_windows_on_its_selected_backend() {
|
||||
for backend in [wgpu::Backend::Dx12, wgpu::Backend::Gl, wgpu::Backend::Vulkan] {
|
||||
|
||||
Reference in new issue
Block a user