Repository navigation
Conversation
dcb2004 to
64aa28f
Compare
|
Independent Windows/NVIDIA check of #3091 head The nine named shader-ownership fixtures pass on the RTX 3080 Ti (driver 621.35), including the native derived-pipeline check: 9 passed, 0 failed, 0 ignored, no reported skips. I ran the The current-head full workspace run, One bounded performance issue remains in Failing test-only regression@@
+ #[test]
+ fn saturated_base_shader_index_shares_repeated_new_stage() {
+ let index: BaseShaderIndex = Mutex::new(None);
+ let a = share_base_shader(&index, 1, &[1], 2);
+ let b = share_base_shader(&index, 2, &[2], 2);
+ let c = share_base_shader(&index, 3, &[3], 2);
+ let again = share_base_shader(&index, 3, &[3], 2);
+ assert_eq!(a.as_slice(), &[1]);
+ assert_eq!(b.as_slice(), &[2]);
+ assert!(Arc::ptr_eq(&c, &again), "an overflow stage should share a live payload");
+ }AI use: Codex (GPT-6.2 Sol) ran the tests and checked the finding; Codex (GPT-6.2 Astra) independently traced the index path. |
|
I tested the proposed bounded FIFO approach independently against head With all 65,536 index entries live, 16 threads requested four new payloads. The stock implementation returned distinct allocations for equal requests; the candidate shared one allocation per new payload, kept the index at its cap, and preserved the bytes held by every original owner. The candidate passed the existing collision and concurrency controls and the saturated case in 20/20 fresh processes. The bound is on index entries, not total live shader memory: after a key is evicted, a later request can create a second copy while an older owner still retains the first. This is a synthetic candidate test; retail memory and timing were not measured. AI use: OpenAI Codex with GPT-6.2 Astra built and ran the checks; Codex reviewed and prepared this report. |
|
Update for head AMD run (listed as untested), with an RTX 3060 in the same PC: the seven new tests pass on both, and nothing else in Tested: at the PR head
Not tested: the whole suite, a title, Intel. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report. |
|
I extended the existing pipeline-chain fixture with a native GPU draw on RTX 5070 / NVIDIA 616.92 at head After a bounded completion fence, readback showed exactly eight expected red pixels in the left two columns and eight untouched blue-clear pixels in the right two. The device remained healthy and the focused test passed with no skips. The existing fallback counters were checked at base, child, and grandchild creation. The fixture intentionally kept the root signature alive. This extends the creation-only coverage to one graphics draw after those shader-bytecode and ancestor lifetimes. It does not establish general resource lifetime, retail rendering, or memory savings. AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report. |
…#3092 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Follow-up to my saturated-index regression on head The previously posted repeated-overflow fixture failed on the unchanged head (0/1/0). With this candidate, Apply-ready candidate diffdiff --git a/crates/xcl/src/hle/d3d12x/device_x.rs b/crates/xcl/src/hle/d3d12x/device_x.rs
index be8051bb..ec952ada 100644
--- a/crates/xcl/src/hle/d3d12x/device_x.rs
+++ b/crates/xcl/src/hle/d3d12x/device_x.rs
@@ -344,29 +344,40 @@ fn rd64(d: &[u8], o: usize) -> u64 {
u64::from_le_bytes(d[o..o + 8].try_into().unwrap())
}
-type BaseShaderIndex = Mutex<Option<HashMap<(u64, usize), std::sync::Weak<Vec<u8>>>>>;
+#[derive(Default)]
+struct BaseShaderEntries {
+ blobs: HashMap<(u64, usize), std::sync::Weak<Vec<u8>>>,
+ order: std::collections::VecDeque<(u64, usize)>,
+}
+
+type BaseShaderIndex = Mutex<Option<BaseShaderEntries>>;
/// A weak index shares live Base shader copies, without keeping their byte buffers alive.
/// Unlike Arc<[u8]>, the Vec payload is released at the last strong reference, even while
/// this index keeps a weak reference. The index itself is bounded too.
fn share_base_shader(index: &BaseShaderIndex, hash: u64, bytes: &[u8], limit: usize) -> Arc<Vec<u8>> {
let key = (hash, bytes.len());
- let cached = index.lock().unwrap().as_ref().and_then(|m| m.get(&key)).and_then(std::sync::Weak::upgrade);
+ let cached = index.lock().unwrap().as_ref().and_then(|m| m.blobs.get(&key)).and_then(std::sync::Weak::upgrade);
if let Some(cached) = cached.filter(|v| v.as_slice() == bytes) {
return cached;
}
// Copy outside the lock; another creation may have published the same bytes meanwhile.
let owned = Arc::new(bytes.to_vec());
let mut g = index.lock().unwrap();
- let m = g.get_or_insert_with(HashMap::new);
- if let Some(cached) = m.get(&key).and_then(std::sync::Weak::upgrade).filter(|v| v.as_slice() == bytes) {
+ let m = g.get_or_insert_with(BaseShaderEntries::default);
+ if let Some(cached) = m.blobs.get(&key).and_then(std::sync::Weak::upgrade).filter(|v| v.as_slice() == bytes) {
return cached;
}
- if m.len() >= limit {
- m.retain(|_, v| v.strong_count() != 0);
- }
- if m.len() < limit || m.contains_key(&key) {
- m.insert(key, Arc::downgrade(&owned));
+ if limit != 0 {
+ if !m.blobs.contains_key(&key) {
+ if m.blobs.len() >= limit {
+ if let Some(oldest) = m.order.pop_front() {
+ m.blobs.remove(&oldest);
+ }
+ }
+ m.order.push_back(key);
+ }
+ m.blobs.insert(key, Arc::downgrade(&owned));
}
owned
}
@@ -1706,19 +1717,52 @@ mod tests {
let b = share_base_shader(&index, 7, &[5], 2);
let uncached = share_base_shader(&index, 9, &[6], 2);
assert_eq!(uncached.as_slice(), &[6], "full index still returns owned bytes");
- assert_eq!(index.lock().unwrap().as_ref().unwrap().len(), 2);
+ assert_eq!(index.lock().unwrap().as_ref().unwrap().blobs.len(), 2);
let weak = Arc::downgrade(&collision);
drop(collision);
assert!(weak.upgrade().is_none(), "the index does not keep the Vec or its payload live");
let c = share_base_shader(&index, 9, &[6], 2);
let keys = index.lock().unwrap();
let keys = keys.as_ref().unwrap();
- assert_eq!(keys.len(), 2);
- assert!(!keys.contains_key(&(7, 3)), "dead entry pruned at capacity");
- assert!(keys.contains_key(&(7, 1)) && keys.contains_key(&(9, 1)), "length is part of identity");
+ assert_eq!(keys.blobs.len(), 2);
+ assert!(!keys.blobs.contains_key(&(7, 3)), "oldest entry evicted at capacity");
+ assert!(keys.blobs.contains_key(&(7, 1)) && keys.blobs.contains_key(&(9, 1)), "length is part of identity");
drop((a, same, b, c, uncached));
}
+ #[test]
+ fn saturated_base_shader_index_shares_repeated_new_stage() {
+ let index: BaseShaderIndex = Mutex::new(None);
+ let a = share_base_shader(&index, 1, &[1], 2);
+ let b = share_base_shader(&index, 2, &[2], 2);
+ let c = share_base_shader(&index, 3, &[3], 2);
+ let again = share_base_shader(&index, 3, &[3], 2);
+ assert_eq!(a.as_slice(), &[1]);
+ assert_eq!(b.as_slice(), &[2]);
+ assert!(Arc::ptr_eq(&c, &again), "an overflow stage should share a live payload");
+ let entries = index.lock().unwrap();
+ let entries = entries.as_ref().unwrap();
+ assert_eq!((entries.blobs.len(), entries.order.len()), (2, 2));
+ }
+
+ #[test]
+ fn concurrent_overflow_shares_one_shader_copy() {
+ let index = Arc::new(Mutex::new(None));
+ let held = [share_base_shader(&index, 1, &[1], 2), share_base_shader(&index, 2, &[2], 2)];
+ let gate = Arc::new(std::sync::Barrier::new(8));
+ let threads: Vec<_> = (0..8).map(|_| {
+ let (index, gate) = (index.clone(), gate.clone());
+ std::thread::spawn(move || {
+ gate.wait();
+ share_base_shader(&index, 3, &[3; 1024], 2)
+ })
+ }).collect();
+ let copies: Vec<_> = threads.into_iter().map(|t| t.join().unwrap()).collect();
+ assert!(copies.iter().all(|v| Arc::ptr_eq(&copies[0], v)));
+ assert_eq!(index.lock().unwrap().as_ref().unwrap().blobs.len(), 2);
+ drop(held);
+ }
+
#[test]
fn concurrent_bases_publish_one_shader_copy() {
let index = Arc::new(Mutex::new(None));
@@ -1732,7 +1776,7 @@ mod tests {
}).collect();
let copies: Vec<_> = threads.into_iter().map(|t| t.join().unwrap()).collect();
assert!(copies.iter().all(|v| Arc::ptr_eq(&copies[0], v)));
- assert_eq!(index.lock().unwrap().as_ref().unwrap().len(), 1);
+ assert_eq!(index.lock().unwrap().as_ref().unwrap().blobs.len(), 1);
}
#[test]AI use: Codex (GPT-6.2 Sol) wrote the candidate, reviewed the bounded index and ownership path, and ran the stated tests. |
Own shader bytes for each retained graphics base and share equal live bytecode through a bounded weak index. Native derivation survives original-buffer reuse and parent release. The 1024-pipeline fixture retains 81920 payload bytes instead of 83886080 with separate copies; this is payload accounting, not process RAM. Full-suite and retail merge checks remain pending. Assisted-by: Codex (GPT-6)
Adapt the shader interning proposal in PR xcl-dev#827 using the bounded weak Vec ownership index from xcl-dev#3091. Pending compute, graphics and stream recipes share live immutable copies while preserving title-memory lifetime and cache keys. Source patch passed 11 focused CPU tests before integration; full GPU/gameplay validation is waived for this user test build. Concept credit: Cattn / PR xcl-dev#827. Implementation and focused checks: Codex (GPT-6).
64aa28f to
299c93f
Compare
Derived pipelines and pending asynchronous pipeline recipes retain shared immutable copies of shader bytes. The title can reuse its input memory without corrupting derived pipelines, and large pending queues avoid retaining one copy of the same shader per recipe. The weak sharing index is bounded, compares full bytes on hash collisions, and releases the payload at the last strong owner.
This extends the existing #3091. The pending-recipe sharing behavior overlaps the proposal in #827 (credit: Cattn); this NVIDIA implementation reuses the bounded
Weak<Vec<u8>>index already present here. No separate duplicate shader-sharing PR is opened.What is in it
Tested
5d0833553c68d2afa327c913cd9a22f17ec6f45esource plus patch SHA2561ea04e88f32675f0c5a4a64eb368479567ae9c1c79d4e7ab7da44ddc3a7c6ac5, not an individual-head full suite.cargo test --locked -p xcl --lib --target-dir <isolated target> -- --exact --test-threads=4 --nocapturefollowed by the 11 exact test names in those groups; the exact command and outputs are retained locally.Regression run
Not run for refreshed head
299c93f113c59eec315933c09432130569288f88. Previous-head results remain historical. The user requested a release candidate and interactive log monitoring, explicitly waiving further local shader/memory validation. This is not a passing GPU or gameplay result.Not tested
AI use
Codex (GPT-6) implemented the ownership repair, adapted #827's sharing concept to the existing bounded index, reviewed source and ran the CPU-only checks described above.
Optional temporary contributor/testing coordination: https://discord.gg/gK3y7WRRY