Repository navigation
metal: prove cached uploads with page write tracking (draft, menu regression) - #513
Draft
RINNECODER wants to merge 2 commits into
Draft
RINNECODER wants to merge 2 commits into
RINNECODER wants to merge 2 commits into
Conversation
After every submission, wait or flip the image cache expires its entries and each uploaded surface re-proved itself with a hash of all its guest bytes (about 870 MiB per frame on a live map scene). The Metal path now uses libc's page write watch (the direct-memory mappings are already registered): an upload collects its surface's pages before the GPU reads them and keeps the generation; the proof collects again and checks that no 64 KiB block of the surface was stamped since. Stamps are shared, so overlapping surfaces collected separately still see each other's stores. Exact for CPU stores of any size, including guarded host writes (file reads). GPU writes from our own work keep invalidating entries as before. A surface the CPU did write is hashed again for a while, so a texture streamed every frame does not take a write fault per page per frame. Ranges the watch does not cover are hashed as before. ANYPS5_METAL_IMAGE_TRACK=0 turns it off. Metal refuses a no-copy alias over pages of mixed protection. When the refused range is watched, the alias is retried under a host-write guard, which unprotects the pages and marks them written so no store is missed. Existing aliases keep working when their pages are protected again. The frame replay registers its mapped ranges with the watch, as the game's mappings are, so its own stores reach the tracker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This branch has not been deployed
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.
Draft. Do not merge: the menu capture regresses (see Blocker). #507 is merged; this is rebased onto main.
What
After every submission, wait or flip, the Metal image cache expires its entries. Each uploaded surface then re-proved itself by hashing all of its guest bytes, about 870 MiB per frame on the live-map capture. This PR proves uploaded surfaces with libc's page write watch instead. The direct-memory mappings are already registered with it.
GuestImageWriteTracker.hpp). The stamps are shared, so overlapping surfaces that are collected separately still see each other's stores.ANYPS5_METAL_IMAGE_TRACK=0turns all of this off.A/B (live-map capture, 10 interleaved pairs, A = #507, repeat 2)
Image-cache stats (GPU timing, 16 flips): hashed 13887 → 8170 MiB, with 409 tracked proofs and 24 tracked rejections.
Correctness
rosetta_image_cache_trackingtest (real watched pages and write faults). It checks that a 1-byte store, a guarded host write, memcpy and memset stores between submissions all force a re-upload, and that two caches over shared pages both see a store.APS5_NO_WRITE_WATCH=1. The existingrosetta_image_cachetest still passes.Blocker
On the menu capture, timed repeat 2 is wrong in 134,964 pixels (max delta 183, on the 3D character). Later repeats are correct, and
--expect-pngagainst the last repeat passes. This is deterministic and does not happen with tracking off.Bisected:
Root cause unknown. Until it is found, page protection on GPU-aliased guest memory is not proven safe.
Codex review findings
Depends on #507 (merged).
🤖 Generated with Claude Code
https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj