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

Open
mahhnameisjeff wants to merge 1 commit from upstream-pr/198 into amd
mahhnameisjeff commented 2026-12-04 10:57:19 +00:00 (Migrated from github.com)

Imported from eikkapine/jaxe. Originally posted by mahhnameisjeff on 2026-12-04T10:57:19Z.


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

<!-- greyfinch-sync:eikkapine/jaxe:issue:5645153731 --> Imported from [eikkapine/jaxe](https://github.com/eikkapine/jaxe/pull/198). Originally posted by [mahhnameisjeff](https://github.com/mahhnameisjeff) on 2026-12-04T10:57:19Z. --- ## 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)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/198:upstream-pr/198'
git switch 'upstream-pr/198'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'amd'
git merge --no-ff 'upstream-pr/198'
git switch 'upstream-pr/198'
git rebase 'amd'
git switch 'amd'
git merge --ff-only 'upstream-pr/198'
git switch 'upstream-pr/198'
git rebase 'amd'
git switch 'amd'
git merge --no-ff 'upstream-pr/198'
git switch 'amd'
git merge --squash 'upstream-pr/198'
git switch 'amd'
git merge --ff-only 'upstream-pr/198'
git switch 'amd'
git merge 'upstream-pr/198'
git push origin 'amd'
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
eikkapine/jaxe!198
No description provided.