compute: publish every compute pack record across numbered parts #3484

Merged
Not-Saii merged 2 commits from upstream-pr/3484 into main 2026-11-30 08:45:07 +00:00
Not-Saii commented 2026-11-29 17:21:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T17:21:50Z.


Fixes #3473. Follows #3091.

compile_dxil --prepare-compute-pack left out every record past 256 MiB. A pack is now written as numbered parts, each under that limit, so every record is published. The shared cache lookup and its 256 MiB cap are unchanged.

Writer (build_compute_frontend_pack)

  • When the next record would cross the limit, a new part is started. Records stay in the sorted request order.
  • Part 0 keeps the name compute-<entry>.pack. Later parts are compute-<entry>.<n>.pack.
  • Every part starts with a 72-byte header: part count, record count, and the id of the next part (zeros in the last part).
  • Part 0 is published under pack_version. Part n > 0 is published under the digest of pack_version and its payload's SHA-256, and the previous part names that id. So the existing lookup refuses a missing, stale or swapped part without hashing a payload twice.
  • Parts are written last to first, with part 0 last. Parts left from an earlier, larger pack are removed before part 0 is published. Nothing is written or removed when every request fails, so an existing pack is kept as before.
  • Only a single record over the limit still fails with invalid compute pack size.
  • pack_version moves to prepared-2.
  • The limit is a writer parameter (part_limit, default compute_pack_part_limit). Only the test lowers it. The command line is unchanged.

Reader (ComputeFrontendPack::load; the runtime caller is unchanged)

  • Loads every part named by the count into one record map.
  • Refuses the whole pack, as it refuses a damaged one today, when:
    • a part is missing, stale or swapped;
    • the part count differs between parts;
    • a key repeats across parts;
    • a part has trailing data;
    • a part file exists past the count.
  • X2W_NATIVE_COMPUTE_PACK still names part 0.

Tests (new native_compute_pack_parts, tests/cmake/native_compute_pack_parts.cmake)

The fixture is 13 source-built requests: 1 prepared and 12 refused. The prepared record sits between refused ones in the sorted order. native_compute_pack_check gains three modes: --build (the writer with a lowered limit), --same (per-key comparison of two packs) and --old (writes a prepared-1 file).

  • Positive.

    • The test sets the limit to the largest record plus the header (9401 bytes here). That gives 3 parts, which match the test's own greedy split exactly.
    • Result: prepared=1 unsupported=12 errors=0.
    • The parts' records, concatenated, are byte-identical to the unlimited pack's.
    • The existing checker accepts the parts against the live frontend (other=0).
    • --same gives the same lookup result for all 13 keys as the one-part pack built by compile_dxil with no limit.
  • Single record over the limit (limit − 1): prepared=0 unsupported=12 errors=1, with exactly one invalid compute pack size.

  • Negative controls. Each is refused with the stated message, and the restored pack loads again:

    Control Message
    missing middle part missing, stale or damaged compute pack
    a valid part 1 from another pack missing, stale or damaged compute pack
    key duplicated into the last part invalid compute pack record
    trailing byte in part 1 trailing compute pack data
    part 1 claims one part more than part 0 invalid compute pack part count
    last part names a next part invalid compute pack part
    stale extra part past the count stale compute pack part, and --build removes it
    prepared-1 pack under this build's revision missing, stale or damaged compute pack, and a rebuild loads
    • Each refusal is matched against the checker's whole stderr line, not a substring.
    • The crafted files are re-chained with correct checksums and ids. The test first checks that its chain writer reproduces the writer's bytes, so each control differs only as intended.
    • A one-part rebuild in the same cache removes the other parts. Its part 0 is byte-identical to the unlimited pack.
  • Revert controls (run locally, not committed):

    • Writer split reverted (a crossing record fails, as before; the limit parameter kept): --build gives prepared=0 unsupported=12 errors=1, with the crossing record reported as invalid compute pack size and left out.
    • prepared-2 reverted to prepared-1: the prepared-1 file passes the version check and is parsed as the new layout. It fails only because a request-key word exceeds the count bound (invalid frontend cache count).
cmake --build --preset dev --target compile_dxil native_compute_pack_check
ctest --preset dev --no-tests=error -R '^native_compute_pack(_parts)?$'

Result: 2/2 passed (native_compute_pack, native_compute_pack_parts). Windows 11 build 26300, MSVC (VS 2022, dev preset), Windows SDK 10.0.26100, Python 3.12. No GPU used. native_compute_pack_hardware was not run. The PR check skips native_* tests, so this local run is the evidence for both until a full workflow run.

Measurement. Counts only. None of my own captures was rerun. The synthetic test above is the evidence. A rerun of the 2,689-request set from #3472, before and after, would show the 28 left-out records published as a second part.

