Skip to content

SCGPU stream ring: GL stream writes no longer wait for the app - #31

Merged
dylanneve1 merged 1 commit into
mainfrom
scgpu/ring
Oct 27, 2026
Merged

dylanneve1 merged 1 commit into
mainfrom
scgpu/ring

Conversation

@dylanneve1

Copy link
Copy Markdown
Collaborator

The GL stream's writes go into a 4 MiB byte ring in the SCGPU pool instead of a mailbox round trip each. Records are {resource, context, length} plus payload padded to 16 bytes; the guest advances ring_head, and the app advances ring_tail and drains the ring before every mailbox command, so ordering holds. The guest only waits for room. Reads still go through the mailbox. The ring is allocated only when the app sets SCGPU_F_RING, so a new kernel with an old app keeps the old path.

Measured on the Pixel 10, home-screen page swipes (SurfaceFlinger, overlay layer, two runs each):

doorbell ring
fps 16.5 / 15.3 19.6 / 20.2
median frame gap 50 ms 42 ms
gaps > 50 ms 55% / 58% 39% / 38%
p99 217 / 267 ms 200 / 217 ms

App side: Scion-Project/scion (scgpu/ring).

🤖 Generated with Claude Code

Every write(2) of the GL stream on /dev/vgpu3d was a mailbox command (TRANSFER_TO_HOST_3D of
the pipe) and a wait for its reply: a round trip per flush, and under video (YouTube in
Safari) 4-10K commands a second with the app's device thread 60% busy. Now, when the app says
it takes them (SCGPU_F_RING), the guest puts the bytes into a 4 MiB byte ring in the pool, as
records of the context's pipe, and returns at once. It rings the app only if the app sleeps, and
waits only for room. The app hands each record to its pipe (transfer_write_iov straight from the
ring) and does so with everything in the ring before it runs any mailbox command, so a reply,
an upload or a read still follows every byte written before it.

bell_ring has a lock of its own now, since both the mailbox and the ring ring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dylanneve1
dylanneve1 merged commit 3ca565e into main Oct 27, 2026
1 check passed
@dylanneve1
dylanneve1 deleted the scgpu/ring branch October 27, 2026 16:14
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