Skip to content

instrumentation: fail a build, an asset or the gate that ships without VKBRIDGE_LATLOG / VKBRIDGE_STATS - #91

Open
pgm1207 wants to merge 1 commit into
ASEbrahim:mainfrom
pgm1207:fix/ship-latency-instrument
Open

pgm1207 wants to merge 1 commit into
ASEbrahim:mainfrom
pgm1207:fix/ship-latency-instrument

Conversation

@pgm1207

@pgm1207 pgm1207 commented Nov 20, 2026

Copy link
Copy Markdown

What

Nothing checked that the per-frame instrumentation a release binary ships with is actually in it. On the CMF (Mali-G720, MaliBridge v0.5.5.3) the deployed libvkbridge_server.so has neither VKBRIDGE_LATLOG nor VKBRIDGE_STATS in its string tables: the knobs were set, nothing was logged, and the one instrument that would answer the next question did not exist on the device.

scripts/check-instrumentation.sh <elf>... reads an ELF's string tables (before or after strip) and fails when VKBRIDGE_LATLOG or VKBRIDGE_STATS is missing. With --server it also demands the latency log's own header line, so a table that merely names the switch cannot pass for the log.

Wired in at three places:

  • scripts/build-server-android.sh — after llvm-strip, on libvkbridge_server.so and libvkbridge_jni.so
  • scripts/check-droiddeck-asset.sh — on the asset's two server libraries and the guest ICD
  • host/run_tests.sh — new instrumentation test, so the host gate has it too

Why the binaries can lose it

Both diagnostics are compiled in unconditionally (server/server_latency.c, client/latency.c; VKBRIDGE_STATS in server/server_conn.c, client/conn.c), and both build scripts compile the whole source directory. A deployed binary without them therefore came from somewhere else: an older checkout, or package-droiddeck-asset.sh's optional <source-dir>. No check existed, so no step failed — the failure only showed up as "no log to read" during a measurement session.

Only presence is asserted: no behaviour change, no default flipped. Turning the latency log on by default was considered and dropped — it writes a line per frame and buys nothing once an operator can set VKBRIDGE_LATLOG=1 in <cache dir>/env, which the harness already does.

Evidence it works

Fresh NDK build of this branch (scripts/build-server-android.sh ~/Android/Sdk/ndk/27.3.13750724 /tmp/opencode/mb-an):

ok: .../arm64-v8a/libvkbridge_server.so carries the latency log and VKBRIDGE_LATLOG VKBRIDGE_STATS
ok: .../arm64-v8a/libvkbridge_jni.so carries the latency log and VKBRIDGE_LATLOG VKBRIDGE_STATS
built .../libvkbridge_server.so and libvkbridge_jni.so

Host:

$ scripts/check-instrumentation.sh --server host/out/vkbridge-server
ok: host/out/vkbridge-server carries the latency log and VKBRIDGE_LATLOG VKBRIDGE_STATS
$ scripts/check-instrumentation.sh host/out/libvulkan_droidbridge.so
ok: host/out/libvulkan_droidbridge.so carries VKBRIDGE_LATLOG VKBRIDGE_STATS
$ scripts/check-instrumentation.sh host/out/libvkb_mali_profile.so
FAIL: ... has no: VKBRIDGE_LATLOG VKBRIDGE_STATS -- built without the per-frame instrumentation?
$ scripts/check-instrumentation.sh --server host/out/libvulkan_droidbridge.so
FAIL: ... has no: latency-log-writer -- built without the per-frame instrumentation?
$ cp host/out/vkbridge-server /tmp/s && strip --strip-unneeded /tmp/s && scripts/check-instrumentation.sh --server /tmp/s
ok: /tmp/s carries the latency log and VKBRIDGE_LATLOG VKBRIDGE_STATS

Gate: make -C host -j8 → rc 0; host/run_tests.sh instrumentation latency → ok instrumentation, ok no protocol errors. latency_test fails with 6 steps in this container both here and on unmodified 3cd7a2b (its present_late_check core-dumps under the suite's Mali profile shim); run alone it is 7/7 OK here and on this branch. That is pre-existing and unrelated to this diff, which touches no C.

Where the numbers come from

CMF measurement session, 2026-11-20: Steam menu CEF-cadence-bound at ~30-39 fps; per-frame tail fence wait 2.60 ms, render_scene 3.39 ms, acquire 0.13, present 0.44 of a ~31.8 ms frame (/tmp/opencode/two-track-plan.md, cmf-latency-baseline). The remaining ~24 ms is what a device-side latency log is for.

Not done here

  • No phone: the asset rebuild/pin that would put this on a device is a separate release step.
  • VKBRIDGE_STATS is not in server_presets.c's per-game allow-list by design (it is a per-server switch, taken from <cache dir>/env), so nothing was changed there.

…t the log

The CMF's deployed libvkbridge_server.so (v0.5.5.3) has neither VKBRIDGE_LATLOG nor
VKBRIDGE_STATS in its string tables, so the knobs did nothing and no per-frame log
existed: the one instrument that would say what the rest of a 31.8 ms frame was doing
was not on the device (fence wait 2.60 ms, render_scene 3.39 ms, acquire 0.13, present
0.44 - 8.2 % + 10.7 % of the frame; the other ~24 ms unknown).

Both diagnostics are compiled in unconditionally (server/server_latency.c, client/latency.c,
server/server_conn.c, client/conn.c) and both build scripts compile the whole source
directory, so the absence came from a binary built elsewhere (an older checkout, or
package-droiddeck-asset.sh's [source-dir]). Nothing checked, so nothing failed.

scripts/check-instrumentation.sh reads an ELF's string tables and fails when
VKBRIDGE_LATLOG or VKBRIDGE_STATS is missing; --server also demands the latency log's own
header line, so a table naming the switch cannot pass for the log. Wired into
build-server-android.sh (after strip, on both server outputs), check-droiddeck-asset.sh
(on the asset's server, jni and ICD) and run_tests.sh ("instrumentation", so the host gate
has it too). The literals survive --strip-unneeded and llvm-strip.

Tested: --server on a fresh NDK build (libvkbridge_server.so, libvkbridge_jni.so) and on
host/out/vkbridge-server -> ok; on host/out/libvulkan_droidbridge.so -> ok; on a library
without them (host/out/libvkb_mali_profile.so) -> FAIL as intended.
@pgm1207

pgm1207 commented Nov 20, 2026

Copy link
Copy Markdown
Author

@coderabbitai review

@pgm1207

pgm1207 commented Nov 20, 2026

Copy link
Copy Markdown
Author

Requesting a review: this is ready and mergeable. CodeRabbit does not appear to be installed on this repo, so this is a ping for a human review.

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