Interaction with #3472 (open). Both change build_compute_frontend_pack.

  • #3472 prepares the records in parallel and then appends them in sorted order, with the size check in the append loop. The split here goes into that append loop: a record that would cross the limit starts a new part instead of becoming an error. Whichever merges second needs a short rebase.
  • #3472 adds unsigned jobs = 1 as the fourth parameter, and this PR adds size_t part_limit there. After both, the checker's --build call must pass jobs explicitly.
  • #3472's doc sentence that records past 256 MiB are "left out" no longer holds after this PR.
  • Memory: the writer now holds every part until it publishes, so the peak is about the size of the whole pack. #3472 already holds every record.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5553178091 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3484). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-29T17:21:50Z. --- Fixes #3473. Follows #3091. `compile_dxil --prepare-compute-pack` left out every record past 256 MiB. A pack is now written as numbered parts, each under that limit, so every record is published. The shared cache `lookup` and its 256 MiB cap are unchanged. **Writer** (`build_compute_frontend_pack`) - When the next record would cross the limit, a new part is started. Records stay in the sorted request order. - Part 0 keeps the name `compute-<entry>.pack`. Later parts are `compute-<entry>.<n>.pack`. - Every part starts with a 72-byte header: part count, record count, and the id of the next part (zeros in the last part). - Part 0 is published under `pack_version`. Part n > 0 is published under the digest of `pack_version` and its payload's SHA-256, and the previous part names that id. So the existing `lookup` refuses a missing, stale or swapped part without hashing a payload twice. - Parts are written last to first, with part 0 last. Parts left from an earlier, larger pack are removed before part 0 is published. Nothing is written or removed when every request fails, so an existing pack is kept as before. - Only a single record over the limit still fails with `invalid compute pack size`. - `pack_version` moves to `prepared-2`. - The limit is a writer parameter (`part_limit`, default `compute_pack_part_limit`). Only the test lowers it. The command line is unchanged. **Reader** (`ComputeFrontendPack::load`; the runtime caller is unchanged) - Loads every part named by the count into one record map. - Refuses the whole pack, as it refuses a damaged one today, when: - a part is missing, stale or swapped; - the part count differs between parts; - a key repeats across parts; - a part has trailing data; - a part file exists past the count. - `X2W_NATIVE_COMPUTE_PACK` still names part 0. **Tests** (new `native_compute_pack_parts`, `tests/cmake/native_compute_pack_parts.cmake`) The fixture is 13 source-built requests: 1 prepared and 12 refused. The prepared record sits between refused ones in the sorted order. `native_compute_pack_check` gains three modes: `--build` (the writer with a lowered limit), `--same` (per-key comparison of two packs) and `--old` (writes a `prepared-1` file). - **Positive.** - The test sets the limit to the largest record plus the header (9401 bytes here). That gives 3 parts, which match the test's own greedy split exactly. - Result: `prepared=1 unsupported=12 errors=0`. - The parts' records, concatenated, are byte-identical to the unlimited pack's. - The existing checker accepts the parts against the live frontend (`other=0`). - `--same` gives the same `lookup` result for all 13 keys as the one-part pack built by `compile_dxil` with no limit. - **Single record over the limit** (limit − 1): `prepared=0 unsupported=12 errors=1`, with exactly one `invalid compute pack size`. - **Negative controls.** Each is refused with the stated message, and the restored pack loads again: | Control | Message | |---|---| | missing middle part | `missing, stale or damaged compute pack` | | a valid part 1 from another pack | `missing, stale or damaged compute pack` | | key duplicated into the last part | `invalid compute pack record` | | trailing byte in part 1 | `trailing compute pack data` | | part 1 claims one part more than part 0 | `invalid compute pack part count` | | last part names a next part | `invalid compute pack part` | | stale extra part past the count | `stale compute pack part`, and `--build` removes it | | `prepared-1` pack under this build's revision | `missing, stale or damaged compute pack`, and a rebuild loads | - Each refusal is matched against the checker's whole stderr line, not a substring. - The crafted files are re-chained with correct checksums and ids. The test first checks that its chain writer reproduces the writer's bytes, so each control differs only as intended. - A one-part rebuild in the same cache removes the other parts. Its part 0 is byte-identical to the unlimited pack. - **Revert controls** (run locally, not committed): - Writer split reverted (a crossing record fails, as before; the limit parameter kept): `--build` gives `prepared=0 unsupported=12 errors=1`, with the crossing record reported as `invalid compute pack size` and left out. - `prepared-2` reverted to `prepared-1`: the `prepared-1` file passes the version check and is parsed as the new layout. It fails only because a request-key word exceeds the count bound (`invalid frontend cache count`). ```powershell cmake --build --preset dev --target compile_dxil native_compute_pack_check ctest --preset dev --no-tests=error -R '^native_compute_pack(_parts)?$' ``` Result: 2/2 passed (`native_compute_pack`, `native_compute_pack_parts`). Windows 11 build 26300, MSVC (VS 2022, dev preset), Windows SDK 10.0.26100, Python 3.12. No GPU used. `native_compute_pack_hardware` was not run. The PR check skips `native_*` tests, so this local run is the evidence for both until a full workflow run. **Measurement.** Counts only. None of my own captures was rerun. The synthetic test above is the evidence. A rerun of the 2,689-request set from #3472, before and after, would show the 28 left-out records published as a second part. **Interaction with #3472 (open).** Both change `build_compute_frontend_pack`. - #3472 prepares the records in parallel and then appends them in sorted order, with the size check in the append loop. The split here goes into that append loop: a record that would cross the limit starts a new part instead of becoming an error. Whichever merges second needs a short rebase. - #3472 adds `unsigned jobs = 1` as the fourth parameter, and this PR adds `size_t part_limit` there. After both, the checker's `--build` call must pass `jobs` explicitly. - #3472's doc sentence that records past 256 MiB are "left out" no longer holds after this PR. - Memory: the writer now holds every part until it publishes, so the peak is about the size of the whole pack. #3472 already holds every record. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Leyukaka commented 2026-11-29 17:45:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T17:45:30Z.

