Skip to content

kyty: Execute is the CPU wall on GPU-driven titles (about 10 µs per operation on a native PS5 title); the plan is #168 #55

Open

Description

@simnJS

Problem

Outside heavy ray tracing, AnyKyty's frame rate is usually capped by one CPU thread: kytyGpuExecute.

Kyty runs the guest GPU work in stages, one thread each: kytyGpu (command processor), kytyGpuResolve, kytyGpuExecute, kytyGpuRecord. Execute takes every draw and dispatch of the frame in order, on a single thread. For each one it tracks state, looks up buffers and textures in the caches, places barriers and binds descriptors. Measured costs, Linux, RTX 4080 SUPER, Ryzen 7950X3D:

Scene Draws per frame Execute cost fps
Cyberpunk 2077, character creator, uncapped (Windows, RTX 5090, report in #42) n/a kytyGpuResolve 98 %, kytyGpuExecute 96 % of a core ~80
An Unreal Engine 4 title, in game 4,240 Execute near a full core ~81

Busier scenes have more draws and fewer fps. Correction: an earlier version of this issue listed title A's Performance mode as Execute-bound. It isn't: that mode is capped by the game at ~141 fps, with Execute at 2.7 µs per draw and 51 % of a core. In Fidelity with RT, title A is GPU-bound. Shaving a few percent off each draw doesn't change the picture. Spreading the work over several threads would: the CPU has 32 threads, and Execute uses one.

Goal

Run Execute on several threads, for a factor, not a few percent, in every game. What looks parallel:

  • recording render passes into Vulkan secondary command buffers on several threads;
  • having worker threads prepare each draw's state ahead (descriptor sets, read-only cache lookups), with the main thread consuming them in order;
  • keeping only what is truly ordered on one thread: cache ownership, barriers, write ordering between draws.

Status

A throwaway prototype is measuring the ceiling first: where the ~4.8 µs per draw go, what is ordered by nature, and what a split actually gains on frame replays. The verdict, with numbers, will be posted here before any large rework starts.

How to check whether Execute is your wall

On Linux, top -H -p <game pid>, or htop with thread names, while in game: if kytyGpuExecute sits near 100 % of one core while the GPU is below ~90 %, Execute is the limit. On Windows, Process Explorer's thread view shows the same names. Post the game, scene, draws per frame if you have them, per-thread CPU, GPU usage and fps.

Help wanted

Knowledge of Vulkan multi-threaded command recording, or of how other emulators split their command processors, is very welcome. Please comment before starting code, so we don't collide with the prototype.

Activity

  1. added
    help wanted
    on Nov 18, 2026
  2. simnJS commented on Nov 18, 2026

    @simnJS
    OwnerAuthor

    Verdict of the ceiling prototype: splitting kytyGpuExecute would gain nothing on our benches today. No rework is planned for now, and this issue stays open as a reference.

    Method: add a fixed cost to every draw in one stage, and see whether the frame time follows. If the frame time doesn't move, that stage isn't on the critical path, and splitting it can't help.

    • Stray (Ryzen 9 7950X + RTX 5070 Ti): +2 µs per draw on Execute (+8.5 ms per frame) leaves fps unchanged (55.6 → 55.6). +2 µs per draw on Resolve: 56.9. GPU at ~40 %. Neither stage holds the frame.
    • An open-world AAA title, Performance mode: flat at ~141 fps while Execute's load triples (668 → 1,343 draws per frame). The cap comes from the game. In Fidelity mode the GPU is the wall.

    Correction to the issue text above: the ~96-98 % "of a core" figures, ours and the ones in #42, do not show saturation. With the default KYTY_GPU_SPIN_US=2000, a stage that waits spins and burns its core anyway. To find the real wall, measure with KYTY_GPU_SPIN_US=0, or better, with the slope test above.

    About 55-60 % of Execute's work is ordered by nature: cache and memory tracking per draw, pass continuity, barriers, label and occlusion ordering. Only ~20-25 % could be split: descriptors, templates, stream encoding. The cheap split would give a few percent at best. The split that gives a factor means versioned caches per render pass, which is weeks of risky work. It would only be worth it for a scene that the slope test shows to be limited by these stages. If you have such a scene, please post the slope numbers here.

  3. simnJS commented on Nov 19, 2026

    @simnJS
    OwnerAuthor

    Closing as not planned: the ceiling prototype above showed that kytyGpuExecute is not on the critical path in our benches.

    • Stray: +2 µs per draw on Execute (+8.5 ms per frame) left fps unchanged (55.6 → 55.6), with the GPU at ~40 %.
    • An open-world title in Performance mode stayed flat at ~141 fps while Execute went from 668 to 1,343 draws per frame.
    • The 96-98 % "of a core" figures are spin-wait (KYTY_GPU_SPIN_US=2000 by default), not saturation.
    • Only about 20-25 % of Execute's work could be split without versioned caches per render pass.

    Reopen with a scene where the slope test (add a fixed cost per draw to one stage and see whether the frame time follows) shows that Execute or Resolve limits the frame, and post the slope numbers.

  4. Celegans12 commented on Nov 21, 2026

    @Celegans12
    Collaborator

    @simnJS here's a scene where the slope test says Execute does limit the frame: Ghost of Yōtei on a laptop. I ran it the way you described, adding a fixed busy-wait before every draw and dispatch on the execute thread, on your 8ebb72d680d plus our Yōtei commits.

    At our Teshio save (1080p, RTX 3080 Laptop + i9-11900H, Windows 11, about 6,200 draws and dispatches per frame), the frame follows the added cost closely. +5 µs per op adds about 31 ms of Execute work per frame and the frame gets 21 ms longer (112.7 → 134.6 ms), so the slope is about 0.69. The next +5 µs adds 18 ms (→ 152.8 ms), a slope of about 0.59. Two 0 µs legs bracket the series at 88.8 and 87.8 presents per 10 s, so drift is small. The GPU is about 70 % busy there, and our per-shader timer puts its work at about 70 ms per frame, so the GPU becomes a co-limit somewhere near 1.5× on this machine.

    I also counted what a split would have to work with. With render-pass segments (ending a segment only at guest waits, ACQUIRE_MEM, PFP_SYNC_ME, Execute's own GPU reads and waits, target changes and flips), 85 % of ops sit in segments of 8 or more, and the op-weighted median segment is 38 ops. But with today's caches, 74 % of the ops in those segments touch state an earlier op of the same segment wrote: buffer 35 %, image 33 % and write-tick 29 % of ops, with the descriptor pool counted separately at 55 %. Ops per critical path in those segments come to only about 2.1. So I think your earlier read holds: without versioned buffer/image/write-tick state, a split gets about 2× at best on the prepared work, and the factor needs the versioned caches per render pass.

    Would that be enough to reopen this? I'm happy to rerun the slope or counters on any branch of yours, or to break the collisions down further (by object, by distance) if that helps the design.

    Details

    Slope legs: 240 s each, world rate from 70 s, KYTY_SPLIT_SLOPE_US = busy-wait before each draw and dispatch on the execute thread. Same build for all legs; this build lost PGO coverage in some functions, so compare these legs only with each other.

    added per op presents per 10 s frame ms added Execute ms per frame Δ frame ms slope
    0 µs 88.75 112.7 0
    5 µs 74.31 134.6 31.1 +21.9 0.70
    10 µs 65.44 152.8 62.1 +18.2 (vs 5 µs) 0.59
    0 µs 87.81 113.9 0

    Counter leg (one 10 s window, numbers per frame): draws 3,550, dispatches 2,663, callbacks 1,232. Ordering points per frame: guest-wait 184, ACQUIRE_MEM 261, PFP_SYNC_ME 22, label 340, event 595, CP write 138, DMA 117, Execute GPU read 11, Execute GPU wait 761, urgent (serving other threads' readbacks) 122, target change 73, queue switch 31, draw/dispatch switch 83, flip 2.

    strict (every point ends a segment) render-pass
    segments per frame 837 600
    median / p90 ops per segment 1 / 19 2 / 27
    op-weighted median segment 25 38
    ops in segments ≥ 8 / ≥ 32 79 % / 44 % 85 % / 56 %
    ops colliding, segments ≥ 8 (no descriptor pool) 73 % 74 %
    ops per critical path, segments ≥ 8 2.2 2.1
    first-collision distance 1 op 58 % 58 %

    "Collision" = an op reads or writes an id an earlier op of the same segment wrote (read-after-write and write-after-write; write-after-read not counted, versioning solves it). Ids: buffer start address, 4 KiB tracker page, image serial, image-heap generation, write-tick page, pipeline first use, descriptor pool.

    AI-assisted: yes

  5. reopened this on Nov 21, 2026
  6. simnJS commented on Nov 21, 2026

    @simnJS
    OwnerAuthor

    @Celegans12 thank you for running the slope test, and for the collision count on top of it. Reopening.

    We reach the same conclusion: on Ghost of Yōtei, Execute is the wall. Our own slope on that title, in one A/B session on a desktop, is in the same range as yours.

    Where we land differently is on the remedy: our measurements say splitting Execute across several threads isn't worth its cost. Execute spends about 10 µs per operation on Yōtei, and most of that isn't resolving resources: it's the guarantees around reads done ahead of time on memory the GPU wrote (the read log, revalidation, waits for GPU copies). Resolution itself, measured in a standalone proof of concept shaped like Yōtei's frame, is a small fraction of a microsecond per operation. Your collision count points the same way: most of the shared state the ops collide on is buffer, image and write-tick state, i.e. that bookkeeping.

    So the route we've chosen is pillar 1 of #168, "what the GPU writes, the GPU reads": steps E2 (GPU-written words and V# read by the shader, compute first), E3 (no execution-time revalidation for loads left to the GPU) and E4 (the thin chain: draws whose resources are all data skip the resolver). That removes the work instead of spreading it over threads. This issue stays open as the measured problem, with #168 as its plan.

    If you'd like to take one of E2-E4, comment on #168 first so two people don't start the same step. Your slope setup would also be the natural check for each of them.

  7. added
    perf
    area: execute
    on Nov 22, 2026
  8. changed the title [-]kyty: kytyGpuExecute runs every draw on one thread — the main CPU wall, and the plan to split it[/-] [+]kyty: Execute is the CPU wall on GPU-driven titles (about 10 µs per operation on Ghost of Yōtei); the plan is #168[/+] on Nov 22, 2026
  9. added
    hard
    and removed
    help wanted
    on Nov 22, 2026
  10. simnJS commented on Nov 22, 2026

    @simnJS
    OwnerAuthor

    Renamed to match where this landed: the measured problem stays here, the plan is #168 (pillar 1, steps E2 to E4), and splitting Execute across threads is not the route. A throwaway prototype is measuring the frame rate Ghost of Yōtei reaches once Execute costs what the "thin chain" (E4) would; its result will be posted on #168. To take a step, comment on #168 first.

  11. mrfelek commented on Nov 23, 2026

    @mrfelek
    Contributor

    @simnJS a second title where the slope test says Execute limits the frame: ASTRO BOT (PPSA21564), the pirate island level, which is the slowest spot we know in that game.

    Setup: Linux, Ryzen 9 5950X, RTX 3080 Ti (NVIDIA 615.71.09), AnyKyty 945dc287bc, KYTY_GPU_SPIN_US=0, warm caches, level started with -lvl big_hand_pirate_island, fps from 60 s of VideoOut telemetry after the level loads. The added cost is a busy-wait before every non-callback operation on the execute thread (a local test-only hook, not for a PR).

    Added per op fps Frame Execute CPU GPU (nvidia-smi)
    0 18.56 53.9 ms 77 % 69 %
    +2 µs 14.19 70.5 ms 92 % 61 %
    +4 µs 10.51 95.2 ms 94 % 54 %
    0 (again) 18.41 54.3 ms 76 % 71 %
    • The two 0 µs legs agree within 1 %.
    • The first +2 µs adds about 23.5 ms of Execute busy time per frame, and the frame gets 16.6 ms longer: a slope of about 0.71. The next +2 µs gives about 0.86.
    • That puts the frame at about 11,600 operations, which matches the [kyty-resolve] "ahead used" count (2.16 M per 10 s at 186 frames). Execute spends about 3.6 µs per operation.

    How it differs from Yōtei: few operations touch GPU-written data. Only about 0.5 % of the ahead reads are "read around GPU writes", so pillar 1's GPU-written path barely applies here. The cost is the plain per-op work times a high op count, so E4's thin chain is what would move it.

    The GPU is not the next wall yet. In an Nsight GPU Trace of one window at the same spot, SM throughput was about 6 % and VRAM throughput about 8 %, with frames of 47–76 ms made of many small submits. Pinning the stage threads (KYTY_GPU_THREAD_CPUS=1,2,3,4,5) made no difference: 18.0 and 18.2 fps against 18.0 and 18.2 by default.

    These numbers are from 945dc287bc, not the current head. If it helps, we can run the E4 ceiling prototype on this scene as one of its non-Yōtei games, and rerun on the head first.

    AI-assisted.

  12. simnJS commented on Nov 26, 2026

    @simnJS
    OwnerAuthor

    Thanks @mrfelek, and sorry for the late answer. Your slope (0.71 to 0.86 at about 11,600 operations per frame, about 3.6 µs each, almost no reads of GPU-written data) makes that title the opposite profile to our GPU-driven bench title, which is what E4 has to be judged on. The E4 ceiling prototype hasn't started: it comes after the T3 gate (#168). When it has a branch, we'll ping you here for the KYTY_AB runs you offered, on both scenes.

  13. added
    needs: measurement
    on Nov 26, 2026
  14. changed the title [-]kyty: Execute is the CPU wall on GPU-driven titles (about 10 µs per operation on Ghost of Yōtei); the plan is #168[/-] [+]kyty: Execute is the CPU wall on GPU-driven titles (about 10 µs per operation on a native PS5 title); the plan is #168[/+] on Nov 26, 2026
  15. simnJS commented on Nov 27, 2026

    @simnJS
    OwnerAuthor

    The four-frame warm-cache 1080p capture from #359 now has a per-frame breakdown. The main kytyGpuExecute thread used 10.14 s of CPU over 12.087 s wall time. The inclusive sample estimates are 2.369 s in PrepareBindings, 1.776 s in RebindImages, and 2.036 s in CommitBindings.

    A separate 10-second counter window from the same run found 200 binding-state rebuilds alongside 504 successful resolution-cache lookups and zero resolution evictions. The renderer also counted 221 binding-state retirements. This gives #359 a concrete target for reducing repeated work on the executor. The phase numbers describe the existing renderer and do not estimate a speedup from parallelism.

  16. github-actions commented on Nov 27, 2026

    @github-actions

    Thanks for the breakdown. For the #359 A/B, compare rebuilds and retirements per frame alongside Execute CPU time and frame time on the same warm-cache capture. That would show whether reducing binding-state churn saves executor time and whether that saving reaches the frame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: executehardneeds: measurementperf

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions