mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 23:59:59 -04:00
Write the end of the run to the log file past its 64 MiB cap, up to a 4 MiB reserve counted on its own.
main.c log_sink wrote nothing to the file once g_log_bytes passed LOG_CAP: every later line, the exit summary, "frametime: exit", the stutter map's exit lines and FATAL and crash lines included, went to stderr only, which a game started from the launcher or Explorer does not keep. A trace = perf session reaches the cap in about 90 minutes (the fresh 0.10.0 log grew 12 KB/s), and the play-test asks for an hour or more of exactly that. A reserve compared against g_log_bytes would not help: that counter adds every line, dropped ones too, so 4 MiB of dropped lines (under 6 minutes at that rate) would use it up before the end came. The new rt_log_ending marks the process as ending; rt_exit_begin (the orderly ends) and perf_summary_flush (the frame-time summary, also on the cheats rebuild exit) call it, and rt_log_sync (a fatal error, the crash report) counts as ending too. The exit summary and the stutter map are written before rt_log_sync, so keying on g_log_final alone would have missed them. While ending, a line past the cap goes to the file through g_log_tail, a counter of the bytes written past the cap, up to LOG_END_RESERVE (4 MiB), after one line saying the end of the run follows. The cut line says the end will still come. The file can end 4 MiB past the cap. perf_summary_flush now calls rt_log_ending before ft_stop, so tests/exit_order_check.py's static check of it wants ft_stop before ft_report rather than first. The check also prints one closing line for the static checks and the program together: the program's own "ok" line had hidden a failing static check. Not reproduced before the change (no log here reached the cap). The new tests/log_cap_check.py builds log_sink with a 4 KiB cap and a 2 KiB reserve: past the cap ordinary lines are dropped with one cut line, and after rt_log_ending or rt_log_sync the end's lines fill the reserve after one "end follows" line, however much was dropped before. exit_order_check (rt_exit_begin marks the end once; exit code 0 at this commit), logq_check and the compile checks pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,8 @@ static char seen[1024];
|
||||
STEP(fs_save_wait) STEP(rtss_limit_restore) STEP(input_rumble_hd_stop) STEP(vk_pipeline_prewarm_marker_clear)
|
||||
STEP(prof_write) STEP(vk_mem_exit_log) STEP(logq_flush) STEP(vk_pipeline_save_exit) STEP(fs_save_flush)
|
||||
static int cfg_save(void) { strcat(seen, "cfg_save "); return 1; }
|
||||
static int ending;
|
||||
static void rt_log_ending(void) { ending++; }
|
||||
'''
|
||||
|
||||
MAIN = r'''
|
||||
@@ -95,9 +97,9 @@ int main(int argc, char **argv) {
|
||||
int first = rt_exit_begin(), again = rt_exit_begin();
|
||||
HANDLE t = CreateThread(NULL, 0, second, NULL, 0, NULL);
|
||||
int parked = WaitForSingleObject(t, 300) == WAIT_TIMEOUT && second_back == -1;
|
||||
printf("once: first caller %d, its own thread again %d, another thread %s\n", first, again,
|
||||
parked ? "stays in rt_exit_begin" : "came back");
|
||||
if (first != 1 || again != 0 || !parked) printf("FAIL: the end must run once\n"), fails++;
|
||||
printf("once: first caller %d, its own thread again %d, another thread %s; the log told of the end %d time(s)\n",
|
||||
first, again, parked ? "stays in rt_exit_begin" : "came back", ending);
|
||||
if (first != 1 || again != 0 || !parked || ending != 1) printf("FAIL: the end must run once\n"), fails++;
|
||||
|
||||
// an update under way: ft_stop waits for it; after ft_stop no update starts
|
||||
HANDLE p = CreateThread(NULL, 0, present, (void *)(intptr_t)20, 0, NULL);
|
||||
@@ -156,8 +158,9 @@ def static_checks():
|
||||
flush = strip_comments(function(perf, 'void perf_summary_flush(void)'))
|
||||
present = strip_comments(function(perf, 'void perf_present(uint64_t frame)'))
|
||||
e, f, s, l = (present.find(x) for x in ('ft_enter()', 'ft_frame(', 'session_report(', 'ft_leave()'))
|
||||
ok = flush[flush.index('{') + 1:].strip().startswith('ft_stop();') and 0 <= e < f < s < l
|
||||
print(f'perf.c: perf_summary_flush starts with ft_stop, perf_present updates inside ft_enter/ft_leave: '
|
||||
stop, report = flush.find('ft_stop();'), flush.find('ft_report(')
|
||||
ok = 0 <= stop < report and 0 <= e < f < s < l
|
||||
print(f'perf.c: perf_summary_flush calls ft_stop before ft_report, perf_present updates inside ft_enter/ft_leave: '
|
||||
f'{"ok" if ok else "FAIL"}')
|
||||
bad += not ok
|
||||
return bad
|
||||
@@ -188,6 +191,7 @@ def main():
|
||||
want_all = ' '.join(STEPS) + ' '
|
||||
want_seconds = ' '.join(s for s in STEPS if s != 'cfg_save') + ' '
|
||||
rc = subprocess.run([str(exe), want_all, want_seconds], env=env, timeout=60).returncode
|
||||
print(f'exit_order_check, the static checks and the program: {"FAILED" if bad or rc else "ok"}')
|
||||
return 1 if bad or rc else 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user