startup: snapshot pool totals and per-reason memory SRV overflow #3480

Merged
Leyukaka merged 1 commit from upstream-pr/3480 into main 2026-11-30 08:46:09 +00:00
Leyukaka commented 2026-11-29 17:09:22 +00:00 (Migrated from github.com)

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


Refs #3477 (items 2 and 4; items 1 and 3 come in a separate PR).

Counting and logging only. Allocation and refusal decisions are unchanged, and both refusal logs are still limited to 8 lines.

Snapshot pool totals (item 2)

reserve_upload_ring counted reservations, bytes and refusals for the upload ring only. The guest memory input snapshot pool now has its own SnapshotPoolTotals (upload_reservation.h), updated under allocator_lock.

The periodic x2w-render upload ring: line gains a suffix:

...; snapshot pool: used N bytes, high-water N bytes, chunks N, reserved N bytes in N reservations, refusals (invalid_size N, no_unused_capacity N, no_device N, create_failed N, map_failed N, bookkeeping_failed N)
  • used: allocated prefixes of all chunks; a chunk's bytes are subtracted when it is recycled.
  • high-water: peak of used.
  • reserved, reservations: cumulative.
  • refusals: cumulative, one counter per cause. Every refusal is counted, including those past the 8 logged lines and the zero or oversized requests, which stay silent in the log as before.

The ring counters move from the note_reserved lambda into finish(), which runs on the same success paths. The snapshot pool reservation refused line keeps its text and its limit of 8.

Memory SRV census: calls past the shape table, per reason (item 4)

Once the 128-entry shape table is full, refusals of new shapes only added to one total. They are now also counted per reason, and the report ends with one more line when that total is non-zero:

x2w-d3d12 memory SRV refusals past the shape table (slot 70): unsupported_description=5 buffer_unavailable=2

The per-reason counts sum to the existing calls past the shape table total. The table size and its key are unchanged. The report line buffer grows from 1024 to 1534 bytes.

Tests

Base c4b8a41b, preset dev:

ctest -R '^(upload_reservation|startup_snapshot_pool_totals|startup_memory_srv_census|startup_memory_srv_report)$'

4/4 passed.

  • startup_snapshot_pool_totals (new, upload_reservation_check --snapshot-pool-totals): tail reservations, a recycled chunk, the 8-line limit shared across causes, and the exact summary text.
  • startup_memory_srv_census (extended): the overflow line, its per-reason counts, and periodic reports when only overflow counts changed.

Mutations, each rebuilt and run:

Mutation Failing test
refusals counted only while fewer than 8 are logged startup_snapshot_pool_totals
recycled bytes not subtracted from used startup_snapshot_pool_totals
high-water overwritten at each reservation startup_snapshot_pool_totals
per-reason overflow increment removed startup_memory_srv_census
all overflow counted under one reason startup_memory_srv_census
repeat of a kept shape counted as overflow once the table is full startup_memory_srv_census

Merges cleanly with #3469 and #3466 (git merge-tree).

Not covered

  • The choice of refusal cause inside reserve_upload_ring at runtime and the periodic line itself are not exercised by a test; the tests cover SnapshotPoolTotals and the census class.
  • used counts chunk prefixes until the chunk is recycled, including chunks whose fences have completed.
  • The snapshot refusal log line still says no unused capacity for every cause; the cause is only in the counters.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5553070553 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3480). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T17:09:22Z. --- Refs #3477 (items 2 and 4; items 1 and 3 come in a separate PR). Counting and logging only. Allocation and refusal decisions are unchanged, and both refusal logs are still limited to 8 lines. ## Snapshot pool totals (item 2) `reserve_upload_ring` counted reservations, bytes and refusals for the upload ring only. The guest memory input snapshot pool now has its own `SnapshotPoolTotals` (`upload_reservation.h`), updated under `allocator_lock`. The periodic `x2w-render upload ring:` line gains a suffix: ``` ...; snapshot pool: used N bytes, high-water N bytes, chunks N, reserved N bytes in N reservations, refusals (invalid_size N, no_unused_capacity N, no_device N, create_failed N, map_failed N, bookkeeping_failed N) ``` - `used`: allocated prefixes of all chunks; a chunk's bytes are subtracted when it is recycled. - `high-water`: peak of `used`. - `reserved`, `reservations`: cumulative. - `refusals`: cumulative, one counter per cause. Every refusal is counted, including those past the 8 logged lines and the zero or oversized requests, which stay silent in the log as before. The ring counters move from the `note_reserved` lambda into `finish()`, which runs on the same success paths. The `snapshot pool reservation refused` line keeps its text and its limit of 8. ## Memory SRV census: calls past the shape table, per reason (item 4) Once the 128-entry shape table is full, refusals of new shapes only added to one total. They are now also counted per reason, and the report ends with one more line when that total is non-zero: ``` x2w-d3d12 memory SRV refusals past the shape table (slot 70): unsupported_description=5 buffer_unavailable=2 ``` The per-reason counts sum to the existing `calls past the shape table` total. The table size and its key are unchanged. The report line buffer grows from 1024 to 1534 bytes. ## Tests Base `c4b8a41b`, preset `dev`: ``` ctest -R '^(upload_reservation|startup_snapshot_pool_totals|startup_memory_srv_census|startup_memory_srv_report)$' ``` 4/4 passed. - `startup_snapshot_pool_totals` (new, `upload_reservation_check --snapshot-pool-totals`): tail reservations, a recycled chunk, the 8-line limit shared across causes, and the exact summary text. - `startup_memory_srv_census` (extended): the overflow line, its per-reason counts, and periodic reports when only overflow counts changed. Mutations, each rebuilt and run: | Mutation | Failing test | |---|---| | refusals counted only while fewer than 8 are logged | `startup_snapshot_pool_totals` | | recycled bytes not subtracted from `used` | `startup_snapshot_pool_totals` | | high-water overwritten at each reservation | `startup_snapshot_pool_totals` | | per-reason overflow increment removed | `startup_memory_srv_census` | | all overflow counted under one reason | `startup_memory_srv_census` | | repeat of a kept shape counted as overflow once the table is full | `startup_memory_srv_census` | Merges cleanly with #3469 and #3466 (`git merge-tree`). ## Not covered - The choice of refusal cause inside `reserve_upload_ring` at runtime and the periodic line itself are not exercised by a test; the tests cover `SnapshotPoolTotals` and the census class. - `used` counts chunk prefixes until the chunk is recycled, including chunks whose fences have completed. - The snapshot refusal log line still says `no unused capacity` for every cause; the cause is only in the counters.
lukaslw-lab commented 2026-11-30 08:34:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T08:34:14Z.

Review: APPROVED


Reviewed d4ac8de4 by reading the diff; not built or run.

Verdict: approve. Counting only, and the totals stay consistent with the chunk state. No MUST.

  • used is right because reuse_upload_chunk is the only place a chunk's used is reset (upload_reservation.h:188). The release-at-submit path (note_submits, release_upload_chunks_at_submit) changes holds and generations, not used. The recycled reservation is counted once: note_reserved(rounded, recycled), then reserve_upload_chunk is called without totals.
  • Ring counters: finish() runs on exactly the four success paths that used to call note_reserved. The ring refusal log keeps its own limit of 8, so splitting the old shared refused[2] changes nothing.
  • Census overflow: more_shape_reasons_ has memory_srv_reason_count entries, one fewer than reasons_. That is safe, because the overflow branch is reached only through memory_srv_reason_has_shape, which requires reason < memory_srv_reason_count.
  • Line lengths: log() formats into 1536 bytes with 2 kept for CRLF, so the census buffer of 1534 is exactly its maximum. The upload-ring line with the new suffix stays well under it.
  • NIT: refusal already holds the cause at the log call (d3d12_xs_device.cpp:2871), so the line could name it instead of always saying no unused capacity. That would close the third "Not covered" item.

Tests: startup_snapshot_pool_totals covers tail, second chunk, in-flight and recycle, the shared 8-line limit and the exact summary text. The census check covers overflow per reason and overflow-only periodic reports, and the six mutations show both catch their target. CI did not run them: neither upload_reservation_check nor the census tests are in the pr preset's list, and /O2 was skipped on the PR.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6108963034 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3480#pullrequestreview-6108963034). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-30T08:34:14Z. **Review:** APPROVED --- Reviewed `d4ac8de4` by reading the diff; not built or run. **Verdict: approve.** Counting only, and the totals stay consistent with the chunk state. No MUST. - `used` is right because `reuse_upload_chunk` is the only place a chunk's `used` is reset (`upload_reservation.h:188`). The release-at-submit path (`note_submits`, `release_upload_chunks_at_submit`) changes holds and generations, not `used`. The recycled reservation is counted once: `note_reserved(rounded, recycled)`, then `reserve_upload_chunk` is called without totals. - Ring counters: `finish()` runs on exactly the four success paths that used to call `note_reserved`. The ring refusal log keeps its own limit of 8, so splitting the old shared `refused[2]` changes nothing. - Census overflow: `more_shape_reasons_` has `memory_srv_reason_count` entries, one fewer than `reasons_`. That is safe, because the overflow branch is reached only through `memory_srv_reason_has_shape`, which requires `reason < memory_srv_reason_count`. - Line lengths: `log()` formats into 1536 bytes with 2 kept for CRLF, so the census buffer of 1534 is exactly its maximum. The upload-ring line with the new suffix stays well under it. - **NIT:** `refusal` already holds the cause at the log call (`d3d12_xs_device.cpp:2871`), so the line could name it instead of always saying `no unused capacity`. That would close the third "Not covered" item. Tests: `startup_snapshot_pool_totals` covers tail, second chunk, in-flight and recycle, the shared 8-line limit and the exact summary text. The census check covers overflow per reason and overflow-only periodic reports, and the six mutations show both catch their target. CI did not run them: neither `upload_reservation_check` nor the census tests are in the `pr` preset's list, and `/O2` was skipped on the PR.
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!3480
No description provided.