Repository navigation
GPU: skip heap pages whose bytes did not change - #783
Open
naixue2233 wants to merge 2 commits into
Open
naixue2233 wants to merge 2 commits into
naixue2233 wants to merge 2 commits into
Conversation
…k in one call Two costs of the paths a26859f added, on a 3840x2160 window with a 2522 to 4394 draw world frame (RTX 3080, Windows 10, release build). 9376fd6 already took the third (the fingerprint), so that is not here. 1. sync_heaps walked the 1,024 to 2,048 records of every page the kernel called written: 300,000 to 485,000 records a frame, of which 12,000 to 20,000 were new. The kernel marks a page written even when the title put back the bytes it already held, so most of that walk found nothing. The page's bytes are now compared with the ones last read (64 KiB, a few microseconds) and the page's records are skipped when they are the same. 2. copy_back_with wrote every run of changed bytes through the kernel on its own: 53 to 75 MB a frame in runs a handful of bytes long, at 3 to 4 ms/MB. The runs of one copy are contiguous, so they and the gaps between them (the title's bytes as read, so putting them back writes what is already there) now go back in one write per copy. Measured, same scene band (2400 to 3200 draws/frame), medians of the frame lines, before and after: | | before | after | | --- | --- | --- | | frame | 815 ms | 364 ms | | preparing, copies | 123 ms / 191 MB | 71 ms / 194 MB | | copying back | 216 ms / 64 MB | 210 ms / 62 MB | The first change is what moved the frame; the copies fell with it (fewer slots left stale, so less to refresh). The second did not move the copying back figure on its own — the one-write form lands in the same 210 to 256 ms band, so the time there is not the write call itself. It is here because it is fewer syscalls over the same bytes, not because I can show a win from it, and it can be dropped without touching the first. Honest limits: the run drifts through the prologue, so the bands are medians of 2 to 4 frame lines at matching draw counts rather than a fixed camera, and the later runs had a warm shader cache. Two things the fork needs on Windows 10 to run at all, not part of this PR: the app-local Agility SDK runtime (without it the title dies at +0xb5a5f8 on the in-box runtime) and the keyboard stand-in pad fix from upstream fxceless#729 (with an XInput keyboard such as a Wooting the title otherwise gets no input).
naixue2233
force-pushed
the
perf/heap-sync-copy-back
branch
from
November 25, 2026 07:35
4523733 to
b5dee8d
Compare
|
Read through at
On the page skip ( |
oceansde012
pushed a commit
to oceansde012/victory-gta6
that referenced
this pull request
Nov 25, 2026
…se bytes did not change, and write a copy back in one call (by naixue2233)
oceansde012
pushed a commit
to oceansde012/victory-gta6
that referenced
this pull request
Nov 25, 2026
…less#786/fxceless#783 merges Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FLuVRkN9XKxpoYQhz4KNXw
pug205gti6
added a commit
to pug205gti6/victory-fork
that referenced
this pull request
Nov 25, 2026
…e, and write a copy back in one call
`sync_heaps` walked the 1,024 to 2,048 records of every page the kernel called written: 300,000 to 485,000 records a frame, of which 12,000 to 20,000 were new. The kernel marks a page written even when the title put back the bytes it already held, so most of that walk found nothing. The page's bytes are now compared with the ones last read (64 KiB, a few microseconds) and the page's records are skipped when they are the same. The bytes are kept by page address, so a heap's pages go with it when it is released: a heap placed where a released one was, holding the same bytes, would otherwise skip the sync its own host heap (new, and empty) needs. The one-write copy-back that came with this is dropped (the review on this PR): it filled the gaps between the runs with the title's bytes as read and wrote the whole stretch once, after the loop, over whatever the title wrote there in between (the case upstream #2009 fixed). It did not move the copying-back figure on its own either, and the runs go back as they did before. Measured with it still in, same scene band (2400 to 3200 draws/frame), medians of the frame lines: frame 815 ms before, 364 ms after. The copies fell with it (fewer slots left stale, so less to refresh). Honest limits: the run drifts through the prologue, so the bands are medians of 2 to 4 frame lines at matching draw counts rather than a fixed camera, and the later runs had a warm shader cache.
Author
|
Both points taken, at
— deepseek v4.1flash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebased onto 9376fd6: the fingerprint change from this PR is gone (9376fd6 took it,
record_print), and so is the one-write copy-back (the review on this PR: it filled the gaps between the runs with the title's bytes as read and wrote them after the loop, over anything the title wrote in between — the case upstream #2009 fixed; and it did not move the copying-back figure on its own). What is left is the first of the two costs. Nothing here changes what is computed; the picture is the same.sync_heapswalked every record of every page the kernel called written. 300,000 to 485,000 records a frame, of which 12,000 to 20,000 were new. The kernel marks a page written even when the title put back the bytes it already held, so most of that walk found nothing. The page's bytes are now compared with the ones last read (64 KiB, a few microseconds) and the page's records are skipped when they are the same.The bytes are kept by page address, so a heap's pages go with it when the heap is released: a heap placed where a released one was, holding the same bytes, would otherwise skip the sync its own host heap (new, and empty) needs.
Measured (with the copy-back still in), same scene band (2400 to 3200 draws/frame), medians of the frame lines, before and after:
The first change is what moved the frame; the copies fell with it (fewer slots left stale, so less to refresh).
Honest limits: the run drifts through the prologue, so the bands are medians of 2 to 4 frame lines at matching draw counts rather than a fixed camera, and the later runs had a warm shader cache.
Two things this fork needs on Windows 10 to run at all, not part of this PR: the app-local Agility SDK runtime (without it the title dies at
+0xb5a5f8on the in-box runtime), and the keyboard stand-in pad fix from upstream #729 (with an XInput keyboard such as a Wooting the title otherwise gets no input).from deepseek(v4.1 flash)