mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 18:09:58 -04:00
With mem_census = 1 the census trigger compared the private bytes with the last census, and Windows charges the video memory to them, so every gigabyte of textures started another 130-260 ms walk on the presenting thread: 22 of the 33 walks of the 2026-11-13 session came from that trigger, while the process's own commit grew 307 MiB in play. The trigger now reads the private bytes less the write-combined memory of the last walk (and what the driver's device-local figure grew since), compares them with the highest figure seen at a census, and waits 60 s after the last walk; the 3600-frame censuses stay. On Windows one walk of the address space now gives both the commit census and the guest regions' committed bytes, which mem_guest_census walked a second time. The census counts the driver's write-combined views apart instead of as guest memory, counts as guest only the reserved guest regions and the loaded modules, and ranks the process's own allocations wherever they lie. The frame after a walk charges its time to a new "census" cause in the frame-time summary and the stutter map instead of "unattributed". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.7 KiB
C
64 lines
2.7 KiB
C
// tests/stutter_hitch_check.py builds this: runtime/stutter_map.c's hitch rule on made-up frame times, with the few
|
|
// runtime functions it calls stubbed. A steady change of pace (the game drawing at 60 fps after 200) counts no hitch;
|
|
// isolated long frames each count one; a frame over SM_HITCH_SURE_NS counts whatever follows it.
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
|
|
#include "../runtime/stutter_map.c"
|
|
|
|
static uint64_t clock_ns;
|
|
int cfg_bool(const char *name) { return !strcmp(name, "NX2NAVI_STUTTER_MAP"); }
|
|
uint64_t kern_now_ns(void) { return clock_ns; }
|
|
void plat_mutex_lock(PlatMutex *m) { (void)m; }
|
|
void plat_mutex_unlock(PlatMutex *m) { (void)m; }
|
|
static int logged;
|
|
void rt_log(const char *fmt, ...) {
|
|
(void)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"};
|
|
static uint64_t frame_no;
|
|
|
|
static void frames(int n, double ms) {
|
|
uint64_t part[8] = {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);
|
|
}
|
|
}
|
|
|
|
static int fails;
|
|
static void expect(const char *what, uint64_t got, uint64_t want) {
|
|
if (got != want) printf("FAIL %s: %llu, expected %llu\n", what, (unsigned long long)got, (unsigned long long)want), fails++;
|
|
}
|
|
|
|
int main(void) {
|
|
stutter_map_init();
|
|
clock_ns = 10000000000ull; // well past any area load
|
|
frames(200, 5.0);
|
|
expect("steady 200 fps", areas[0].hitch, 0);
|
|
frames(300, 16.6); // the game's menus at 60 fps
|
|
expect("a change to 60 fps", areas[0].hitch, 0);
|
|
if (!paced_out) printf("FAIL the change of pace was not counted as one\n"), fails++;
|
|
frames(200, 7.0);
|
|
for (int k = 0; k < 5; k++) frames(1, 30.0), frames(60, 7.0); // five isolated spikes
|
|
expect("five isolated spikes", areas[0].hitch, 5);
|
|
frames(1, 150.0), frames(1, 150.0), frames(60, 7.0); // two long frames in a row: the second stands out
|
|
expect("two frames over the sure line", areas[0].hitch, 7);
|
|
frames(1, 40.0), frames(1, 40.0), frames(60, 7.0); // a double spike: the second one counts
|
|
expect("a double spike", areas[0].hitch, 8);
|
|
stutter_area("Kakariko"); // a load: what follows within SM_LOAD_NS is the load's
|
|
frames(1, 60.0), frames(30, 7.0);
|
|
expect("a spike right after a load (play)", areas[1].hitch, 0);
|
|
expect("a spike right after a load (load)", areas[1].load_hitch, 1);
|
|
if (!logged) printf("FAIL nothing was logged\n"), fails++;
|
|
if (fails) return 1;
|
|
printf("stutter_hitch_check: all checks passed\n");
|
|
return 0;
|
|
}
|