Review: APPROVED


Approve at 8d25453a. Reviewed by reading the diff only; nothing was built or run here.

Checked: part naming and the split are deterministic (sorted requests, greedy); a record goes into exactly one part, none lost or duplicated at a boundary; the single-record bound part_limit - 72 - 80 keeps every file within lookup's 256 MiB cap; the next-id chain and the part-past-the-count check refuse a missing, stale or swapped part; the reader and the prepared-2 bump refuse old packs; nothing changes when X2W_NATIVE_COMPUTE_PACK is unset.

Should:

  • tests/native_compute_pack_check.cpp:30 passes the limit as the 4th positional argument, where #3472 adds unsigned jobs = 1. If the rebase misses that call it still compiles (size_t to unsigned) and the limit becomes the thread count. Suggest landing #3472 first, then the signature (requests, cache, entry, jobs, part_limit) with the test passing both.
  • A publish or fs::remove that fails after a later part has been replaced leaves no loadable pack: the old part 0 then names a part whose id differs. That is safe (the load is refused and every request is a miss), but the doc only covers "every input fails"; one sentence would do.

Nits:

  • The loader keeps the records of all parts, so the loaded pack is no longer bounded by one 256 MiB file. The doc could say so.
  • tests/native_compute_pack_check.py:177 matches stale compute pack part as a substring, while the PR body says every refusal is matched against the whole stderr line.
  • lookup compares a part's stored id with the id named by the previous part, but the id is not re-derived from the stored checksum. Hardening only.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6104036967 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3484#pullrequestreview-6104036967). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T17:45:30Z. **Review:** APPROVED --- Approve at `8d25453a`. Reviewed by reading the diff only; nothing was built or run here. Checked: part naming and the split are deterministic (sorted requests, greedy); a record goes into exactly one part, none lost or duplicated at a boundary; the single-record bound `part_limit - 72 - 80` keeps every file within `lookup`'s 256 MiB cap; the next-id chain and the part-past-the-count check refuse a missing, stale or swapped part; the reader and the `prepared-2` bump refuse old packs; nothing changes when `X2W_NATIVE_COMPUTE_PACK` is unset. Should: - `tests/native_compute_pack_check.cpp:30` passes the limit as the 4th positional argument, where #3472 adds `unsigned jobs = 1`. If the rebase misses that call it still compiles (`size_t` to `unsigned`) and the limit becomes the thread count. Suggest landing #3472 first, then the signature `(requests, cache, entry, jobs, part_limit)` with the test passing both. - A publish or `fs::remove` that fails after a later part has been replaced leaves no loadable pack: the old part 0 then names a part whose id differs. That is safe (the load is refused and every request is a miss), but the doc only covers "every input fails"; one sentence would do. Nits: - The loader keeps the records of all parts, so the loaded pack is no longer bounded by one 256 MiB file. The doc could say so. - `tests/native_compute_pack_check.py:177` matches `stale compute pack part` as a substring, while the PR body says every refusal is matched against the whole stderr line. - `lookup` compares a part's stored id with the id named by the previous part, but the id is not re-derived from the stored checksum. Hardening only.
lukaslw-lab commented 2026-11-30 00:29:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T00:29:52Z.


Thanks for taking #3473. A real-data point for it: 4,352 compute requests from one local capture, through the current single-file writer (with #3472), gave 887 prepared, 2,742 unsupported and 723 left out as invalid compute pack size.

Agreed with Leyukaka on the order: #3472 first, then (requests, cache, entry, jobs, part_limit) here.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7265320782 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3484#issuecomment-7265320782). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-30T00:29:52Z. --- Thanks for taking #3473. A real-data point for it: 4,352 compute requests from one local capture, through the current single-file writer (with #3472), gave 887 prepared, 2,742 unsupported and **723 left out** as `invalid compute pack size`. Agreed with Leyukaka on the order: #3472 first, then `(requests, cache, entry, jobs, part_limit)` here.
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
R0Y00/Xbox2Windows!3484
No description provided.