Skip to content

GPU: a title copy makes due again only the copies it writes - #12

Merged
wbkepler merged 1 commit into
mainfrom
gpu/title-copy-invalidation
Nov 25, 2026
Merged

wbkepler merged 1 commit into
mainfrom
gpu/title-copy-invalidation

Conversation

@wbkepler

Copy link
Copy Markdown
Owner

What

A title memory copy at submission (Step::Copy, or Step::Run for memory-to-memory copies) used to clear the current ranges of every host copy in the batch. After each of the world's ~30 tiny title copies per frame, every later list checked every copy again (most of the ~90k watch checks per frame, almost all finding nothing).

  • Batch::title_wrote(at, len) flushes the pending refreshes as before, but takes only the written range out of current, rounded out to whole 64 KiB pages and including pages that show it at other mappings (watch::aliased_pages). Copies that aren't tracked are still due again in full.
  • Step::Run / HostList::defer now carry the range they write.
  • Why the earlier attempt crashed (local b3864d6, about 160 s into the world): marked pages that title threads wrote after an earlier list in the submission took them, but before a later list armed them, were no longer taken again inside the submission. Their copy-back kept the title's bytes and dropped the shaders' bytes: "kept the title's" went from about 1 to 14–26 per frame in that run, and then the title crashed reading -1.
  • The fix for that: the batch records the ranges shaders write through marks. Batch::finish (which replaces the final flush) takes what changed in those ranges once more, just before the lists run, so the pages are taken and armed together.

Measured (one 300 s world run; RTX 5090, VICTORY_GPU_UPLOAD=1 VICTORY_GPU_UPLOAD_WRITES=1 VICTORY_LAZY_COPY_BACK=1)

per frame before (main minus 2 PRs) after
frame 326–356 ms 322–352 ms
preparing 190–217 ms 166–196 ms
watch checks ~92,900 ~69,500
refresh batches 57–71 ms ~49 ms
copies ~100 MB ~113 MB
snapshots ~293 MB ~289 MB (unchanged; the large unmarked buffer is not in this PR)
marked pages keeping the title's bytes 0–1 1

The run stayed stable for the full 300 s: no device removal, no access violation, and the world scenes render.

Tests

  • a_title_write_refreshes_only_the_copies_it_reaches: covers the written copy, an alias of it, an untouched copy that stays current, and the finish retake of an armed range.
  • The existing batch tests were moved to title_wrote.

🤖 Generated with Claude Code

A title memory copy (Step::Copy) or memory-to-memory copy (Step::Run)
at submission cleared every copy's current ranges, so each list after
it checked every copy again: ~30 tiny copies a frame, most of the
~90,000 watch checks a frame, nearly all finding nothing changed. Both
steps know the range they write: the batch now cuts only that range
(whole pages, plus the pages showing it at other mappings) out of the
current ranges; copies not tracked are due again whole as before.

An earlier attempt at this crashed the title after ~160 s: marked
pages the title's threads wrote after a list took them, but before a
later list armed them, were no longer taken again in the submission,
so their copy-back kept the title's bytes and dropped the shaders'
(~20 such pages a frame instead of ~1). The batch now remembers the
ranges shaders write through marks and, before the lists run, takes
what changed in them once more (`Batch::finish`): armed and taken, a
title write there saves the page's bytes as intended.

World (RTX 5090, upload heaps, lazy copy-back): preparing ~190-217 ->
~166-196 ms/frame, watch checks ~92,900 -> ~69,500, refresh batches
~57-71 -> ~49 ms; marked pages keeping the title's bytes stay ~1 a
frame; stable for 300 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wbkepler
wbkepler merged commit d63dcfa into main Nov 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant