Title memory by address: stop reaching the 3 GiB cap #198

Open
github-bot wants to merge 1 commit from github-bot/gh-198 into amd AGit
Owner

@⁠mahhnameisjeff on GitHub · 2026-12-04 10:57 UTC · original
mahhnameisjeff:amd-memory-page-reclaim → amd · +189 −15 · 1 files · 1 commits · open

Title memory by address: stop reaching the 3 GiB cap (port of ReVIctory #33)

This is a port of ReVIctory PR 33 by saltdam36 (merged there) to the amd branch. Its replaced() comes from Darner (darner-gpu/src/memory.rs, GPL-3.0), as in the original. Only crates/jaxe-gpu/src/memory.rs changes. The original diff does not apply as it is (this branch has no fault sink, and its pages are kept as (copy, at)), so it was carried over by hand.

What was wrong

With ray tracing on, the pages held for "title memory by address" grow until they reach MOST (3 GiB). After that no pages are taken, the ray-tracing programs read zeros, and frame times get much worse.

Seen on an RX 6700 XT (Series X, ray tracing on, amd as of 0902398) in an hour of play:

  • held pages went from 812 MB at the start to 3,072 MB at 56 minutes, never going down, and then title memory by address: no more pages are taken; others read zeros MOST=49152
  • of the ~47,000 pages that filled it, 42,343 came for the builder's root views ("others" in the memory report line); 29,024 packed structures went in that time, but these pages did not go with them
  • in the same stretch the GPU time per frame went from ~30 ms to 110–155 ms, and the run ended in a crash with system commit nearly used up (issues #133 and #119 look like the same thing)

What is changed

Three parts, as in the original:

  1. Reclaim. A page taken for the builder's root view before the packed structure has streamed in remembers the view address. If a structure lands there, the page is the structure's own (also those past its end), and goes back with it in gone.
  2. Replacement in place. When a packed structure gives way to another at the same address (land, header changed), its pages stay where they are (replaced). Given back and placed again, they would go to other places in the arenas after the submission had already asked the write watch.
  3. Optional release. JAXE_MEMORY_EVICT_FRAMES=<n> (off by default) gives back pages that are only read once no list has named them for n frames, while more than JAXE_MEMORY_EVICT_ABOVE_MB (default 2048) is held. A page given back that a shader still reaches comes back through the fault path the frame after, whatever FAULTS_ALL says.

The memory report line now also says how many structures were replaced, pages given back, free pages, pages taken over by a structure, and pages let go and asked for again.

Results

Same machine, same save point, 36 minutes, with JAXE_MEMORY_EVICT_FRAMES=600:

before with this
held at 30 min 1,943 MB, still growing 2,047 MB, flat from 25 min on
reached the 3 GiB cap yes, at 56 min no
pages given back with their structure 0 43,831
pages taken over by a structure – 8,525
read-only pages let go / asked for again – 29,495 / 4,279
GPU collapse to 4 fps / crash yes no, and played past where the earlier run crashed

Not measured: how long the reclaim alone (without the release switch) stays under the cap on this branch. The original PR has the same note.

Testing

  • cargo test -p jaxe-gpu -- memory:: passes
  • diag build, 36 minutes of play as above

🤖 Generated with Claude Code

**@⁠mahhnameisjeff** on GitHub · 2026-12-04 10:57 UTC · [original](https://github.com/eikkapine/jaxe/pull/198) `mahhnameisjeff:amd-memory-page-reclaim` → `amd` · +189 −15 · 1 files · 1 commits · open ## Title memory by address: stop reaching the 3 GiB cap (port of ReVIctory #33) This is a port of [ReVIctory PR 33](https://github.com/ReTerryDavis/ReVIctory/pull/33) by saltdam36 (merged there) to the `amd` branch. Its `replaced()` comes from Darner (`darner-gpu/src/memory.rs`, GPL-3.0), as in the original. Only `crates/jaxe-gpu/src/memory.rs` changes. The original diff does not apply as it is (this branch has no fault sink, and its pages are kept as `(copy, at)`), so it was carried over by hand. ### What was wrong With ray tracing on, the pages held for "title memory by address" grow until they reach `MOST` (3 GiB). After that no pages are taken, the ray-tracing programs read zeros, and frame times get much worse. Seen on an RX 6700 XT (Series X, ray tracing on, `amd` as of 0902398) in an hour of play: - held pages went from 812 MB at the start to 3,072 MB at 56 minutes, never going down, and then `title memory by address: no more pages are taken; others read zeros MOST=49152` - of the ~47,000 pages that filled it, 42,343 came for the builder's root views ("others" in the memory report line); 29,024 packed structures went in that time, but these pages did not go with them - in the same stretch the GPU time per frame went from ~30 ms to 110–155 ms, and the run ended in a crash with system commit nearly used up (issues #133 and #119 look like the same thing) ### What is changed Three parts, as in the original: 1. **Reclaim.** A page taken for the builder's root view before the packed structure has streamed in remembers the view address. If a structure lands there, the page is the structure's own (also those past its end), and goes back with it in `gone`. 2. **Replacement in place.** When a packed structure gives way to another at the same address (`land`, header changed), its pages stay where they are (`replaced`). Given back and placed again, they would go to other places in the arenas after the submission had already asked the write watch. 3. **Optional release.** `JAXE_MEMORY_EVICT_FRAMES=<n>` (off by default) gives back pages that are only read once no list has named them for `n` frames, while more than `JAXE_MEMORY_EVICT_ABOVE_MB` (default 2048) is held. A page given back that a shader still reaches comes back through the fault path the frame after, whatever `FAULTS_ALL` says. The memory report line now also says how many structures were replaced, pages given back, free pages, pages taken over by a structure, and pages let go and asked for again. ### Results Same machine, same save point, 36 minutes, with `JAXE_MEMORY_EVICT_FRAMES=600`: | | before | with this | |---|---|---| | held at 30 min | 1,943 MB, still growing | 2,047 MB, flat from 25 min on | | reached the 3 GiB cap | yes, at 56 min | no | | pages given back with their structure | 0 | 43,831 | | pages taken over by a structure | – | 8,525 | | read-only pages let go / asked for again | – | 29,495 / 4,279 | | GPU collapse to 4 fps / crash | yes | no, and played past where the earlier run crashed | Not measured: how long the reclaim alone (without the release switch) stays under the cap on this branch. The original PR has the same note. ### Testing - `cargo test -p jaxe-gpu -- memory::` passes - diag build, 36 minutes of play as above 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Pages taken for the builder's root view before the packed structure
streamed in were held as ordinary view pages and never given back, so
the pages held for title memory by address grew to MOST (3 GiB) and
everything after read zeros. They now remember the view address, become
the structure's own when it lands there (also those past its end), and
go back with it. A structure replaced by another at the same address
keeps its pages in place (Darner's `replaced`). Optional release of
read-only pages unnamed for JAXE_MEMORY_EVICT_FRAMES frames while more
than JAXE_MEMORY_EVICT_ABOVE_MB (2048) is held; off by default.

Ported from ReVIctory #33 by saltdam36.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 11:02:25 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/198/head:github-bot/gh-198'
git switch 'github-bot/gh-198'

Merge

Merge the changes and update on Forgejo.
git switch 'amd'
git merge --no-ff 'github-bot/gh-198'
git switch 'github-bot/gh-198'
git rebase 'amd'
git switch 'amd'
git merge --ff-only 'github-bot/gh-198'
git switch 'github-bot/gh-198'
git rebase 'amd'
git switch 'amd'
git merge --no-ff 'github-bot/gh-198'
git switch 'amd'
git merge --squash 'github-bot/gh-198'
git switch 'amd'
git merge --ff-only 'github-bot/gh-198'
git switch 'amd'
git merge 'github-bot/gh-198'
git push origin 'amd'
This discussion has been locked. Commenting is limited to contributors.
No description provided.