From 8e50b37cfc57d333822bb540a436a297b8ba5596 Mon Sep 17 00:00:00 2001 From: Shokunin <30949000+tetrisgm@users.noreply.github.com> Date: Wed, 21 Oct 2026 13:36:29 -0700 Subject: [PATCH] Attribute replay completion waits to render queue operations --- runtime/src/main.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 6c1ddb38..ac8da9ee 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp @@ -4818,12 +4818,18 @@ static uint64_t g_frame_report_wait_ticks = 0; /* offline pacer waits */ /* Explicit, file-driven production benchmark. No debug server, sampler or * per-instruction tracing is needed. Capture outside the measured interval; * export the existing frame ring before requesting the normal quit path. */ -struct ReplayWorkSample { uint64_t frame, guest, pacer, queue, completed; }; +struct ReplayWorkSample { uint64_t frame, guest, pacer, queue, completed, bp, ring, acquire; }; static std::vector g_replay_work; static void input_replay_frame_completed(uint64_t frame) { if (g_replay_work.empty()) return; auto &sample = g_replay_work[frame % HOST_FRAME_STAMP_CAP]; - if (sample.frame == frame) sample.completed = host_clock_us(); + if (sample.frame == frame) { + sample.completed = host_clock_us(); + RtStats rs{}; rt_get_stats(&rs); + sample.bp = rs.backpressure_ns / 1000; + sample.ring = rs.ring_full_ns / 1000; + sample.acquire = rs.acquire_ns / 1000; + } } static void input_replay_frontend_tick(uint64_t frame) { uint64_t relative = input_replay_frame(frame); @@ -4883,7 +4889,7 @@ static void input_replay_frontend_tick(uint64_t frame) { if (report && *report) { FILE *f = std::fopen(report, "w"); if (!f) throw std::runtime_error("cannot write input replay frame report"); - std::fputs("frame,relative,us,interp,checks,faults,io_kb,guest_us,pacer_us,queue_us,completed_us\n", f); + std::fputs("frame,relative,us,interp,checks,faults,io_kb,guest_us,pacer_us,queue_us,completed_us,completed_bp_us,completed_ring_us,completed_acquire_us\n", f); uint64_t total = host_frame_stamp_total(); uint64_t first = total > HOST_FRAME_STAMP_CAP ? total-HOST_FRAME_STAMP_CAP : 0; for (uint64_t i=first; i 0 && bytes < (int)sizeof renderer) { + std::ofstream detail(std::string(report) + ".renderer.json"); + detail << "{" << renderer << "}"; + if (!detail) throw std::runtime_error("cannot write input replay renderer report"); + } } SDL_Event event{}; event.type = SDL_QUIT; SDL_PushEvent(&event); }