A dormant block kept its surface's cache on the host, and a non-deferred one
its surface's memory wired, until a cap, a client's going or a new block's want
of room let it go. After a browser closed, walk m3-max-66448 (arm64 macOS
27.0.1 on the M3) kept 250 dormant deferred blocks, 1013 MiB of caches that
held the only copy of surfaces other processes still held, and 3 to 5 wired
blocks of 6016x6016 surfaces with nothing to copy, 432 to 580 MiB.
Each dormant block now also goes once it has slept 10 s (kRgfxDormantAgeMs),
the host's age for a shape no texture references (UNREFERENCED_FOR). The
release worker lets it go, run by a timer armed for the next block's age; none
is armed while no block sleeps. The let-go is the one the caps make:
- a block whose cache the GPU has not written since its last copy is released
with nothing to copy, and the host drops the cache;
- a written block's release copies the cache into its pages, a deferred one's
pages named first where its surface lives on. One such release is in flight
at a time, the next let go at its answer, so the copies the blocks a close
leaves owe come one after another, not as one burst beside the frames.
The surface's next ask makes a new block over its pages.
What the guest sees: a surface's pages take the GPU's writes when its block
ages out rather than at its next lock, so only a CPU read without IOSurfaceLock
sees the bytes earlier, and IOSurface leaves that read undefined. A lock reads
what it read before.
The release worker also logs, for eight a minute at most of the blocks let go
for their age with clients of the surface left, which processes with a context
open find the surface by its ID: a diagnostic, for who holds them.
guest/prebuilt and guest/prebuilt-arm64e are rebuilt from these sources.