Memory: bound queued host work and reclaim idle staging before world-load allocations fail #2639

Open
opened 2026-11-26 06:14:20 +00:00 by github-bot · 1 comment
Owner

@⁠pickles976 on GitHub · 2026-11-26 04:07 UTC · original

Triage request: goal:world-load (#1833). Let a loader that can finish serially spend longer loading rather than allocate several jobs’ peak scratch space at once. Please start with one measured XCL-owned buffer path, not a replacement allocator or a change to the console memory profile.

Why not just set a process cap? In #1566, a 13,824 MB process cap refused required texture pages during startup; the title died twice at 11.7 s. On our 16 GiB Linux / Wine 11.0 / RTX 4060 Laptop GPU (8 GiB), #1831’s isolated enforcement test assigned a 64 MiB job limit but a 128 MiB commit still succeeded. Neither refusal nor unenforced limits provide backpressure. Separately, a contributor on #542 reported nearly identical ~40 GB commit peaks with 4 vs 15 compiler workers, but ~28 GB with three upload/detile changes together. That makes transient copies worth measuring, not proof they dominate on every 16 GiB host.

Proposed first slice

  1. On the XCL_ACTIVITY tick, expose capacity held by upload/detile staging: reserved but not allocated, active (including fence-pinned), and idle/reusable, with high-water marks. Count backing allocations once, including capacity retained in pools, not views or just payload length. Compare these with process commit, resident memory and local/non-local GPU memory as distinct series. If staging is small at the load peak, publish that result and pick the measured owner instead.
  2. Opt in with e.g. XCL_HOST_STAGING_BUDGET_MIB (unset/0: unchanged; positive MiB converted once to bytes). For participating owners, reserved + active + idle must not exceed the configured bytes. Reserve the job’s peak simultaneous input/output/scratch before materializing it. Reuse an idle allocation or drop reconstructible idle backing before asking for more. Hold the charge through completion, including GPU fences and aliases. Never discard dirty guest data or memory still in use. Releasing a buffer means it is reusable or freed, not a claim that OS RSS immediately fell.
  3. Bound pending descriptors by count as well as payloads by bytes; defer at ingress, not after copying into an unbounded waiting list. Preserve dependency and retirement order. Do not wait holding allocator, queue or submit locks, on a thread needed to retire the work, or while holding a partial reservation needed by another job. Completion, cancellation, failure and device loss must unblock waiters. If one job cannot fit, chunk only when the format permits it; otherwise fail through the existing operation’s error path with owner, required and available bytes. No indefinite retry, partial success, or silently skipped upload.

Fit with existing work. Keep title_memory_mb guest-visible; #1566/#1831 address whole-process commit, #640/#1773 GPU pages and residency. DirectStorage already has XCL_DSTORAGE_MEMORY_BUDGET_MIB and ordered retirement: reuse that policy if integrating it later, with both limits checked in one admission decision, not two blocking reservations. Compiler parallelism (#542/#2624) can be tuned independently; opaque DXC/driver allocations are not enforceable staging bytes. This is not a maximum on RSS, title CRT allocations, worker processes or driver memory. If required live data alone exceeds physical RAM, a longer wait is not a fix.

What would demonstrate it works?

  • Deterministic two-producer fixture: both jobs fit individually but not together. Peak stays within budget, second job makes progress after retirement, and both outputs match the unlimited path byte-for-byte. Force a delayed fence and prove its backing is not recycled early. Exercise idle trim, cancellation, oversize and shutdown with a waiter; none may leak credit or hang. No new gate when unset.
  • Guarded parent/head comparison with identical cache state, inputs and workload: report staging peak, bytes reclaimed, waits/time, process/scope peak, minimum available RAM and last completed load stage. Repeat with cold and warm caches distinguished. On this 16 GiB Wine machine keep the 9 GiB scope, 512 MiB swap ceiling and 2 GiB system headroom guard; don't approach a kernel OOM to demonstrate one. If the stock vkd3d integration (#175) stops the title earlier, report fixture evidence only. Lower staging usage with unchanged total pressure is useful negative evidence, not proof of gameplay.

Maintainer decision requested: does an activity-counter patch for upload/detile staging followed by an opt-in admission patch for the measured owner fit the world-load roadmap?

AI assistance: OpenAI Codex reviewed existing reports and drafted this proposal. The linked Wine cap result is a local fixture; the other XCL load measurements are attributed above. No retail data attached.

**@⁠pickles976** on GitHub · 2026-11-26 04:07 UTC · [original](https://github.com/xcl-dev/xcl/issues/2639) **Triage request: `goal:world-load` (#1833).** Let a loader that can finish serially spend longer loading rather than allocate several jobs’ peak scratch space at once. Please start with one measured XCL-owned buffer path, not a replacement allocator or a change to the console memory profile. **Why not just set a process cap?** In [#1566](https://git.gtahub.st/github/xcl-dev--xcl/issues/1566), a 13,824 MB process cap refused required texture pages during startup; the title died twice at 11.7 s. On our 16 GiB Linux / Wine 11.0 / RTX 4060 **Laptop** GPU (8 GiB), [#1831’s isolated enforcement test](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1831) assigned a 64 MiB job limit but a 128 MiB commit still succeeded. Neither refusal nor unenforced limits provide backpressure. Separately, a contributor [on #542](https://git.gtahub.st/github/xcl-dev--xcl/issues/542) reported nearly identical ~40 GB commit peaks with 4 vs 15 compiler workers, but ~28 GB with three upload/detile changes together. That makes transient copies worth **measuring**, not proof they dominate on every 16 GiB host. **Proposed first slice** 1. On the `XCL_ACTIVITY` tick, expose capacity held by upload/detile staging: reserved but not allocated, active (including fence-pinned), and idle/reusable, with high-water marks. Count backing allocations once, including capacity retained in pools, not views or just payload length. Compare these with process commit, resident memory and local/non-local GPU memory as distinct series. If staging is small at the load peak, publish that result and pick the measured owner instead. 2. Opt in with e.g. `XCL_HOST_STAGING_BUDGET_MIB` (unset/0: unchanged; positive MiB converted once to bytes). For participating owners, **reserved + active + idle must not exceed the configured bytes**. Reserve the job’s peak simultaneous input/output/scratch before materializing it. Reuse an idle allocation or drop reconstructible idle backing before asking for more. Hold the charge through completion, including GPU fences and aliases. Never discard dirty guest data or memory still in use. Releasing a buffer means it is reusable or freed, not a claim that OS RSS immediately fell. 3. Bound pending descriptors by count as well as payloads by bytes; defer at ingress, not after copying into an unbounded waiting list. Preserve dependency and retirement order. Do not wait holding allocator, queue or submit locks, on a thread needed to retire the work, or while holding a partial reservation needed by another job. Completion, cancellation, failure and device loss must unblock waiters. If one job cannot fit, chunk only when the format permits it; otherwise fail through the existing operation’s error path with owner, required and available bytes. No indefinite retry, partial success, or silently skipped upload. **Fit with existing work.** Keep `title_memory_mb` guest-visible; #1566/#1831 address whole-process commit, #640/#1773 GPU pages and residency. DirectStorage already has `XCL_DSTORAGE_MEMORY_BUDGET_MIB` and ordered retirement: reuse that policy if integrating it later, with both limits checked in one admission decision, not two blocking reservations. Compiler parallelism (#542/#2624) can be tuned independently; opaque DXC/driver allocations are not enforceable staging bytes. This is **not** a maximum on RSS, title CRT allocations, worker processes or driver memory. If required live data alone exceeds physical RAM, a longer wait is not a fix. **What would demonstrate it works?** - Deterministic two-producer fixture: both jobs fit individually but not together. Peak stays within budget, second job makes progress after retirement, and both outputs match the unlimited path byte-for-byte. Force a delayed fence and prove its backing is not recycled early. Exercise idle trim, cancellation, oversize and shutdown with a waiter; none may leak credit or hang. No new gate when unset. - Guarded parent/head comparison with identical cache state, inputs and workload: report staging peak, bytes reclaimed, waits/time, process/scope peak, minimum available RAM and last completed load stage. Repeat with cold and warm caches distinguished. On this 16 GiB Wine machine keep the 9 GiB scope, 512 MiB swap ceiling and 2 GiB system headroom guard; don't approach a kernel OOM to demonstrate one. If the stock vkd3d integration (#175) stops the title earlier, report fixture evidence only. Lower staging usage with unchanged total pressure is useful negative evidence, not proof of gameplay. Maintainer decision requested: does an activity-counter patch for upload/detile staging followed by an opt-in admission patch for the measured owner fit the world-load roadmap? AI assistance: OpenAI Codex reviewed existing reports and drafted this proposal. The linked Wine cap result is a local fixture; the other XCL load measurements are attributed above. No retail data attached.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:14:20 +00:00
Author
Owner

@⁠pickles976 on GitHub · 2026-11-26 04:16 UTC · original

Human being here: basically it seems like xcl just allocates memory when the executable asks for it. Instead we should be able to set some limit of how much memory xcl is allowed to use. Requests beyond this point go into a queue, and are realloc'ed when data in memory is no longer needed. I'm not exactly sure what is being loaded during the game's startup, but I am expecting that some of that data is transient, and does not need to live in memory the whole time.

Without xcl enforcing memory limits, the game will always OOM on smaller machines. I am with family for Thanksgiving and running on my gaming laptop with 16GB and this is a hard blocker for running on this machine.

Let me know what you think.

**@⁠pickles976** on GitHub · 2026-11-26 04:16 UTC · [original](https://github.com/xcl-dev/xcl/issues/2639#issuecomment-7182456971) Human being here: basically it seems like `xcl` just allocates memory when the executable asks for it. Instead we should be able to set some limit of how much memory `xcl` is allowed to use. Requests beyond this point go into a queue, and are realloc'ed when data in memory is no longer needed. I'm not exactly sure what is being loaded during the game's startup, but I am expecting that some of that data is transient, and does not need to live in memory the whole time. Without `xcl` enforcing memory limits, the game will always OOM on smaller machines. I am with family for Thanksgiving and running on my gaming laptop with 16GB and this is a hard blocker for running on this machine. Let me know what you think.
This discussion has been locked. Commenting is limited to contributors.
No description provided.