XGameSave: stage and roll back failed XGameSaveSubmitUpdate #1521

Closed
OtavioTadeu wants to merge 1 commit from upstream-pr/1531 into main
OtavioTadeu commented 2026-11-24 17:18:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by OtavioTadeu on 2026-11-24T17:18:50Z.


Makes XGameSaveSubmitUpdate (gamesave::apply) all-or-nothing by staging writes into ~xcltmp.* temp files, backing up existing files, and rolling back on any failure so partial updates cannot corrupt a save container. Fixes #324.

What is in it

  • crates/xcl/src/hle/xgameruntime/gamesave.rs: coalesce per-blob operations, stage and sync writes to sibling ~xcltmp.* files, back up existing targets before replace/delete, roll back in reverse order on error, and add rollback/coalescing tests

Tested

  • NVIDIA GeForce GTX 1660 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600G, Windows 11 build 26200, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), debug build
  • cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask [no wave64], gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware [no wave64], heap_window_out_of_memory_falls_back_to_the_switch_form [no heap windows])
  • cargo test -p xcl --lib gamesave: 11 passed, 0 failed

Regression run

  • scripts/smoke.ps1 -Game retail_title -Seconds 60 (main baseline vs PR head on NVIDIA GeForce GTX 1660 SUPER):

xcl-smoke v1

commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485

gpu: NVIDIA GeForce GTX 1660 SUPER

title: retail_title

seconds: 60

exit: 0x0

frames shown: 631 (PresentX 631)

presents per 2 s (last 3): 47 47 49

device removals: 0

crashes: 0

peak commit: 15199 MB


xcl-smoke v1

commit: 16bcf5bffc5e86475913da8c0669719d71fa7659

gpu: NVIDIA GeForce GTX 1660 SUPER

title: retail_title

seconds: 60

exit: 0x0

frames shown: 647 (PresentX 647)

presents per 2 s (last 3): 47 44 40

device removals: 0

crashes: 0

peak commit: 15195 MB

Not tested

  • AMD / native wave64 GPUs, Linux/Wine, and extended gameplay past the 60 s smoke window

AI use

  • Antigravity with Gemini 4 Neon: analyzed the issue, wrote the fix, tests, and PR description; reviewed by author.
