fix(xgameruntime): cheaper XGameSave quota and single submit per update #17

Manually merged
github merged 1 commit from gh-pr/17/head into gh-pr/17/base 2026-11-26 19:14:11 +00:00
Owner

@⁠Callimann8 on GitHub · 2026-11-21 12:38 UTC · original
Callimann8:claude/project-thread-ivz8wb → main · +102 −23 · 3 files · 1 commits · merged 2026-11-21 12:45 UTC

What

Follow-up to #14 for the two non-blocking review points.

  • Quota without a full re-read. Used (behind XGameSaveGetRemainingQuota* and the quota check in submit) no longer loads every container with its blob data. A new StoredBlobBytes opens each .xgs file, reads the header and each blob's name length and data length, and seeks past the names and data. A file that does not parse still stops with the same AbxUnsupported. LoadAll and Used share a ForEachContainer enumeration.
  • Second submit on one update. XGameSaveUpdate::submitted is now std::atomic<bool> and is set with exchange(true) when XGameSaveSubmitUpdate or XGameSaveSubmitUpdateAsync is called, not after the write finishes. A second submit (sync or async) or a XGameSaveSubmitBlobWrite/Delete while an asynchronous submit is pending now returns E_GS_HANDLE_EXPIRED, instead of starting a second write or changing changes while the worker reads it. A submit that fails (or an async submit that cannot start) clears the flag, so the update stays usable as before.
  • Debt fragment fix-xgamesave-resubmit.md records the pending-submit behaviour under the existing "behaviour the documentation does not state" entry.

Tested

