mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 01:49:59 -04:00
Run every orderly exit through one sequence that puts RivaTuner's profile back before the slow pipeline save.
The window's close, the guest's ExitProcess and the end of a --seconds run each ran their own list. All three waited for the pipeline save (up to 5 s for running builds, then the write) before they put RivaTuner Statistics Server's profile back, stopped HD rumble, wrote the frame-time summary and flushed the save, so a console close, a session end or an "End task" that killed the process in that wait left the game's limit in RTSS's profile (the next run takes it for the player's own), a buzzing controller and no exit summary. ExitProcess also lacked cfg_save and the rumble stop, and it and the window's close had no shared guard, so both could run at once and write the summary twice while the present thread still added to it. gfx_present.c rt_exit_begin is the one guard (the first caller runs; another thread waits for good; the same thread again returns, and svc.c ends the process then rather than resume guest code). rt_exit_steps runs, in order: fs_save_wait (a Commit under way finishes, none is refused), rtss_limit_restore, input_rumble_hd_stop, cfg_save (not for --seconds), the prewarm marker clear, prof_write, vk_mem_exit_log, a non-final log flush (the new logq.c logq_flush, bounded trylocks, queue left on), vk_pipeline_save_exit, and fs_save_flush last. perf.c ft_stop keeps the present thread's frame-time updates out of the exit's summary and waits at most 50 ms, on the exiting thread, for one under way. The restore relies on rtss_limit.c's closed flag to stay restored while frames go on during the pipeline save. The log order changes: "frametime: exit" and the stutter-map exit lines now come before the pipeline save's lines. Not reproduced before the change. tests/exit_order_check.py (new: the step order, the once-guard with a second thread, ft_stop's wait and bound, and statically that the three exits use the helper with the RTSS restore before the pipeline save), tests/logq_check.py (with a logq_flush case), tests/save_share_check.py and the compile checks pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -296,9 +296,40 @@ int main(int argc, char **argv) {
|
||||
at = out_n;
|
||||
for (int i = 0; i < THREADS; i++) next[i] = 0;
|
||||
|
||||
// 9. logq_sync: what is queued is written before it returns, and later lines are written by their own thread. The
|
||||
// lines are logged together just before it, so the log thread is still gathering them (the clock says whether
|
||||
// this thread was in time for that): the batch a fatal error, a crash or the end of the process finds queued.
|
||||
// 9. logq_flush: what is queued is written before it returns, inside the gathering time, and the queue stays on.
|
||||
// With the log thread stuck in a write (the test holds its io lock) it gives up within its bound and writes
|
||||
// nothing, and the line is written once the write is over.
|
||||
uint64_t f0 = plat_now_ns();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
char line[64];
|
||||
int n = snprintf(line, sizeof line, "t 3 %d \n", i);
|
||||
logq_write(line, (size_t)n);
|
||||
}
|
||||
early = out_n - at;
|
||||
in_time = plat_now_ns() - f0 < LOGQ_GATHER_NS / 2;
|
||||
logq_flush();
|
||||
if (in_time) CHECK(!early, "%zu bytes were written before logq_flush, inside the gathering time", early);
|
||||
CHECK(check_lines(at, next, ¬es) == 20, "logq_flush returned before the queued lines were written");
|
||||
CHECK(__atomic_load_n(&Q.on, __ATOMIC_ACQUIRE), "logq_flush turned the queue off");
|
||||
at = out_n;
|
||||
plat_mutex_lock(&Q.io);
|
||||
logq_write("t 3 20 \n", 8);
|
||||
f0 = plat_now_ns();
|
||||
logq_flush();
|
||||
uint64_t gave_up = plat_now_ns() - f0;
|
||||
size_t through = out_n - at;
|
||||
plat_mutex_unlock(&Q.io);
|
||||
settle();
|
||||
CHECK(gave_up < 2000000000ull && !through, "logq_flush with the io lock taken: back after %.0f ms, %zu bytes written",
|
||||
gave_up / 1e6, through);
|
||||
CHECK(check_lines(at, next, ¬es) == 1, "the line queued while logq_flush gave up");
|
||||
at = out_n;
|
||||
for (int i = 0; i < THREADS; i++) next[i] = 0;
|
||||
|
||||
// 10. logq_sync: what is queued is written before it returns, and later lines are written by their own thread. The
|
||||
// lines are logged together just before it, so the log thread is still gathering them (the clock says
|
||||
// whether this thread was in time for that): the batch a fatal error, a crash or the end of the process finds
|
||||
// queued.
|
||||
__atomic_store_n(&sink_ms, 20, __ATOMIC_RELEASE);
|
||||
uint64_t s0 = plat_now_ns();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
|
||||
Reference in New Issue
Block a user