<!-- greyfinch-sync:ivall/xcl:issue:6587439869 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1531). Originally posted by [OtavioTadeu](https://github.com/OtavioTadeu) on 2026-11-24T17:18:50Z. --- Makes `XGameSaveSubmitUpdate` (`gamesave::apply`) all-or-nothing by staging writes into `~xcltmp.*` temp files, backing up existing files, and rolling back on any failure so partial updates cannot corrupt a save container. Fixes #324. **What is in it** - `crates/xcl/src/hle/xgameruntime/gamesave.rs`: coalesce per-blob operations, stage and sync writes to sibling `~xcltmp.*` files, back up existing targets before replace/delete, roll back in reverse order on error, and add rollback/coalescing tests **Tested** - NVIDIA GeForce GTX 1660 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600G, Windows 11 build 26200, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), rustc 1.100.0 (`stable-x86_64-pc-windows-msvc`), debug build - `cargo test --workspace -- --test-threads=4`: 777 passed, 0 failed, 41 ignored (SKIPPED GPU tests: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask` [no wave64], `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware` [no wave64], `heap_window_out_of_memory_falls_back_to_the_switch_form` [no heap windows]) - `cargo test -p xcl --lib gamesave`: 11 passed, 0 failed **Regression run** - `scripts/smoke.ps1 -Game retail_title -Seconds 60` (`main` baseline vs PR head on NVIDIA GeForce GTX 1660 SUPER): ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: NVIDIA GeForce GTX 1660 SUPER title: retail_title seconds: 60 exit: 0x0 frames shown: 631 (PresentX 631) presents per 2 s (last 3): 47 47 49 device removals: 0 crashes: 0 peak commit: 15199 MB ``` ``` xcl-smoke v1 commit: 16bcf5bffc5e86475913da8c0669719d71fa7659 gpu: NVIDIA GeForce GTX 1660 SUPER title: retail_title seconds: 60 exit: 0x0 frames shown: 647 (PresentX 647) presents per 2 s (last 3): 47 44 40 device removals: 0 crashes: 0 peak commit: 15195 MB ``` **Not tested** - AMD / native wave64 GPUs, Linux/Wine, and extended gameplay past the 60 s smoke window **AI use** - Antigravity with Gemini 4 Neon: analyzed the issue, wrote the fix, tests, and PR description; reviewed by author.
GonZiin commented 2026-11-24 18:08:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by GonZiin on 2026-11-24T17:32:39Z.

Review: COMMENTED


The new BTreeMap<PathBuf, ...> can reverse updates that differ only in case on Windows. enc preserves ASCII case, so the map keeps slot and SLOT as separate keys and sorts SLOT first. In a case-insensitive directory both paths resolve to the same blob, so the last submitted operation loses.

Tested

  • Windows 11 Pro build 26300, Ryzen 7 7800X3D, Rust 1.100.0 MSVC, debug. I added a temporary probe in an isolated checkout and ran cargo test -p xcl --lib review_case_aliases_preserve_update_order -- --nocapture. The probe verified that the temporary directory resolves both cases to the same file before calling apply.
  • Write slot = "first", then write SLOT = "last". Base 9e3831e1f570d3646e53ab753b19ec07eb8f1485 left "last". Head 16bcf5bffc5e86475913da8c0669719d71fa7659 left "first".
  • Write slot, then delete SLOT. The base removed the blob. The head kept it. Both revisions returned S_OK.

Please preserve submission order for operations that can resolve to the same on-disk blob and cover the write/write and write/delete cases.

Not tested

Case-sensitive directories and retail titles.

AI use

Codex (gpt-6.2-sol) reviewed the ordering, wrote and ran the probe, and drafted this review.

<!-- greyfinch-sync:ivall/xcl:review:6044248394 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1531#pullrequestreview-6044248394). Originally posted by [GonZiin](https://github.com/GonZiin) on 2026-11-24T17:32:39Z. **Review:** COMMENTED --- The new `BTreeMap<PathBuf, ...>` can reverse updates that differ only in case on Windows. `enc` preserves ASCII case, so the map keeps `slot` and `SLOT` as separate keys and sorts `SLOT` first. In a case-insensitive directory both paths resolve to the same blob, so the last submitted operation loses. **Tested** - Windows 11 Pro build 26300, Ryzen 7 7800X3D, Rust 1.100.0 MSVC, debug. I added a temporary probe in an isolated checkout and ran `cargo test -p xcl --lib review_case_aliases_preserve_update_order -- --nocapture`. The probe verified that the temporary directory resolves both cases to the same file before calling `apply`. - Write `slot = "first"`, then write `SLOT = "last"`. Base `9e3831e1f570d3646e53ab753b19ec07eb8f1485` left `"last"`. Head `16bcf5bffc5e86475913da8c0669719d71fa7659` left `"first"`. - Write `slot`, then delete `SLOT`. The base removed the blob. The head kept it. Both revisions returned `S_OK`. Please preserve submission order for operations that can resolve to the same on-disk blob and cover the write/write and write/delete cases. **Not tested** Case-sensitive directories and retail titles. **AI use** Codex (`gpt-6.2-sol`) reviewed the ordering, wrote and ran the probe, and drafted this review.
dcastell1 commented 2026-11-24 18:09:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T17:34:16Z.


Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@9e3831e (baseline 776 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
777 passed; 0 failed; 41 ignored   (exit 0)

One more than the baseline; staging and rolling back a failed XGameSaveSubmit is covered and green.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it. (The PR is a draft; this is the suite as it stands.)

<!-- greyfinch-sync:ivall/xcl:comment:7139391275 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1531#issuecomment-7139391275). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T17:34:16Z. --- Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on `main@9e3831e` (baseline **776 passed, 0 failed, 41 ignored** on this box): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 777 passed; 0 failed; 41 ignored (exit 0) ``` One more than the baseline; staging and rolling back a failed `XGameSaveSubmit` is covered and green. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it. (The PR is a draft; this is the suite as it stands.)
DavidM1911 commented 2026-11-24 19:07:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:05:51Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141592425 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1531#issuecomment-7141592425). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T19:05:51Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
upstream-sync closed this pull request 2026-11-24 21:06:26 +00:00
throny commented 2026-11-24 21:08:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-24T19:38:12Z.


Two contributors checked independently and found that this PR makes the same change as #543 (for #324): #1607, group D10. They suggest keeping #543. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps.

This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7142377986 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1531#issuecomment-7142377986). Originally posted by [throny](https://github.com/throny) on 2026-11-24T19:38:12Z. --- <!-- xcl-1607-hint:D10 --> Two contributors checked independently and found that this PR makes the same change as #543 (for #324): #1607, group D10. They suggest keeping #543. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps. This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
ivall commented 2026-11-24 21:09:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-24T20:42:35Z.


Closing this as a duplicate: #543 makes the same change and was opened first (an XGameSave update is staged first and rolled back when a part of it fails). It stays open and is the one that will be reviewed and merged.

This says nothing about the quality of the code here. I compared the two diffs; the pair was also found by independent checks in #1607. If this PR covers a case #543 does not, or #543 is closed without being merged, say so and I'll reopen it. A test that is only here is welcome on #543.

Thank you for the work.

AI use: Claude Code (Claude Opus 5.5) compared the diffs and wrote this comment; the decision is the maintainer's.

<!-- greyfinch-sync:ivall/xcl:comment:7143950793 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1531#issuecomment-7143950793). Originally posted by [ivall](https://github.com/ivall) on 2026-11-24T20:42:35Z. --- Closing this as a duplicate: #543 makes the same change and was opened first (an XGameSave update is staged first and rolled back when a part of it fails). It stays open and is the one that will be reviewed and merged. This says nothing about the quality of the code here. I compared the two diffs; the pair was also found by independent checks in #1607. If this PR covers a case #543 does not, or #543 is closed without being merged, say so and I'll reopen it. A test that is only here is welcome on #543. Thank you for the work. AI use: Claude Code (Claude Opus 5.5) compared the diffs and wrote this comment; the decision is the maintainer's.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1521
No description provided.