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 <noreply@anthropic.com>
|
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. |
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
|
Independent Windows/NVIDIA check of #3091 head
The full I did not run a paired title smoke, measure retail memory savings, or test AMD/Intel on this head. AI use: Codex (GPT-6.2 Sol) built and ran these checks and reviewed the results. |
|
At A hook in the test captured a valid native DXIL descriptor with production The recipe preserved a red-only write mask, distinct from the grandchild's all-channel mask. Both drew a red triangle over a blue-cleared 4×4 target, scissored to the left two columns:
All 16 pixels matched after a completion fence in each fresh process, and the device remained healthy. This verifies native use of the stored graphics descriptor and the shared shader lifetime. The fixture invoked deferred creation directly, so it does not exercise asynchronous worker scheduling or measure memory savings. AI use: OpenAI Codex adapted the fixture, ran the controls and prepared the report. |
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).
299c93f to
1dad60e
Compare
bmjask
left a comment
There was a problem hiding this comment.
Critical-review result: I found no concrete ownership or deduplication defect. Keeping weak entries in the index does not affect correctness because byte equality is checked and live users retain their own Arc; replacement affects reuse only.
Please update the failing PR-description gate and preserve the measured memory/startup evidence when this is promoted from nvidia-dev.
Reviewed at 1dad60e with Codex (GPT-5).
|
CI follow-up for #3091 head PR #3183 addresses the shared-test-state race: its bounded WARP overlap check reproduced 4/2 before the lock and 2/2 after it. Its Windows build/test and description checks pass. That existing test-isolation PR is the relevant CI unblocker; #3091 should be rerun after it lands. The separate PR-description job rejects the historical smoke results: Regression run needs generated AI use: Codex (GPT-6.2 Sol) inspected both exact CI failures, compared the source blobs, and drafted this note. |
How this was run: the suite ran once on the 11 of your PRs that build on this base, merged together (#3047 #3048 #3049 #3091 #3092 #3103 #3104 #3105 #3107 #3123 #3125; a local tree, only #3125 needed a resolution in README and the AI use: Claude Code (Claude Opus 5.5 and Claude Fable 5.2) ran the builds, tests and title runs, reviewed the diff and wrote this; the code points cited were checked against the merged tree. |
|
merge-check This check was run from the PR author's account (Prime1997), so it does not count as one of #3041's two independent checks. Suite in debug; smokes on release builds of the exact merged and base commits, with a copied profile and shader cache. Generated by Claude Code |
main has merged nvidia-dev (xcl-dev#3203): its two-pass mesh, sparse and upload paths now submit through real::native_queue_execute / _signal / _wait. Those already carry xcl-dev#867's UnadoptGuard and unwrap_fence; the conflicts and the main-only submit paths were resolved as follows. Taken from main, the stack's version dropped (main does the same): - recomp/dxc.rs (3): xcl-dev#688's private DXC heaps; main's form (3842807) falls back on any failure and never destroys a heap. - device_x.rs (10): xcl-dev#3091 (cherry-pick 511a297); main's 7e24237 keeps interned shader copies for base pipelines. xcl-dev#3091's tests and its real.rs test counter (GRAPHICS_FALLBACK_ATTEMPTS) and README line go; xcl-dev#2753's console_bytes is re-applied on main's file. - bind.rs (16): the stack's only change there was xcl-dev#1803, merged in main. main's file, plus the xcl-dev#2816 feedback-copy UnadoptGuard in poll_two_pass_feedback (ed887d2, from linux/stack-nvidia-dev). - pso.rs: main has daae033 (multidimensional groups take direct DXIL, xcl-dev#3189's change), so the stack-only commit is in main; translate calls take main's translate_compute_rodata / translate_entry_rodata_rt32. - list_x.rs tests: xcl-dev#3090's barrier tests were in twice (cherry-pick and main's merge); the cherry-picked copy goes. - runner.rs device(), xbox.rs Fssm::rodata: added on both sides; one copy. - README.md: the precompile-wrapper paragraph was added on both sides; one copy. Both kept: - build.rs (2): TRANSLATION_GLUE_REVISION "pso-glue-v5-linux-multidimensional- direct" (main's v5 + the stack suffix); translator sources keep xcl-dev#2229's cfg.rs and code_loads.rs, drop dxc.rs as main does. - dxil/kernel.rs (6): TRANSLATOR_VERSION 13 (main 12; the stack's xcl-dev#2229 head output differs, as on linux/stack-nvidia-dev); main's rt32 entry points with xcl-dev#2229's code_loads. - dxil/lower.rs (4), lower_mem.rs (3), lower_window.rs (1), recomp/emit.rs (11), recomp/mod.rs (3), recomp/tests.rs (1), core_tests.rs: main has an earlier copy of xcl-dev#2229 (41f1a85); xcl-dev#2229's head (code_loads, xcl_cload / xcl_gload(hi, a)) is kept over it, as on linux/stack-nvidia-dev; main's loop_ids, IO slots, ps_mask_live_scc and rt32 mask kept beside it, and main's duplicate core_tests copy of the rodata test goes. lower_mem.rs keeps the stack's scratch_ptr insert-before-terminator line. - real.rs (6): the class scan keeps `own` with main's release_through_its_own_vtable; xcl-dev#2477's in-place patch after main's two-pass defer hooks; q_signal_pc / q_wait_pc beside main's page mappings; the title ExecuteCommandLists keeps xcl-dev#867's list guards inside main's watch::in_driver scope; test modules of both. - list_x.rs (1): xcl-dev#867's allocator / PSO guards with main's `on = pc_alloc`. - sparse.rs (1): main's new_state, with xcl-dev#867's raw fences for the sparse and readback fences and the async readback fence pairs (as on linux/stack-nvidia-dev); pc_execute (main's texture_upload submit path) unadopts its list for the submit. - title_textures.rs (1): main's early fence creation, as a raw fence. - dstorage.rs (4): xcl-dev#2864's unpack cache on main's Cow source and stage buffers. - xg.rs (2): main's copy_args (adccb7d) covers xcl-dev#684's argument fix; xcl-dev#684's destination guard kept. - present.rs (1), gpu_compute_e2e.rs (1), README.md (2): tests and text of both. linux/README.md: main line updated; xcl-dev#1599, xcl-dev#2082, xcl-dev#1803, xcl-dev#3090, xcl-dev#688, xcl-dev#3091 and the stack-only multidimensional row leave the table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bmjask
left a comment
There was a problem hiding this comment.
Critical review of current head 1dad60ed. I found no concrete ownership defect in the shared immutable shader bytes: live pipelines retain strong Arcs and weak-index replacement affects reuse, not correctness. The current branch is nevertheless conflicted with main, so the hand-ported recipe and compute-build-key paths need a fresh rebase plus targeted tests of title memory reuse during pending builds and derived PSO creation. Please also retain the measured memory/startup evidence after rebasing. This updates my prior code review; no local Windows run.
The pool's entries are weak, but an `Arc<[u8]>` holds its bytes in the allocation its weak references keep: the bytes of a shader whose last owner went stayed until the pool's next sweep (8,192 entries or more). The copies are `Arc<Vec<u8>>` now, so they go with their last owner, as in xcl-dev#3091. The bases, the descriptions of pipelines not built yet and the compute build keys hold the same one. Found by ettehn; the shape of the fix and the need to change the build key with it are thehollowedone's (review of xcl-dev#3505). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Source overlap check for #3091 head #3091 still has distinct work worth preserving: its test exercises a 1,024-recipe backlog and sharing across compute, graphics and stream forms; its derived-pipeline chain tests go further than #3505's new tests. It also rejects a nonempty shader stage with a null pointer while capturing a base, whereas current main's If #3505 lands first, a smaller follow-up from #3091's distinct validation and tests would avoid duplicating its production pool. This is a diff comparison, not a build, runtime measurement or merge check. AI use: OpenAI Codex (GPT-6.2 Sol) compared both current PR diffs and the existing main ownership path. |
|
Review (head 1dad60e, diff read, not a merge-check; it conflicts with main and
Fine: the bytes handed to the driver stay valid while the descriptor and build key hold the AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
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.Rebased onto main (2026-11-28).
nvidia-devwas merged intomainby #3203, so this PR now targetsmainand its branch was rebased ontomain765b2c5bfff6754e8c9886a73e188a86aca3c64c: head1dad60ed99b343428faff147592de955ae273dfa(was299c93f113c59eec315933c09432130569288f88).mainalready kept each recipe's shader bytes in anArc<[u8]>shared with its compute build key (cfbe016), which the second commit collided with. It is ported onto that code by hand: recipes and compute build keys now both hold this PR'sArc<Vec<u8>>from the weak index, socompute_build_key.rs, its tests and one test helper inpso_async.rschange type with it. That port needs a review. On the rebased head, on the same RTX 3060 Ti PC, debug profile:cargo check -p xcl --all-targetsexited 0, andcargo test -p xcl --lib -- --test-threads=4 a_thousand_pending_graphics_recipes_keep_two_unique_shader_payloads async_recipes_share_shader_bytes_and_keep_them_until_the_last_owner base_shader_bytes_survive_title_memory_reuse base_shader_copy_rejects_unreadable_nonempty_stages base_shader_sharing_checks_collisions_and_bounds_weak_entries build_key_shares_the_owned_shader_allocation concurrent_bases_publish_one_shader_copy derived_base_owns_shader_bytes_after_parent_is_forgotten derived_pipeline_patches_land_on_the_desc_parts gpu_derived_pipeline_survives_original_shader_reuse many_bases_share_shader_payload compute_build_key shaders_key owned_desc owned_shader in_flight base_shader mesh_stream derived depth_biasgave 40 passed, 0 failed, 0 ignored, no SKIPPED. The whole suite and the paired title runs have not been rerun on this head; every other result below is from the earlier head. The rebase and its conflict resolution were done with Claude Code.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/6B4TykyC4W