mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 09:19:58 -04:00
Put the process's OS handle count on the sizes line and add a handle census by kind behind NX2NAVI_HANDLE_CENSUS.
A session of 2026-11-13 grew from 683 to 1095 OS handles in 11 minutes, rising at every area load and never falling,
while the guest's own handles stayed at 116-122 and the threads flat; the VMA block count fell back while the handle
count did not. The log could not show it: the 600-frame "mem: sizes" line had only the guest's handles, and nothing
told which kind of handle grows.
kernel.c kern_sizes now adds "process handles" (plat_handle_count, one system call every 600 frames under trace=perf)
beside the guest's "handles". platform.h gets plat_handle_census: on Windows the system's extended handle table
filtered by our process id, with the type names from NtQueryObject's ObjectTypesInformation; on Linux the
/proc/self/fd links grouped by kind. It never opens, duplicates or names a handle (a name query can block on a pipe).
With NX2NAVI_HANDLE_CENSUS=1 (default 0, read at start) and trace=perf, perf.c starts one long-lived thread that the
600-frame report wakes; when the count grew by 16 or more since its last census it logs "mem: handles frame N: T in
all (+D since the last census): Event a (+x), ...". The census reads a few MiB of the system's table in 2-5 ms, off
the drawing threads; one thread for the run keeps a new thread's own handle out of what it counts. New cfg rows:
HANDLE_CENSUS in known[], sections[] (diagnostics) and metas[] ("0", "0|1", restart), and an nx2navi.ini.example
entry.
New tests/handle_census_check.py builds the platform layer alone: 20 events and 5 sections show as Event +20 and
Section +5, the total stays within 2 of GetProcessHandleCount, the figures return once they are closed, and kinds
past the room given go into the last entry; docs/building.md describes it. Not reproduced before the change (the
growth needs a game run). handle_census_check, sync_wake_check and the cfg row check pass; every runtime file compiles
with the dev flags, and perf.c, kernel.c, win32.c and cfg.c add no -Wall -Wextra warnings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2447,7 +2447,8 @@ int kern_svc(Cpu *c, uint32_t imm) {
|
||||
}
|
||||
|
||||
// NX2NAVI_TRACE=perf "mem: sizes" (perf.c): guest threads, the handle table, the system-event table and fibers, each
|
||||
// against its fixed size (the tables are fatal when full).
|
||||
// against its fixed size (the tables are fatal when full). Beside the guest's handles, the OS handles of the process
|
||||
// (platform.h plat_handle_count): they grew at every area load of a session while the guest's stayed flat.
|
||||
void kern_sizes(PerfSizes *s) {
|
||||
uint64_t threads = 0, handles = 0, fibers = 0, ses;
|
||||
plat_mutex_lock_shared(&G);
|
||||
@@ -2462,6 +2463,7 @@ void kern_sizes(PerfSizes *s) {
|
||||
plat_mutex_unlock_shared(&g_fiber_lock);
|
||||
perf_size(s, "guest threads", threads, 0, PERF_SIZE_NONE);
|
||||
perf_size(s, "handles", handles, MAX_H, PERF_SIZE_NONE);
|
||||
perf_size(s, "process handles", plat_handle_count(), 0, PERF_SIZE_NONE);
|
||||
perf_size(s, "system events", ses, sizeof g_se / sizeof *g_se, PERF_SIZE_NONE);
|
||||
perf_size(s, "fibers", fibers, FIBER_MAX, PERF_SIZE_NONE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user