Cross-built ab_xgameruntime and fake_title with MinGW-w64 (GCC 13, posix threads) on Linux: no errors or warnings. fake_title gains two checks: a second XGameSaveSubmitUpdateAsync while the first is pending, and another after it completed, both expect E_GS_HANDLE_EXPIRED. Not run on Windows: the e2e game-save test runs on CI. python tools/check_conventions.py and python tools/debt_fold.py --check pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • python tools/check_conventions.py passes (no comments in code, one declaration per export, Conventional Commit subjects)
  • Unimplemented paths stop (AbxNotImplemented / AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragment
  • Known gaps added, changed or removed through docs/dev/debt/changes/<branch>.md
  • Generic behaviour, not specific to one title
  • No game files, keys, notes or logs added to the repository
  • Depends on: none (#14 is merged)
  • Fixes: none
  • Unblocks: none
  • Source of behaviour: E_GS_HANDLE_EXPIRED from the public GDK XGameSave documentation; the pending-submit case is not documented and is listed in the debt fragment
  • AI-assisted: yes
**@⁠Callimann8** on GitHub · 2026-11-21 12:38 UTC · [original](https://github.com/Dark3581/AnyBox/pull/17) `Callimann8:claude/project-thread-ivz8wb` → `main` · +102 −23 · 3 files · 1 commits · merged 2026-11-21 12:45 UTC ### What Follow-up to #14 for the two non-blocking review points. - **Quota without a full re-read.** `Used` (behind `XGameSaveGetRemainingQuota*` and the quota check in submit) no longer loads every container with its blob data. A new `StoredBlobBytes` opens each `.xgs` file, reads the header and each blob's name length and data length, and seeks past the names and data. A file that does not parse still stops with the same `AbxUnsupported`. `LoadAll` and `Used` share a `ForEachContainer` enumeration. - **Second submit on one update.** `XGameSaveUpdate::submitted` is now `std::atomic<bool>` and is set with `exchange(true)` when `XGameSaveSubmitUpdate` or `XGameSaveSubmitUpdateAsync` is called, not after the write finishes. A second submit (sync or async) or a `XGameSaveSubmitBlobWrite`/`Delete` while an asynchronous submit is pending now returns `E_GS_HANDLE_EXPIRED`, instead of starting a second write or changing `changes` while the worker reads it. A submit that fails (or an async submit that cannot start) clears the flag, so the update stays usable as before. - Debt fragment `fix-xgamesave-resubmit.md` records the pending-submit behaviour under the existing "behaviour the documentation does not state" entry. ### Tested Cross-built `ab_xgameruntime` and `fake_title` with MinGW-w64 (GCC 13, posix threads) on Linux: no errors or warnings. `fake_title` gains two checks: a second `XGameSaveSubmitUpdateAsync` while the first is pending, and another after it completed, both expect `E_GS_HANDLE_EXPIRED`. Not run on Windows: the e2e game-save test runs on CI. `python tools/check_conventions.py` and `python tools/debt_fold.py --check` pass. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] `python tools/check_conventions.py` passes (no comments in code, one declaration per export, Conventional Commit subjects) - [x] Unimplemented paths stop (`AbxNotImplemented` / `AbxUnsupported`); silent stubs are listed under Silent stubs through a debt fragment - [x] Known gaps added, changed or removed through `docs/dev/debt/changes/<branch>.md` - [x] Generic behaviour, not specific to one title - [x] No game files, keys, notes or logs added to the repository - [x] Depends on: none (#14 is merged) - [x] Fixes: none - [x] Unblocks: none - [x] Source of behaviour: `E_GS_HANDLE_EXPIRED` from the public GDK XGameSave documentation; the pending-submit case is not documented and is listed in the debt fragment - [x] AI-assisted: yes
Quota usage now reads only each container's header and blob sizes,
skipping blob data, instead of loading every save. An update is marked
submitted when XGameSaveSubmitUpdate or XGameSaveSubmitUpdateAsync is
called, so a second submit or a change while an asynchronous submit is
pending returns E_GS_HANDLE_EXPIRED; a failed submit reopens the update.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YZ2Pr8UXYtQrsE3cZZ4WyY
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:14:10 +00:00
github manually merged commit 94926edac5 into gh-pr/17/base 2026-11-26 19:14:11 +00:00
Author
Owner

@⁠Dark3581 on GitHub · 2026-11-21 12:44 UTC · original · approved these changes

Reviewed — looks good

Both follow-ups from #14 are done. The quota walk reads the same layout Store writes, and a damaged file still stops with the same report.

What I ran

Head 94926ed, based on current main (3f460fd). MinGW (WinLibs GCC 15.2 UCRT, Ninja, Release) on Windows 10, clean build directory.

Results

Check Result Note
MinGW full build passed no warnings
CTest passed 42/42
e2e_gamesave repeated passed 25 runs, no failure
Quota probe, valid files passed one container gives 4 bytes used, two containers give 9 (5 + 0); .txt and update.tmp in the folder are not counted
Quota probe, damaged files passed truncated, trailing byte, name length 0xFFFFFFFF, blob count 0xFFFFFFFF and an empty .xgs each stop as unsupported in XGameSaveGetRemainingQuota (GameSave.cpp:358), same message as Load
check_conventions.py passed
debt_fold.py --check passed 11 fragments apply cleanly
CI passed all jobs green

Findings

Blocking

None.

Non-blocking

  • core/libs/tests/FakeTitle.cpp:835: the "while pending" check passes whether the first submit is still running or has already finished, because the flag stays set after a successful submit. That is the right behaviour; the check just does not prove that the pending case is reached. A worker held on a gate, as e2e_async does, would pin it down, if you want to.
  • GameSave.cpp, XGameSaveCloseUpdate: closing an update while its asynchronous submit is still running frees the update the worker is reading. This was already the case before this PR, and the GDK documentation expects the title to wait for completion first. It's worth a debt line, or a stop, in a later PR.

Not verified

On a console title: how the GDK handles a second submit while one is still pending. This is recorded in the debt fragment.

Thanks, this keeps quota checks cheap as saves grow.

**@⁠Dark3581** on GitHub · 2026-11-21 12:44 UTC · [original](https://github.com/Dark3581/AnyBox/pull/17#pullrequestreview-6005266827) · **approved these changes** # Reviewed — looks good Both follow-ups from #14 are done. The quota walk reads the same layout `Store` writes, and a damaged file still stops with the same report. ## What I ran Head `94926ed`, based on current `main` (`3f460fd`). MinGW (WinLibs GCC 15.2 UCRT, Ninja, Release) on Windows 10, clean build directory. ## Results | Check | Result | Note | | - | - | - | | MinGW full build | passed | no warnings | | CTest | passed | 42/42 | | `e2e_gamesave` repeated | passed | 25 runs, no failure | | Quota probe, valid files | passed | one container gives 4 bytes used, two containers give 9 (5 + 0); `.txt` and `update.tmp` in the folder are not counted | | Quota probe, damaged files | passed | truncated, trailing byte, name length `0xFFFFFFFF`, blob count `0xFFFFFFFF` and an empty `.xgs` each stop as `unsupported` in `XGameSaveGetRemainingQuota` (`GameSave.cpp:358`), same message as `Load` | | `check_conventions.py` | passed | | | `debt_fold.py --check` | passed | 11 fragments apply cleanly | | CI | passed | all jobs green | ## Findings ### Blocking None. ### Non-blocking - `core/libs/tests/FakeTitle.cpp:835`: the "while pending" check passes whether the first submit is still running or has already finished, because the flag stays set after a successful submit. That is the right behaviour; the check just does not prove that the pending case is reached. A worker held on a gate, as `e2e_async` does, would pin it down, if you want to. - `GameSave.cpp`, `XGameSaveCloseUpdate`: closing an update while its asynchronous submit is still running frees the update the worker is reading. This was already the case before this PR, and the GDK documentation expects the title to wait for completion first. It's worth a debt line, or a stop, in a later PR. ## Not verified On a console title: how the GDK handles a second submit while one is still pending. This is recorded in the debt fragment. Thanks, this keeps quota checks cheap as saves grow.
This discussion has been locked. Commenting is limited to contributors.
No description provided.