Skip to content

Add opt-in STATS breakdown and frame trace (blocked ms, server/backlog/transport/client split, VKBRIDGE_FRAME_TRACE) - #82

Open
pgm1207 wants to merge 3 commits into
ASEbrahim:mainfrom
pgm1207:pr/1-stats-diagnostics
Open

pgm1207 wants to merge 3 commits into
ASEbrahim:mainfrom
pgm1207:pr/1-stats-diagnostics

Conversation

@pgm1207

@pgm1207 pgm1207 commented Nov 16, 2026

Copy link
Copy Markdown

Problem

STATS shows only totals, so it is hard to tell whether a slow frame is the GPU, the server, the socket or the client. Example: of ~5 ms in vkWaitForFences in Steam's GPU process, ~4.96 ms was GPU completion and ~0.9 ms was the bridge. That was not visible before.

Change

  • STATS reports time blocked.
  • VKBRIDGE_STATS_SPLIT (adds VKB_F_TIMES to the wire header, common/vkb_wire.h) splits time into server run, async backlog, transport and client.
  • VKBRIDGE_FRAME_TRACE: per-frame trace (client/ftrace.c, sites in wsi.c and wsi_wayland.c).
  • VKB_INFO_ALWAYS log macro so these lines appear without verbose logging.

How tested

Host quick-check 14/14 on RADV (desktop). On Intel (laptop) 13/14, and the same failure (desc_limits_check) is on unmodified main. layer-quick-check has 2 failures on main as well. Device runs on the Poco (G925) and CMF Phone 1 (G615).

Evidence

This PR changes no fps; it made the per-stage attribution below possible.

Devices: Poco X8 Pro Max (2602BPC18G, Immortalis-G925) and CMF Phone 1 (A015, Mali-G615 MC2, MT6878, 120 Hz). Test app: MaliDeck (a re-signed DroidDeck 0.7.1 test build). Wireless adb. No power numbers are claimed: some runs were USB- or AC-powered.

Steam menu, fps while moving Poco X8 Pro Max CMF Phone 1
stock-like (all new defaults off) 75 (shipped build) 28.7 and 33.2 (2 runs)
all new defaults on 118.5 77.0 and 74.7 (2 runs)

CMF Phone 1, one default turned off at a time (n=1, 30 s each; none off is about 76): ANGLE=vulkan off 37.1, 6 images off 56.6, pass-through off 66.0, early present off 68.6, present reap off 71.2, async create off 74.0.
Poco, cumulative steps: 75 -> 84 (web UI on ANGLE Vulkan) -> 90 (async create) -> 102 (pass-through) -> 118 (early present + 6 images) -> 118.5 (present reap). Frames on the 8.3 ms slot: 71-76 % -> 98.8 %.
Megabonk in game, Poco, 75 s after a 30 s warm-up, p7 vs stock: 83.3 vs 77.9 fps and 110.9 vs 92.3 fps (n=2 per arm, different scenes). A gain of about 5-10 fps is plausible, not proven. CMF Phone 1, Megabonk, p8 defaults vs stock (stock 21.6 and 22.0; p8 20.9, 17.6, and 24.5 with tracing on): no measurable difference, scene noise about 3 fps; the game is GPU-bound there (GPU done 23 ms after commit against a 40 ms present interval), so these toggles are not shown to help a GPU-bound game. No power numbers on CMF Phone 1.

Limitations: attribution rows are single 30 s samples. In-game A/B has scene noise (n=2 per arm). On CMF Phone 1 an "Offline Mode" popup was on screen in all menu runs, so absolute fps may differ from a clean menu. A forced-composite vs pass-through flicker comparison was run only in CMF Phone 1 Megabonk (6 screenshots each, no flicker or tearing seen either way, fps equal within noise); not on the Poco. In the Poco game flicker check, 78 of about 79 composite_why lines were layers=1 / composite=0, one was layers=2, and one frame was black at the Guide-button transition. On CMF Phone 1 the menu was GPU-limited (GPU at max clock 36-97 % of the time) and showed no flicker with pass-through. Quick 30 s menu runs are screening only, not benchmarks. In game the Poco is limited by game CPU and GPU together; the 11 stalls over 50 ms came from game loading/GC, not the bridge.

How to reproduce

Set the toggle named in this text (others at their defaults), open the Steam menu, move the pointer for 30 s, and read frame intervals from the compositor/gamescope frame log (intervals under 100 ms count as in motion). Raw runs and scripts are available on request.

Risks

The wire header changes (VKB_F_TIMES is flag-gated). All new output is off unless the toggles are set. Please check the wire-compat expectations.

Toggles / defaults

VKBRIDGE_STATS_SPLIT and VKBRIDGE_FRAME_TRACE: both off by default. I would leave them off.

Dropped

The early-present trace sites were left out so this PR does not depend on PR 4.


[Disclosure: I prepared this change and text with the help of an AI assistant. The measurements come from real device runs; the limits are stated above.]

Total milliseconds the calling threads spent in synchronous round trips and
the longest single one per interval (and for the run at exit), plus blocked
milliseconds per command in the per-command lines. Counted only while
VKBRIDGE_STATS is on; the wire protocol is unchanged.
…t and client time (VKB_F_TIMES, VKBRIDGE_STATS_SPLIT)
…it, frame callback, release and feedback

VKBRIDGE_FRAME_TRACE=1 records each step of a frame's way through the swapchain (acquire, fence waits, present, the present
thread's take and fence wait, commit, compositor frame callback, buffer release, presentation feedback) in a lock-free ring and
logs it every 250 ms as "FT <pid> <code><us>,<a>,<b> ..." lines, with the clock epoch in a first "FT0" line (CLOCK_MONOTONIC, the
clock of VKBRIDGE_LATLOG). Default off; each site is one relaxed load of a flag. The codes are listed in client/ftrace.c.
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