mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 09:39:58 -04:00
Keep the game on the largest-L3 die only when that die has 8 cores, and reserve no recorder core there.
cache_die moved the process to the logical processors of the largest L3 cache whenever the L3 sizes differed. That is right for a two-die X3D desktop part with 8 cores a die, but it also held the game to the 4 large cores of a mobile part whose 8 small cores share a smaller L3, and to the 6 cores of a 12-core X3D part, where the recording thread's reserved core then left the game 5. The die is now used only when it has 8 or more physical cores (perf.c cpu_placement logs when one is passed over). And while the process runs on that die alone, RECORDER_CORE=auto reserves no core for the recording thread, since the game's threads already have the die to themselves; =1 still reserves one. Checked: all runtime files compile. This PC has a single-die processor (one L3), where neither rule applies: a run still reserves the recording core (logical processors 14 and 15 of 16) and logs no cache die. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -74,7 +74,8 @@
|
||||
# timer_1ms = 1
|
||||
# The thread that records the GPU work (the first to spend half a second doing it, not the one that submits first) keeps
|
||||
# the highest scheduling priority (recorder_prio), and a core of its own that the process's other threads stay off
|
||||
# (recorder_core: auto = with 12 or more logical processors, 1 always, 0 never). That is a fast core, with both of its
|
||||
# (recorder_core: auto = with 12 or more logical processors, unless the game runs on the cache die below, 1 always,
|
||||
# 0 never). That is a fast core, with both of its
|
||||
# logical processors: on Windows the highest-numbered core of the fastest efficiency class; on Linux the performance
|
||||
# core that clocks highest on a hybrid CPU (else the core of the highest capacity or clock), and none when fewer than
|
||||
# four cores are that fast. The log names the thread and its logical processors.
|
||||
@@ -96,7 +97,8 @@
|
||||
# dyn_res_target = 16.7
|
||||
# dyn_res_step = 45
|
||||
# Processors. On a processor whose dies have L3 caches of different sizes (AMD's two-die X3D processors, with 3D
|
||||
# V-Cache on one die) the game runs on the die with the larger cache: 1 = on, 0 = Windows places the threads.
|
||||
# V-Cache on one die) the game runs on the die with the larger cache when that die has 8 cores or more: 1 = on,
|
||||
# 0 = Windows places the threads.
|
||||
# cache_die = 1
|
||||
# One logical processor of each physical core, so no two busy threads share a core: 1 = on, 0 = all of them.
|
||||
# one_per_core = 0
|
||||
|
||||
@@ -99,6 +99,7 @@ void perf_lock_hold(void *site, uint64_t ns); // a lock held ns from site (vk_
|
||||
extern void (*perf_rec_waits)(uint64_t *full_ns, uint64_t *drain_ns); // set by the back end (vk_rec.c totals)
|
||||
void perf_present(uint64_t frame);
|
||||
void perf_cpu_start(void); // the process's logical processors (NX2NAVI_CACHE_DIE, NX2NAVI_ONE_PER_CORE), at start
|
||||
int perf_cpu_on_cache_die(void); // 1 while the process runs on the die with the largest L3 cache alone (perf.c cpu_placement)
|
||||
void perf_summary_flush(void); // prints the frame-time summary of the running period (exit); the 60 s lines come from perf_present
|
||||
void gfx_exit_log(void); // back end's lines for the exit summary (weak no-op in prof_win.c)
|
||||
void perf_gpu_wait(uint64_t t0); // a wait for a GPU fence ended (any thread; the render thread's also counts as PERF_FENCE)
|
||||
|
||||
@@ -745,6 +745,16 @@ static void cpu_placement(void) {
|
||||
one_mode == 2 ? " in the B blocks" : "");
|
||||
else
|
||||
one_mode = 0;
|
||||
// The largest L3 is a reason to stay on its processors only where it serves enough cores to run the game: two
|
||||
// dies of one design, one of them with stacked cache (a two-die X3D desktop part, 8 cores a die). A die of
|
||||
// fewer cores holds the game to them: the 4 large cores of a mobile part whose 8 small cores share a smaller
|
||||
// L3, or the 6 of a 12-core X3D part, where the recording thread's own core (vk_exec.c rec_claim) left 5.
|
||||
int die_cores = __builtin_popcountll(cpu_die & cpu_one);
|
||||
if (cpu_die && cpu_die != cpu_all && die_cores < 8) {
|
||||
rt_log("cpu: logical processors %#llx of %#llx share the largest L3 cache (%u MiB), but only %d cores: not "
|
||||
"used", (unsigned long long)cpu_die, (unsigned long long)cpu_all, kb >> 10, die_cores);
|
||||
cpu_die = 0;
|
||||
}
|
||||
if (cpu_die && cpu_die != cpu_all)
|
||||
rt_log("cpu: logical processors %#llx of %#llx share the largest L3 cache (%u MiB)%s",
|
||||
(unsigned long long)cpu_die, (unsigned long long)cpu_all, kb >> 10,
|
||||
@@ -763,6 +773,8 @@ static void cpu_placement(void) {
|
||||
|
||||
void perf_cpu_start(void) { cpu_placement(); }
|
||||
|
||||
int perf_cpu_on_cache_die(void) { return cpu_applied && cpu_die && (cpu_applied & ~cpu_die) == 0; }
|
||||
|
||||
// NX2NAVI_CRASH_FILTER_GUARD (default 1; 0 off): once a second, the crash report's last-chance exception filter is put
|
||||
// back if a DLL loaded after the start (a GPU driver, an overlay) set its own in its place. Without it, a fault in such
|
||||
// a DLL ends the process with no FATAL line in the log. The first eight replacements are logged with the module.
|
||||
|
||||
@@ -1636,8 +1636,10 @@ static const op_hdr *walk(VkExec *ex, const op_hdr *h, int depth) {
|
||||
// scheduler prefers it over the guest's other cores (NX2NAVI_RECORDER_PRIO=0 leaves the guest's priorities alone) and
|
||||
// gets a core of its own (plat_cpu_reserve): every other thread of the process, the guest's cores, the audio, the
|
||||
// shader and pipeline workers, is kept off it, so nothing of this process preempts the recording. That core is then
|
||||
// lost to the rest, so NX2NAVI_RECORDER_CORE=auto (the default) reserves it only with 12 or more logical processors;
|
||||
// 1 always, 0 never. Linux reserves none with fewer than four fast cores.
|
||||
// lost to the rest, so NX2NAVI_RECORDER_CORE=auto (the default) reserves it only with 12 or more logical processors,
|
||||
// and not while the process runs on the die with the largest L3 alone (perf.c cpu_placement): on a two-die X3D part
|
||||
// the game's threads already have that die to themselves, and a core taken from them cost frames; 1 always, 0 never.
|
||||
// Linux reserves none with fewer than four fast cores.
|
||||
// The recording thread is not the first to call vk_exec_record: the game's main thread submits first and goes on
|
||||
// submitting a little at a time, while another guest thread does the work (Kokiri Forest: that thread spent 21.9 of
|
||||
// the 22.5 s the replay took in a minute and a half, the first one 0.5 s). The first thread to have spent
|
||||
@@ -1658,7 +1660,10 @@ static void rec_claim(void) {
|
||||
}
|
||||
const char *rc = cfg_value("NX2NAVI_RECORDER_CORE");
|
||||
unsigned ncpu = plat_cpu_usable();
|
||||
if (!strcmp(rc, "1") || (!strcmp(rc, "auto") && ncpu >= 12)) {
|
||||
int cache_die = perf_cpu_on_cache_die();
|
||||
if (!strcmp(rc, "auto") && cache_die) rt_log("vk: no core is reserved for the recording thread: the process runs on "
|
||||
"the die with the largest L3 cache (NX2NAVI_RECORDER_CORE=1 reserves one)");
|
||||
if (!strcmp(rc, "1") || (!strcmp(rc, "auto") && ncpu >= 12 && !cache_die)) {
|
||||
char which[96];
|
||||
int n = plat_cpu_reserve(which, sizeof which);
|
||||
if (n) rt_log("vk: the recording thread has a core of its own: logical processor%s %s (%d of %u; "
|
||||
|
||||
Reference in New Issue
Block a user