diff --git a/docs/building.md b/docs/building.md index 2b935b26..b54deb10 100644 --- a/docs/building.md +++ b/docs/building.md @@ -709,6 +709,12 @@ shapes crossing the picture at any speed are none, where each of the test's rule without a thumbnail is not judged. With `time` it prints what the cell means of one thumbnail cost. No GPU, no game files. +A change to the present side's log lines (`runtime/vk_backend.c` `present_main` and `present_window`, the window line +of `runtime/perf.c` `perf_present`) or to how `tools/perf_summary.py` reads them passes +`python tests\perf_summary_check.py`. It checks that the format strings it copies are still the runtime's, makes lines +with them and checks the present percentiles, the present thread's averages and the hand-off share the tool prints, +and that the lines of older logs, without those fields, still parse. Any Python, no game files. + The lifter (`recomp/`) and the CPU headers (`runtime/cpu.h`, `runtime/simd.h`) are checked against Unicorn. Every lifter change passes these, all run with `.venv`: diff --git a/runtime/flight.c b/runtime/flight.c index be0cc39a..61051aef 100644 --- a/runtime/flight.c +++ b/runtime/flight.c @@ -32,7 +32,9 @@ // Record columns after frame, time and interval: blocked time per PERF_* kind (us), then the counts. enum { C_SUBMITS, C_PASSES, C_DRAWS, C_DRAWS_SEEN, C_CLEARS, C_COPIES, C_DISPATCHES, C_XLATED, C_PERF0, C_N = C_PERF0 + PERF_CNT_N }; -static const char *const blocked_names[PERF_N] = {"pace_ms", "fence_ms", "drain_ms", "pipe_ms", "xlate_ms", "tex_ms", "astc_ms"}; +static const char *const blocked_names[] = {"pace_ms", "fence_ms", "drain_ms", "pipe_ms", "xlate_ms", "tex_ms", "astc_ms", + "handoff_ms"}; +_Static_assert(sizeof blocked_names / sizeof *blocked_names == PERF_N, "blocked_names follows the PERF_* list (host.h)"); static const char *const count_names[C_N] = { "submits", "passes", "draws", "draws_seen", "clears", "copies", "dispatches", "shaders_xlated", // PERF_CNT_* order (host.h) diff --git a/runtime/host.h b/runtime/host.h index 79c9ccfe..8c8a4a05 100644 --- a/runtime/host.h +++ b/runtime/host.h @@ -28,12 +28,17 @@ enum { RT_TRACE_SVC = 1, RT_TRACE_HOSTCALL = 2, RT_TRACE_IPC = 4, RT_TRACE_FS = RT_TRACE_SCHED = 64, RT_TRACE_AUDIO = 128, RT_TRACE_PRESENT = 256 }; extern unsigned rt_trace; // from NX2NAVI_TRACE=svc,host,ipc,fs,gfx,perf,sched,audio,present (or all) // prof_win.c: NX2NAVI_PROFILE= sampling profiler; NX2NAVI_TRACE=perf frame timing (waits of the render thread) -// PERF_TEX: texture uploads on the render thread (deswizzle, decode, staging), PERF_ASTC included -enum { PERF_PACE, PERF_FENCE, PERF_DRAIN, PERF_PIPE, PERF_XLATE, PERF_TEX, PERF_ASTC, PERF_N }; +// PERF_TEX: texture uploads on the render thread (deswizzle, decode, staging), PERF_ASTC included. PERF_HANDOFF: the +// presenting thread's wait for the present thread to take the previous picture (vk_backend.c present_image), which is +// where the present thread's own pacing and a slow present call (an overlay's frame limiter inside it) hold the game. +enum { PERF_PACE, PERF_FENCE, PERF_DRAIN, PERF_PIPE, PERF_XLATE, PERF_TEX, PERF_ASTC, PERF_HANDOFF, PERF_N }; void prof_start(void); void prof_write(void); // idempotent; boot.c calls it before _exit uint64_t perf_begin(void); // start time of a wait; pair with perf_end void perf_end(int kind, uint64_t t0); // counts render-thread time only +// The same for a wait that may run on any guest thread (the game's image acquire): the render and replay threads' as +// perf_end, any other thread's added to the next present's frame (perf_present). +void perf_end_any(int kind, uint64_t t0); void perf_replay(uint64_t t0); // replay (NVN -> Vulkan recording) time on any thread, waits inside it included void perf_replay_thread(void); // the calling thread replays for the render thread: perf_end counts its waits void perf_main_thread(void); // the calling thread is the guest main thread (NX2NAVI_PROFILE_MAIN) diff --git a/runtime/nvn_api_obj.c b/runtime/nvn_api_obj.c index 97ac2e47..ece8be33 100644 --- a/runtime/nvn_api_obj.c +++ b/runtime/nvn_api_obj.c @@ -16,6 +16,7 @@ #include "nvn_api.h" #include "nvn_hmap.h" #include "nvn_tex.h" +#include "prof.h" #include "platform/platform.h" // ---------- Descriptor pools @@ -827,11 +828,19 @@ NVN_API(nvnWindowAcquireTexture) { NVN_BLOCKING(); int idx = o->active ? o->next++ % o->active : 0; *out = idx; + // The frame timing's waits count on the presenting thread (perf.c perf_end); a game may acquire on another, whose + // wait here perf_end_any adds to the next present. One line names both threads once the first present is known. + static volatile int32_t named; + if (prof_render_tid && !named && !plat_xchg32(&named, 1)) { + uint32_t tid = plat_thread_id(); + rt_log("nvn: the game acquires its window images on thread %u and presents on thread %u%s", tid, + prof_render_tid, tid == prof_render_tid ? "" : ": the acquire's waits count for the next present"); + } uint64_t at = idx < 4 ? o->avail[idx] : 0; if (at) { uint64_t p0 = perf_begin(); sleep_until(at); - perf_end(PERF_PACE, p0); + perf_end_any(PERF_PACE, p0); } // On the Switch the image comes back only after the display has shown it, which needs the GPU to have finished the // frame drawn into it, so the CPU never runs more than the swapchain's depth ahead of the GPU. Here the pacer frees @@ -846,13 +855,9 @@ NVN_API(nvnWindowAcquireTexture) { } uint64_t *fe = img_fence_of(o, idx), want = fe ? *fe : 0; if (acq_wait == 2) want = last_present_fence; - if (acq_wait && want) { + if (acq_wait && want) { // the back end's wait counts it as a fence wait (vk_sync.c vk_sync_fence_wait), not pacing const GfxBackend *b = gfx_backend(); - if (b->fence_done() < want) { - uint64_t p0 = perf_begin(); - b->fence_wait(want, UINT64_MAX); - perf_end(PERF_PACE, p0); - } + if (b->fence_done() < want) b->fence_wait(want, UINT64_MAX); } if (gfx_backend()->frame_start) gfx_backend()->frame_start(); // the frame's work starts here // The sync means "the display no longer reads this image". Presents are copies queued in submit order, so it is diff --git a/runtime/perf.c b/runtime/perf.c index c5904e40..f776e4c4 100644 --- a/runtime/perf.c +++ b/runtime/perf.c @@ -98,6 +98,22 @@ void perf_end(int kind, uint64_t t0) { __atomic_fetch_add(&frame_ns[kind], d, __ATOMIC_RELAXED); } +// The waits of other threads that hold the frame all the same: a game may acquire its window image on a thread other +// than the one that presents (vk_lowlat.c's comments note it), and perf_end leaves those waits out, so the pacer's +// wait in the acquire showed nowhere. Added to frame_ns and wait_ns by the present (perf_present) before the frame's +// parts are read. +static volatile int64_t any_ns[PERF_N]; + +void perf_end_any(int kind, uint64_t t0) { + if (!t0 || (unsigned)kind >= PERF_N) return; + uint32_t tid = plat_thread_id(); + if (tid == prof_render_tid || tid == prof_replay_tid) { + perf_end(kind, t0); + return; + } + plat_add64(&any_ns[kind], (int64_t)(kern_now_ns() - t0)); +} + static volatile int64_t other_wait_ns; // perf_gpu_wait on threads other than the render thread, over the window static volatile int64_t render_wait_ns; // the same on the render thread void (*perf_gpu_stats)(PerfGpu *out); @@ -454,10 +470,12 @@ typedef struct { // them in, every frame that waited 900 ms for a pipeline was charged to "replay", the larger number, and a log // could not tell a pipeline stall from a slow replay. // "census" is the address-space walk of NX2NAVI_MEM_CENSUS (census_check), which runs on the presenting thread after a -// present: its time is charged to the next frame, which it delays. -enum { FT_C_PIPE, FT_C_XLATE, FT_C_TEX, FT_C_FENCE, FT_C_PACE, FT_C_REPLAY, FT_C_CENSUS, FT_C_OTHER, FT_C_N }; -static const char *const ft_cause_name[FT_C_N] = { "pipeline", "translation", "texture", "fence", "pacing", "replay", - "census", "unattributed" }; +// present: its time is charged to the next frame, which it delays. "hand-off" is the wait for the present thread to +// take the previous picture (PERF_HANDOFF): its own pacing and its present call, an overlay's frame limiter included. +// stutter_map.c cause_short and tools/stutter_map.py read these names, in this order. +enum { FT_C_PIPE, FT_C_XLATE, FT_C_TEX, FT_C_FENCE, FT_C_PACE, FT_C_HANDOFF, FT_C_REPLAY, FT_C_CENSUS, FT_C_OTHER, FT_C_N }; +static const char *const ft_cause_name[FT_C_N] = { "pipeline", "translation", "texture", "fence", "pacing", "hand-off", + "replay", "census", "unattributed" }; static uint64_t census_part_ns; // present thread: the census walks since the last present (census_check) static struct { uint64_t t0, frames, sum, over25, over50, over100; @@ -647,10 +665,11 @@ static void ft_report(uint64_t now, const char *tag) { (unsigned long long)w->op_n[PERF_RP_DRAW], w->op_ns[PERF_RP_BIND] / 1e6, (unsigned long long)w->op_n[PERF_RP_BIND], w->op_ns[PERF_RP_XFER] / 1e6, (unsigned long long)w->op_n[PERF_RP_XFER], nvn_op_name(w->max_op), w->max_ns / 1e6, w->hold_ns / 1e6); - rt_log("frametime: worst frame %llu: %.1f ms; shader translation %.1f, pipeline build %.1f, texture upload %.1f (astc %.1f), replay %.1f (on the CPU %.1f), fence/present wait %.1f, pacing %.1f%s", + rt_log("frametime: worst frame %llu: %.1f ms; shader translation %.1f, pipeline build %.1f, texture upload %.1f (astc %.1f), replay %.1f (on the CPU %.1f), fence/present wait %.1f, pacing %.1f, hand-off %.1f%s", (unsigned long long)w->frame, w->ns / 1e6, w->wait[PERF_XLATE] / 1e6, w->wait[PERF_PIPE] / 1e6, w->wait[PERF_TEX] / 1e6, w->wait[PERF_ASTC] / 1e6, w->replay / 1e6, w->replay_cpu / 1e6, - (w->wait[PERF_FENCE] + w->wait[PERF_DRAIN]) / 1e6, w->wait[PERF_PACE] / 1e6, ops); + (w->wait[PERF_FENCE] + w->wait[PERF_DRAIN]) / 1e6, w->wait[PERF_PACE] / 1e6, + w->wait[PERF_HANDOFF] / 1e6, ops); } } memset(&ft, 0, sizeof ft); @@ -741,6 +760,7 @@ static uint64_t ft_frame(uint64_t frame, uint64_t now, uint64_t d) { part[FT_C_TEX] = frame_ns[PERF_TEX]; part[FT_C_FENCE] = frame_ns[PERF_FENCE] + frame_ns[PERF_DRAIN]; part[FT_C_PACE] = frame_ns[PERF_PACE]; + part[FT_C_HANDOFF] = frame_ns[PERF_HANDOFF]; part[FT_C_REPLAY] = rep > 0 ? (uint64_t)rep : 0; uint64_t inside = part[FT_C_PIPE] + part[FT_C_XLATE] + part[FT_C_TEX]; // waits on the replay thread part[FT_C_REPLAY] = part[FT_C_REPLAY] > inside ? part[FT_C_REPLAY] - inside : 0; @@ -997,6 +1017,10 @@ void perf_present(uint64_t frame) { if (rt_trace & RT_TRACE_SCHED) kern_sched_report(frame); uint64_t now = kern_now_ns(), d = last ? now - last : 0; prof_sampler_frame(frame, now, last ? d : 0); + for (int k = 0; k < PERF_N; k++) { // other threads' waits for this frame (perf_end_any), before its parts are read + int64_t a = __atomic_load_n(&any_ns[k], __ATOMIC_RELAXED) ? plat_xchg64(&any_ns[k], 0) : 0; + if (a > 0) __atomic_fetch_add(&frame_ns[k], (uint64_t)a, __ATOMIC_RELAXED), __atomic_fetch_add(&wait_ns[k], (uint64_t)a, __ATOMIC_RELAXED); + } uint64_t rep = ft_frame(frame, now, d); // d is 0 on the first present: it only starts the period if (__atomic_load_n(&session_due, __ATOMIC_RELAXED) && plat_xchg32(&session_due, 0)) session_report(now); ab_b += rt_ab(); @@ -1035,13 +1059,14 @@ void perf_present(uint64_t frame) { char marks[700]; marks[0] = 0; mark_text(&fm, marks, 0, sizeof marks); - // drain: the wait for the present thread's previous job; replay: the replays since the last present, the - // pipeline, translation and texture waits above included (the rest of a slow frame is the game's own work) + // drain: the wait for the present thread's previous job; handoff: the wait to hand it the next one; + // replay: the replays since the last present, the pipeline, translation and texture waits above included + // (the rest of a slow frame is the game's own work) rt_log("perf: slow frame %llu: %.1f ms; blocked pipeline %.1f xlate %.1f texture %.1f astc %.1f fence %.1f pacing %.1f " - "drain %.1f; replay %.1f%s", + "drain %.1f handoff %.1f; replay %.1f%s", (unsigned long long)frame, d / 1e6, frame_ns[PERF_PIPE] / 1e6, frame_ns[PERF_XLATE] / 1e6, frame_ns[PERF_TEX] / 1e6, frame_ns[PERF_ASTC] / 1e6, frame_ns[PERF_FENCE] / 1e6, - frame_ns[PERF_PACE] / 1e6, frame_ns[PERF_DRAIN] / 1e6, rep / 1e6, marks); + frame_ns[PERF_PACE] / 1e6, frame_ns[PERF_DRAIN] / 1e6, frame_ns[PERF_HANDOFF] / 1e6, rep / 1e6, marks); } } memset(frame_ns, 0, sizeof frame_ns); @@ -1065,9 +1090,9 @@ void perf_present(uint64_t frame) { uint64_t dwin[3]; for (int i = 0; i < 3; i++) dwin[i] = disk[i] - disk_prev[i], disk_prev[i] = disk[i]; if (n && span) - rt_log("perf: frame %llu: interval avg %.2f ms max %.2f ms (%.1f fps); render thread blocked: pacing %.0f%% fence %.0f%% drain %.0f%% pipeline build %.0f%% shader xlate %.0f%% texture %.0f%% (astc %.0f%%); pipelines built in background %lld, draws skipped pending %lld, waited %lld, waiting for a shader %lld, one-shot waited %lld; textures uploaded %lld re-uploaded %lld; slowest frame: xlate %.1f ms texture %.1f ms (astc %.1f) pipeline %.1f ms fence %.1f ms; shaders: %llu keys, %llu translated; render busy avg %.2f ms; replay avg %.2f ms; ab %llu/%llu; world %.1f s; shader disk reads: %llu on the render thread (%.1f ms), %llu by the loaders", + rt_log("perf: frame %llu: interval avg %.2f ms max %.2f ms (%.1f fps); render thread blocked: pacing %.0f%% fence %.0f%% drain %.0f%% handoff %.0f%% pipeline build %.0f%% shader xlate %.0f%% texture %.0f%% (astc %.0f%%); pipelines built in background %lld, draws skipped pending %lld, waited %lld, waiting for a shader %lld, one-shot waited %lld; textures uploaded %lld re-uploaded %lld; slowest frame: xlate %.1f ms texture %.1f ms (astc %.1f) pipeline %.1f ms fence %.1f ms; shaders: %llu keys, %llu translated; render busy avg %.2f ms; replay avg %.2f ms; ab %llu/%llu; world %.1f s; shader disk reads: %llu on the render thread (%.1f ms), %llu by the loaders", (unsigned long long)frame, sum / 1e6 / n, max / 1e6, n * 1e9 / sum, 100.0 * wait_ns[PERF_PACE] / span, - 100.0 * wait_ns[PERF_FENCE] / span, 100.0 * wait_ns[PERF_DRAIN] / span, + 100.0 * wait_ns[PERF_FENCE] / span, 100.0 * wait_ns[PERF_DRAIN] / span, 100.0 * wait_ns[PERF_HANDOFF] / span, 100.0 * wait_ns[PERF_PIPE] / span, 100.0 * wait_ns[PERF_XLATE] / span, 100.0 * wait_ns[PERF_TEX] / span, 100.0 * wait_ns[PERF_ASTC] / span, (long long)async, (long long)skips, (long long)waited, (long long)sskip, (long long)oneshot, (long long)up, (long long)reup, worst_ns[PERF_XLATE] / 1e6, worst_ns[PERF_TEX] / 1e6, diff --git a/runtime/stutter_map.c b/runtime/stutter_map.c index 2263b930..e5cf5ffd 100644 --- a/runtime/stutter_map.c +++ b/runtime/stutter_map.c @@ -18,7 +18,7 @@ // 96 ms after an area load (2026-11-13) each counted as a change of pace before, as each was followed by one as long. // // What a hitch went to comes from the frame-time summary's split (perf.c ft_frame: pipeline, translation, texture, -// fence, pacing, replay, unattributed), with the draws that met a pipeline or a shader missing between the previous +// fence, pacing, hand-off, replay, census, unattributed), with the draws that met a pipeline or a shader missing between the previous // present and this one (stutter_miss, from the replay thread). Each hitch gets a "stutter:" line, at most // SM_LINES_PER_S a second and SM_LINES_MAX in all; the counts go on past that. Every SM_REPORT_NS of play, when the // window loses the focus in play (perf.c session_report) and at exit, @@ -42,7 +42,7 @@ int stutter_map_on; #define SM_AREAS 128 // areas kept by name; later ones share the last slot -#define SM_CAUSES 8 +#define SM_CAUSES 9 // perf.c's FT_C_N #define SM_LOAD_NS 3000000000ull // after an area load, frames count as the load's for this long #define SM_HITCH_MIN_NS 12000000.0 // a hitch is at least this long... #define SM_HITCH_ANY_NS 25000000ull // ...and any frame over this is one @@ -364,9 +364,10 @@ void stutter_frame(uint64_t frame, uint64_t now, uint64_t d, const uint64_t *par } } -// In the order of perf.c's causes (FT_C_*); "census" is NX2NAVI_MEM_CENSUS's walk of the address space. -static const char *const cause_short[SM_CAUSES] = {"pipeline", "translation", "texture", "fence", "pacing", "replay", - "census", "unattributed"}; +// In the order of perf.c's causes (FT_C_*); "hand-off" is the wait for the present thread to take the previous picture, +// "census" NX2NAVI_MEM_CENSUS's walk of the address space. +static const char *const cause_short[SM_CAUSES] = {"pipeline", "translation", "texture", "fence", "pacing", "hand-off", + "replay", "census", "unattributed"}; static int area_cmp(const void *x, const void *y) { const Area *a = &areas[*(const int *)x], *b = &areas[*(const int *)y]; diff --git a/runtime/vk_backend.c b/runtime/vk_backend.c index 6963c991..09ec2e10 100644 --- a/runtime/vk_backend.c +++ b/runtime/vk_backend.c @@ -40,7 +40,8 @@ #define WEAK __attribute__((weak)) -typedef struct { VkImage image; VkFormat format; int w, h, has_crop, crop[4]; uint64_t frame, at, queued, value; } PresentJob; +// handoff_ns: how long the presenting thread waited to hand this job over (present_image), for the present lines +typedef struct { VkImage image; VkFormat format; int w, h, has_crop, crop[4]; uint64_t frame, at, queued, value, handoff_ns; } PresentJob; static PlatMutex pl = PLAT_MUTEX_INIT; static PlatCond pcv = PLAT_COND_INIT; // job queued, job taken, job submitted @@ -76,9 +77,31 @@ static void pace_shown(uint64_t interval_ns) { pace_avg_ns = pace_avg_ns ? pace_avg_ns + (uint64_t)(((int64_t)interval_ns - (int64_t)pace_avg_ns) / 4) : interval_ns; } +// NX2NAVI_TRACE=perf: the present thread's own window of PW_PRESENTS presents. The render thread's perf lines time the +// game's side and the hand-off; these say where the present thread's time went: the blit and its submission, the +// wait for the picture's time (pace_smooth), and the present call, which takes the queue lock and in which an overlay +// with a frame limiter sleeps. With the presenting thread's wait to hand each picture over, which that time causes. +#define PW_PRESENTS 60 +typedef struct { uint64_t n, blit, wait, call, call_max, past, hand, hand_max; } PresentWin; + +static void present_window(PresentWin *w, uint64_t frame, uint64_t blit, uint64_t wait, uint64_t call, uint64_t past, + uint64_t hand) { + w->n++, w->blit += blit, w->wait += wait, w->call += call, w->past += past, w->hand += hand; + if (call > w->call_max) w->call_max = call; + if (hand > w->hand_max) w->hand_max = hand; + if (w->n < PW_PRESENTS) return; + double n = (double)w->n; + rt_log("perf: present thread frame %llu: %llu presents; blit and submit avg %.2f ms, paced wait avg %.2f ms, present " + "call avg %.2f ms max %.2f ms, past target avg %.2f ms; the presenting thread waited to hand over avg %.2f ms " + "max %.2f ms", (unsigned long long)frame, (unsigned long long)w->n, w->blit / 1e6 / n, w->wait / 1e6 / n, + w->call / 1e6 / n, w->call_max / 1e6, w->past / 1e6 / n, w->hand / 1e6 / n, w->hand_max / 1e6); + memset(w, 0, sizeof *w); +} + static void present_main(void *arg) { (void)arg; uint64_t last = 0, last_queued = 0; + PresentWin win = {0}; plat_mutex_lock(&pl); for (;;) { while (!pending) plat_cond_wait(&pcv, &pl); @@ -87,6 +110,8 @@ static void present_main(void *arg) { busy = 1; plat_cond_broadcast(&pcv); plat_mutex_unlock(&pl); + int timed = (rt_trace & (RT_TRACE_PRESENT | RT_TRACE_PERF)) != 0; + uint64_t b0 = timed ? kern_now_ns() : 0; if (flight_on || vk_dump_white) vk_thumbs_frame(j.frame); // NX2NAVI_DUMP_WHITE reads them too vk_dlssg_present_frame(j.frame); vk_lowlat_present_frame(j.frame); // the frame's number for the blit's submit and the present's markers @@ -104,14 +129,18 @@ static void present_main(void *arg) { uint64_t t1 = kern_now_ns(); if (last) pace_shown(t1 - last); vk_present_flip(); + uint64_t t2 = timed ? kern_now_ns() : 0; perfmon_shown(t1); // the overlay's frame times: the pictures as shown // NX2NAVI_TRACE=present: one line per present: the host present's interval, the interval of the game's present - // calls (when the host present went out before back-edge pacing), the wait and how far past its target it went + // calls (when the host present went out before back-edge pacing), the wait and how far past its target it went; + // then how long the present call took and how long the presenting thread waited to hand this picture over if (rt_trace & RT_TRACE_PRESENT) - rt_log("present: frame %llu interval %.3f ms, game %.3f ms, waited %.3f ms, %.3f ms past target", - (unsigned long long)j.frame, last ? (t1 - last) / 1e6 : 0.0, + rt_log("present: frame %llu interval %.3f ms, game %.3f ms, waited %.3f ms, %.3f ms past target; present call " + "%.3f ms, hand-off %.3f ms", (unsigned long long)j.frame, last ? (t1 - last) / 1e6 : 0.0, last_queued ? (j.queued - last_queued) / 1e6 : 0.0, (t1 - t0) / 1e6, - j.at && t1 > j.at ? (t1 - j.at) / 1e6 : 0.0); + j.at && t1 > j.at ? (t1 - j.at) / 1e6 : 0.0, (t2 - t1) / 1e6, j.handoff_ns / 1e6); + if (rt_trace & RT_TRACE_PERF) + present_window(&win, j.frame, t0 - b0, t1 - t0, t2 - t1, j.at && t1 > j.at ? t1 - j.at : 0, j.handoff_ns); last = t1; last_queued = j.queued; vk_pipeline_autosave(); // starts the autosave thread once @@ -258,11 +287,16 @@ static void present_image(const tex_t *t, const int crop[4], uint64_t at_ns, uin if (!plat_thread_spawn(present_main, NULL, "vk present", 0)) rt_fatal("vk: cannot start the present thread"); present_thread = 1; } - while (pending) plat_cond_wait(&pcv, &pl); // one present in waiting at most + // One present in waiting at most: the wait for the present thread to take the previous one is the hand-off + // (PERF_HANDOFF), timed from under pl, where pending is read. + uint64_t h0 = pending ? perf_begin() : 0; + while (pending) plat_cond_wait(&pcv, &pl); + j.handoff_ns = h0 ? kern_now_ns() - h0 : 0; job = j; pending = 1; plat_cond_broadcast(&pcv); plat_mutex_unlock(&pl); + perf_end(PERF_HANDOFF, h0); if (rdoc_active()) { vk_present_drain(); rdoc_after_present(frame); } } diff --git a/tests/perf_summary_check.py b/tests/perf_summary_check.py new file mode 100644 index 00000000..a246da8b --- /dev/null +++ b/tests/perf_summary_check.py @@ -0,0 +1,106 @@ +"""tools/perf_summary.py reads the present side of a log: lines made with the runtime's format strings (copied below; +keep them in step with runtime/perf.c perf_present and runtime/vk_backend.c present_main and present_window) give the +present percentiles, the present thread's window averages and the render thread's hand-off share, and the lines of +older logs (no hand-off share, no present call or hand-off on the `present:` lines) still parse. + + python tests/perf_summary_check.py +""" +import re +import subprocess +import sys +import tempfile +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +TOOL = ROOT / 'tools' / 'perf_summary.py' + + +def c_fmt(fmt, *args): + """A C printf format with %llu, %lld and %u as Python's %d and %% kept.""" + return fmt.replace('%llu', '%d').replace('%lld', '%d').replace('%u', '%d') % args + + +# runtime/vk_backend.c present_main's TRACE=present line and present_window's line, as the C source has them +PRESENT_OLD = 'present: frame %llu interval %.3f ms, game %.3f ms, waited %.3f ms, %.3f ms past target' +PRESENT_TAIL = '; present call %.3f ms, hand-off %.3f ms' +WINDOW = ('perf: present thread frame %llu: %llu presents; blit and submit avg %.2f ms, paced wait avg %.2f ms, present ' + 'call avg %.2f ms max %.2f ms, past target avg %.2f ms; the presenting thread waited to hand over avg %.2f ms ' + 'max %.2f ms') +# runtime/perf.c perf_present's window line, its head to the shares (the rest is filled in below) +PERF_HEAD = ('perf: frame %llu: interval avg %.2f ms max %.2f ms (%.1f fps); render thread blocked: pacing %.0f%% fence ' + '%.0f%% drain %.0f%% handoff %.0f%% pipeline build %.0f%% shader xlate %.0f%% texture %.0f%% (astc %.0f%%)') +PERF_TAIL = ('; pipelines built in background 0, draws skipped pending 0, waited 0, waiting for a shader 0, one-shot waited ' + '0; textures uploaded 3 re-uploaded 0; slowest frame: xlate 0.0 ms texture 0.0 ms (astc 0.0) pipeline 0.0 ms ' + 'fence 0.0 ms; shaders: 10 keys, 10 translated; render busy avg 5.00 ms; replay avg 3.00 ms; ab 0/60; world ' + '12.0 s; shader disk reads: 0 on the render thread (0.0 ms), 0 by the loaders') + + +def source_has(): + """The format strings above are still the runtime's (the C sources split them over string literals).""" + def joined(path): + text = path.read_text(encoding='utf-8') + return re.sub(r'"\s*\n\s*"', '', text) # adjacent literals on following lines become one + be, perf = joined(ROOT / 'runtime' / 'vk_backend.c'), joined(ROOT / 'runtime' / 'perf.c') + for piece in (PRESENT_OLD + PRESENT_TAIL, WINDOW): + assert piece in be, f'runtime/vk_backend.c no longer has: {piece}' + assert PERF_HEAD in perf, f'runtime/perf.c no longer has: {PERF_HEAD}' + + +def run(lines, lo=0): + with tempfile.TemporaryDirectory() as d: + log = Path(d) / 'nx2navi.log' + log.write_text('\n'.join(lines) + '\n', encoding='utf-8') + out = subprocess.run([sys.executable, str(TOOL), str(log), str(lo)], capture_output=True, text=True, + encoding='utf-8', check=True).stdout + return out + + +def summary(out, head): + found = [ln for ln in out.splitlines() if ln.startswith(head)] + assert len(found) == 1, (head, out) + return found[0] + + +def main(): + source_has() + lines = [] + # 100 presents of the new form: intervals 16.0..16.99 ms, then one 40 ms; the present call 0.1..1.09 ms; the + # hand-off 2.0 ms each but one of 30 ms + for i in range(100): + lines.append('[host] ' + c_fmt(PRESENT_OLD + PRESENT_TAIL, 1000 + i, 16.0 + i / 100, 16.5, 1.0 + i / 100, 0.05, + 0.1 + i / 100, 30.0 if i == 50 else 2.0)) + lines.append('[host] ' + c_fmt(PRESENT_OLD + PRESENT_TAIL, 1100, 40.0, 40.0, 0.0, 0.5, 20.0, 2.0)) + lines.append('[host] ' + c_fmt(WINDOW, 1080, 60, 0.8, 1.5, 0.6, 1.09, 0.05, 2.5, 30.0)) + lines.append('[host] ' + c_fmt(WINDOW, 1140, 60, 1.0, 1.0, 1.0, 20.0, 0.10, 1.5, 3.0)) + lines.append('[host] ' + c_fmt(PERF_HEAD, 1080, 16.7, 40.0, 59.9, 0.0, 2.0, 0.0, 12.0, 0.0, 0.0, 1.0, 0.0) + PERF_TAIL) + lines.append('[host] ' + c_fmt(PERF_HEAD, 1140, 16.7, 20.0, 59.9, 0.0, 2.0, 0.0, 18.0, 0.0, 0.0, 1.0, 0.0) + PERF_TAIL) + out = run(lines) + pres = summary(out, 'SUMMARY present:') + # 101 intervals: p50 is the 51st smallest (16.50), p99 the 100th (16.99), max 40 + assert '101 presents' in pres and 'interval p50 16.50 p95 16.95 p99 16.99 max 40.00' in pres, pres + assert 'present call p50 0.60 p95 1.05 p99 1.09 max 20.00' in pres, pres + assert 'hand-off p50 2.00 p95 2.00 p99 2.00 max 30.00' in pres, pres + win = summary(out, 'SUMMARY present thread:') + assert '120 presents in 2 windows' in win and 'present call avg 0.80 ms max 20.00 ms' in win, win + assert 'hand-off avg 2.00 ms max 30.00 ms' in win, win + frames = summary(out, 'SUMMARY frames') + assert 'blocked at the hand-off 15.0% of the time (the highest window 18%)' in frames, frames + assert 'perf 1080: 59.9 fps max 40.00 pacing 0% handoff 12% pipe 0% tex 1%' in out, out + + # an older log: no hand-off share on the perf line, no present call or hand-off on the present lines + old_perf = PERF_HEAD.replace(' handoff %.0f%%', '') + old = ['[host] ' + c_fmt(PRESENT_OLD, 2000 + i, 16.0 + i / 10, 16.5, 1.0, 0.0) for i in range(10)] + old.append('[host] ' + c_fmt(old_perf, 2040, 16.7, 20.0, 59.9, 0.0, 2.0, 0.0, 0.0, 0.0, 1.0, 0.0) + PERF_TAIL) + out = run(old) + pres = summary(out, 'SUMMARY present:') + assert '10 presents' in pres and 'interval p50 16.50' in pres and 'present call' not in pres, pres + assert 'hand-off' not in pres, pres + assert 'SUMMARY present thread' not in out, out + frames = summary(out, 'SUMMARY frames') + assert 'hand-off' not in frames and 'perf 2040: 59.9 fps max 20.00 pacing 0% pipe 0% tex 1%' in out, out + print('perf_summary_check: ok') + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tests/stutter_hitch_check.c b/tests/stutter_hitch_check.c index 133c4a35..f98073fe 100644 --- a/tests/stutter_hitch_check.c +++ b/tests/stutter_hitch_check.c @@ -17,18 +17,20 @@ void rt_log(const char *fmt, ...) { logged++; } -// perf.c's causes, in its order (FT_C_*) -static const char *const names[8] = {"pipeline", "translation", "texture", "fence", "pacing", "replay", "census", - "unattributed"}; +// perf.c's causes, in its order (FT_C_*); the frames below are charged to the last, unattributed +static const char *const names[] = {"pipeline", "translation", "texture", "fence", "pacing", "hand-off", "replay", + "census", "unattributed"}; +#define OTHER (SM_CAUSES - 1) +_Static_assert(sizeof names / sizeof *names == SM_CAUSES, "names follows perf.c's FT_C_* list"); static uint64_t frame_no; static void frames(int n, double ms) { - uint64_t part[8] = {0}; + uint64_t part[SM_CAUSES] = {0}; for (int i = 0; i < n; i++) { uint64_t d = (uint64_t)(ms * 1e6); clock_ns += d; - part[7] = d; - stutter_frame(++frame_no, clock_ns, d, part, names, 8, 7); + part[OTHER] = d; + stutter_frame(++frame_no, clock_ns, d, part, names, SM_CAUSES, OTHER); } } @@ -55,11 +57,11 @@ int main(void) { expect("a double spike", areas[0].hitch, 7); // three long frames, each followed by one as long, as after an area load in a session of 2026-11-13 (87, 91 and // 96 ms): one episode, not three changes of pace - uint64_t paced0 = paced_out, charged0 = areas[0].cause_ns[7]; + uint64_t paced0 = paced_out, charged0 = areas[0].cause_ns[OTHER]; frames(1, 87.0), frames(1, 91.0), frames(1, 96.0), frames(60, 7.0); expect("three slow frames in a row", areas[0].hitch, 8); expect("not a change of pace", paced_out, paced0); - expect("the episode's time", areas[0].cause_ns[7] - charged0, 274000000ull); + expect("the episode's time", areas[0].cause_ns[OTHER] - charged0, 274000000ull); // a change to 30 fps from 140: a run of long frames longer than SM_EPISODE_MAX, a change of pace frames(200, 7.0); frames(300, 33.3); @@ -90,7 +92,7 @@ int main(void) { for (int k = 0; k < 5; k++) frames(1, 120.0), frames(59, 33.3); expect("five hitches at 30 fps", areas[3].hitch, 5); expect("five hitches at 30 fps (worst)", areas[3].worst_ns, 120000000ull); - expect("five hitches at 30 fps (their time)", areas[3].cause_ns[7], 600000000ull); + expect("five hitches at 30 fps (their time)", areas[3].cause_ns[OTHER], 600000000ull); if (!logged) printf("FAIL nothing was logged\n"), fails++; if (fails) return 1; printf("stutter_hitch_check: all checks passed\n"); diff --git a/tests/stutter_map_check.py b/tests/stutter_map_check.py index 93379abd..bc346c14 100644 --- a/tests/stutter_map_check.py +++ b/tests/stutter_map_check.py @@ -42,12 +42,16 @@ def main(): '[host] ' + c_fmt('stutter: frame %llu at %.1f s, %.1f ms (frames about %.1f ms) in %s%s:%s; an episode of %d ' "frames to frame %llu, %.1f ms the first, the parts above the first frame's", 1400, 90.0, 274.0, 7.0, 'Kakariko Village', '', ' fence 77.1 replay 4.0 (charged to fence)', 3, 1402, 87.0), + # a cause with a hyphen in its name + '[host] ' + c_fmt('stutter: frame %llu at %.1f s, %.1f ms (frames about %.1f ms) in %s%s:', 1500, 95.0, 41.0, 7.0, + 'Kakariko Village', '') + ' hand-off 33.0 (charged to hand-off)', '[host] ' + c_fmt('stutter map (%s): %.1f min of play in %d areas; %llu hitches in play and %llu ' 'after area loads; %llu long frames were a change of pace (the frames after them as long), not ' - 'hitches; in play by cause:', 'exit', 12.5, 2, 3, 1, 7) + ' pipeline 2 texture 1', + 'hitches; in play by cause:', 'exit', 12.5, 2, 4, 1, 7) + ' pipeline 2 texture 1 hand-off 1', '[host] ' + c_fmt('stutter map: %s: %.1f min at %.0f fps; hitches %llu (%.2f a minute', 'Kakariko Village', 10.0, - 139.6, 3, 0.3) + 139.6, 4, 0.4) + c_fmt('; %s %llu, %.1f ms avg', 'pipeline', 2, 30.2) + c_fmt('; %s %llu, %.1f ms avg', 'texture', 1, 19.0) + + c_fmt('; %s %llu, %.1f ms avg', 'hand-off', 1, 41.0) + c_fmt('), worst %.1f ms (frame %llu); over 25 ms %llu; after its ' 'loads %llu; draws that met a pipeline missing %llu, a shader %llu, %.1f ms on the replay thread', 31.5, 1200, 1, 1, 4, 1, 40.2), @@ -68,22 +72,25 @@ def main(): log = Path(d) / 'nx2navi.log' log.write_text('\n'.join(lines) + '\n', encoding='utf-8') block, hitches = stutter_map.read_log(log) - assert block and block['head'][0] == 'exit' and block['head'][3] == '3', block and block['head'] + assert block and block['head'][0] == 'exit' and block['head'][3] == '4', block and block['head'] a = block['areas'][0] - assert a['name'] == 'Kakariko Village' and a['hitch'] == 3 and a['causes'] == {'pipeline': 2, 'texture': 1}, a + assert a['name'] == 'Kakariko Village' and a['hitch'] == 4, a + assert a['causes'] == {'pipeline': 2, 'texture': 1, 'hand-off': 1}, a assert a['pmiss'] == 4 and a['smiss'] == 1 and a['load'] == 1 and a['over25'] == 1, a assert block['areas'][1]['causes'] == {}, block['areas'][1] assert block['sum'] == (2, 1, 1, 1, 0), block['sum'] p = block['pipes'][0] assert p['v'] == '1a2b3c4d' and p['f'] == '5e6f7a8b' and p['ready'] == 160 and p['misses'] == 3, p assert p['state'].startswith('new to this install'), p - assert len(hitches) == 3 and hitches[0]['cause'] == 'pipeline' and hitches[1]['load'], hitches + assert len(hitches) == 4 and hitches[0]['cause'] == 'pipeline' and hitches[1]['load'], hitches assert hitches[2]['ms'] == 274.0 and hitches[2]['cause'] == 'fence' and not hitches[2]['load'], hitches[2] + assert hitches[3]['cause'] == 'hand-off', hitches[3] out = Path(d) / 'map.md' stutter_map.report([log], out) text = out.read_text(encoding='utf-8') - assert block['head'][5] == '7' and block['head'][6] == ' pipeline 2 texture 1', block['head'] - assert '7 long frames left out' in text and '**3 hitches in play**' in text and '| Kakariko Village | 10.0 | 140 |' in text, text + assert block['head'][5] == '7' and block['head'][6] == ' pipeline 2 texture 1 hand-off 1', block['head'] + assert '7 long frames left out' in text and '**4 hitches in play**' in text and '| Kakariko Village | 10.0 | 140 |' in text, text + assert 'hand-off 1' in text, text print('stutter_map_check: ok') return 0 diff --git a/tools/flight_view.py b/tools/flight_view.py index 85583c6d..5c891f30 100644 --- a/tools/flight_view.py +++ b/tools/flight_view.py @@ -14,14 +14,14 @@ from pathlib import Path from PIL import Image, ImageDraw -BLOCKED = ['pace_ms', 'fence_ms', 'drain_ms', 'pipe_ms', 'xlate_ms', 'tex_ms', 'astc_ms'] +BLOCKED = ['pace_ms', 'fence_ms', 'drain_ms', 'pipe_ms', 'xlate_ms', 'tex_ms', 'astc_ms', 'handoff_ms'] # Counts that are 0 in a steady frame: any non-zero value is listed. RARE = ['shaders_xlated', 'pipe_built', 'pipe_waited', 'oneshot_waited', 'pipe_bg_used', 'draws_skip_pipe', 'draws_skip_shader', 'tex_new', 'tex_alias', 'tex_up', 'tex_reup', 'wb_done', 'wb_skip'] # Counts with a steady level: frames off the median by more than a quarter are listed. LEVEL = ['submits', 'passes', 'draws', 'draws_seen', 'clears', 'copies', 'dispatches'] SHORT = {'interval_ms': 'ms', 'pace_ms': 'pace', 'fence_ms': 'fence', 'drain_ms': 'drain', 'pipe_ms': 'pipe', - 'xlate_ms': 'xlate', 'tex_ms': 'tex', 'astc_ms': 'astc'} + 'xlate_ms': 'xlate', 'tex_ms': 'tex', 'astc_ms': 'astc', 'handoff_ms': 'handoff'} def load(dump): diff --git a/tools/perf_summary.py b/tools/perf_summary.py index 17826032..3018929b 100644 --- a/tools/perf_summary.py +++ b/tools/perf_summary.py @@ -4,6 +4,12 @@ `mem: dirty` lines (vk_memory.c dirty census) are summarised per pool class (CPU_CACHED, CPU_UNCACHED, other): what a device-local mirror of buffer-bound pools would upload per frame and per submit, FlushMappedRange use, mirror size. + +The present side (runtime/vk_backend.c present_main): the `present:` lines of NX2NAVI_TRACE=present give percentiles +of the host present's interval, its paced wait, how far past its target it went, the present call and the presenting +thread's hand-off wait (the last two only in logs that have them), and the `perf: present thread` lines of +NX2NAVI_TRACE=perf the present thread's averages per window. The render thread's hand-off share is read from the perf +lines that have it. """ import re import statistics @@ -14,6 +20,12 @@ PERF = re.compile(r'perf: frame (\d+): interval avg ([\d.]+) ms max ([\d.]+) ms GPU = re.compile(r'perf: frame (\d+): gpu avg (?:([\d.]+) ms|n/a).*?fence wait per frame: render thread ([\d.]+) ms, ' r'other threads ([\d.]+) ms; vram (?:([\d.]+) of ([\d.]+) MiB|n/a).*?ram working set ([\d.]+) MiB, ' r'private ([\d.]+) MiB; bound: (\w+)') +HANDOFF = re.compile(r' handoff (\d+)% ') +PRESENT = re.compile(r'present: frame (\d+) interval ([\d.]+) ms, game ([\d.]+) ms, waited ([\d.]+) ms, ([\d.]+) ms past ' + r'target(?:; present call ([\d.]+) ms, hand-off ([\d.]+) ms)?') +PRESENT_WIN = re.compile(r'perf: present thread frame (\d+): (\d+) presents; blit and submit avg ([\d.]+) ms, paced wait ' + r'avg ([\d.]+) ms, present call avg ([\d.]+) ms max ([\d.]+) ms, past target avg ([\d.]+) ms; ' + r'the presenting thread waited to hand over avg ([\d.]+) ms max ([\d.]+) ms') SCHED = re.compile(r'sched: frame (\d+): (.*)') THREAD = re.compile(r'sched: (render )?(0x[0-9a-f]+) (p\d+ m\d+) run (\d+)% core (\d+)% host (\d+)% sleep (\d+)% ' r'sync (\d+)% cv (\d+)% lock (\d+)% addr (\d+)% cpu (\d+)% blocks (\d+) preempted (\d+)') @@ -30,8 +42,34 @@ def dirty_fields(text): def p95(v): + return pct(v, 0.95) + + +def pct(v, q): + """The q quantile of v (nearest rank below), 0 for none.""" v = sorted(v) - return v[min(len(v) - 1, int(0.95 * len(v)))] if v else 0.0 + return v[min(len(v) - 1, int(q * len(v)))] if v else 0.0 + + +def present_summary(pres, wins): + """pres: {field: [ms]} of the window's `present:` lines; wins: the `perf: present thread` lines' fields.""" + if pres.get('interval'): + parts = [] + for key, name in (('interval', 'interval'), ('waited', 'paced wait'), ('past', 'past target'), + ('call', 'present call'), ('handoff', 'hand-off')): + v = pres.get(key) + if v: + parts.append(f'{name} p50 {pct(v, 0.5):.2f} p95 {pct(v, 0.95):.2f} p99 {pct(v, 0.99):.2f} ' + f'max {max(v):.2f}') + print(f'SUMMARY present: {len(pres["interval"])} presents; ' + '; '.join(parts) + ' (ms)') + if wins: + n = sum(w[0] for w in wins) + + def avg(i): # present-weighted mean of a window average + return sum(w[i] * w[0] for w in wins) / n + print(f'SUMMARY present thread: {n} presents in {len(wins)} windows; blit and submit avg {avg(1):.2f} ms, paced ' + f'wait avg {avg(2):.2f} ms, present call avg {avg(3):.2f} ms max {max(w[4] for w in wins):.2f} ms, past ' + f'target avg {avg(5):.2f} ms; hand-off avg {avg(6):.2f} ms max {max(w[7] for w in wins):.2f} ms') def dirty_summary(lines, frames): @@ -70,6 +108,7 @@ def main(): hi = int(sys.argv[3]) if len(sys.argv) > 3 else 10**9 fr, fps, mx, gpu, vram, ram, bound = None, [], [], [], [], [], {} dirty, dframes, dlast = [], [], None + pres, wins, handoff = {}, [], [] for line in open(sys.argv[1], encoding='utf-8', errors='replace'): if line.startswith('run_game:'): print(line.rstrip()) @@ -87,7 +126,11 @@ def main(): if lo < f <= hi: fps.append(float(m[4])) mx.append(float(m[3])) - print(f'perf {f}: {m[4]} fps max {m[3]} pacing {m[5]}% pipe {m[6]}% tex {m[7]}%') + h = HANDOFF.search(line) + if h: + handoff.append(int(h[1])) + print(f'perf {f}: {m[4]} fps max {m[3]} pacing {m[5]}%' + (f' handoff {h[1]}%' if h else '') + + f' pipe {m[6]}% tex {m[7]}%') elif m := GPU.search(line): f = int(m[1]) if lo < f <= hi: @@ -99,6 +142,16 @@ def main(): bound[m[9]] = bound.get(m[9], 0) + 1 print(f' gpu {f}: {m[2] or "n/a"} ms, fence wait render {m[3]} other {m[4]} ms, ' f'vram {m[5] or "n/a"} MiB, ram ws {m[7]} private {m[8]} MiB, bound {m[9]}') + elif m := PRESENT_WIN.search(line): + f = int(m[1]) + if lo < f <= hi: + wins.append((int(m[2]), *(float(x) for x in m.groups()[2:]))) + elif m := PRESENT.search(line): + f = int(m[1]) + if lo < f <= hi: + for key, g in (('interval', 2), ('waited', 4), ('past', 5), ('call', 6), ('handoff', 7)): + if m[g] is not None and (key != 'interval' or float(m[g]) > 0): + pres.setdefault(key, []).append(float(m[g])) elif m := SCHED.search(line): fr = int(m[1]) if lo < fr <= hi: @@ -110,13 +163,15 @@ def main(): print(f' rw{m[1]}: {m[2]}') if fps: print(f'SUMMARY frames {lo}-{hi}: mean fps {statistics.mean(fps):.1f}, min window fps {min(fps):.1f}, ' - f'max frame {max(mx):.1f} ms') + f'max frame {max(mx):.1f} ms' + (f', render thread blocked at the hand-off {statistics.mean(handoff):.1f}% ' + f'of the time (the highest window {max(handoff)}%)' if handoff else '')) if ram: g = f'gpu mean {statistics.mean(gpu):.2f} ms' if gpu else 'gpu n/a' v = f'vram max {max(u for u, _ in vram):.0f} of {vram[-1][1]:.0f} MiB' if vram else 'vram n/a' b = ', '.join(f'{k} {n}' for k, n in sorted(bound.items())) print(f'SUMMARY gpu: {g}, {v}, ram ws max {max(w for w, _ in ram):.0f} MiB, ' f'private max {max(p for _, p in ram):.0f} MiB; bound windows: {b}') + present_summary(pres, wins) dirty_summary(dirty, dframes) diff --git a/tools/stutter_map.py b/tools/stutter_map.py index fee50c23..81743e6d 100644 --- a/tools/stutter_map.py +++ b/tools/stutter_map.py @@ -27,13 +27,13 @@ HEAD = re.compile(r'stutter map \(([^)]*)\): ([\d.]+) min of play in (\d+) areas AREA = re.compile(r'stutter map: (.+?): ([\d.]+) min at (\d+) fps; hitches (\d+) \(([\d.]+) a minute(.*?)\), worst ' r'([\d.]+) ms \(frame (\d+)\); over 25 ms (\d+); after its loads (\d+); draws that met a pipeline ' r'missing (\d+), a shader (\d+), ([\d.]+) ms on the replay thread') -CAUSE = re.compile(r'; (\w+) (\d+), ([\d.]+) ms avg') +CAUSE = re.compile(r'; ([\w-]+) (\d+), ([\d.]+) ms avg') # hand-off has a hyphen PIPES = re.compile(r'stutter map: (\d+) pipelines draws met missing: (\d+) that this install had recorded before .*?, ' r'(\d+) new to it, (\d+) with a shader translated in play, (\d+) still translating when met') PIPE = re.compile(r'stutter map: (mesh|vertex) (\S+)/(\S+) first met in (.+?): (\d+) draws met it missing, (\d+) its ' r'shader, ([\d.]+) ms on the replay thread; usable after (\d+) ms at most \((\d+) times\); (.*)$') HITCH = re.compile(r'stutter: frame (\d+) at ([\d.]+) s, ([\d.]+) ms \(frames about ([\d.]+) ms\) in (.+?)(, after its ' - r'load)?: .*?\(charged to (\w+)\)') + r'load)?: .*?\(charged to ([\w-]+)\)') def read_log(path):