mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-21 03:39:57 -04:00
Evict idle VRAM mirrors to make room, and ask again for mirrors the budget refused.
A pool whose mirror did not fit the VRAM budget stayed imported for good, however hot, while mirrors nothing had used for minutes kept their memory. Now a new mirror that does not fit takes the room of mirrors no submission synced for 120 submissions, least recently synced first; a pool refused for the budget asks again after 600 submissions; and above the texture pressure threshold (90% of the budget) mirrors idle for 600 submissions go every 8 submissions so the textures get the room. A victim has nothing in the submission being recorded and its GPU writes are already back in guest memory; its device address table pages move back to the imported buffer (vk_gpa_remap_plain) and the mirror is destroyed once the submission is done. It is mirrored again from a whole copy at its next buffer use. NX2NAVI_MIRROR_EVICT=0 turns it off. Measured with the budget taken as 16 GiB, same route: off, 691 mirrors (910 MiB) and 133 pools refused for the budget; on, 405 mirrors (799 MiB): 240 idle ones (98 MiB, title-screen and loading pools) evicted, 114 pools refused. That exe still evicted idle mirrors under pressure for the textures, which a later commit removes, and asked refused pools again every 16 submissions (1,795 times), which another commit spaces out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -238,7 +238,7 @@ void vk_gpa_clear(uint64_t lo, uint64_t hi) {
|
||||
plat_mutex_unlock(&gpa_lock);
|
||||
}
|
||||
|
||||
uint32_t vk_gpa_remap(uint64_t lo, uint64_t hi, uint32_t old_rec, VkBuffer buf, uint64_t buf_lo) {
|
||||
static uint32_t remap(uint64_t lo, uint64_t hi, uint32_t old_rec, VkBuffer buf, uint64_t buf_lo, int keep_twin) {
|
||||
if (!vk_gpa_on() || !buf) return old_rec;
|
||||
uint64_t dev = vk_gpa_device_address(buf);
|
||||
uint64_t p0 = (lo + 4095) >> PAGE_SHIFT, p1 = hi >> PAGE_SHIFT;
|
||||
@@ -247,9 +247,9 @@ uint32_t vk_gpa_remap(uint64_t lo, uint64_t hi, uint32_t old_rec, VkBuffer buf,
|
||||
// NX2NAVI_GPA_TWIN=0 (diagnosis): no twin, the writes go to the mirror alone, as before patch 0034.
|
||||
static int twins = -1;
|
||||
if (twins < 0) { const char *e = cfg_get("NX2NAVI_GPA_TWIN"); twins = !(e && !strcmp(e, "0")); }
|
||||
uint64_t twin = old_rec && twins ? (uint64_t)G.cpu[REC_WORD + old_rec * REC_WORDS] |
|
||||
(uint64_t)G.cpu[REC_WORD + old_rec * REC_WORDS + 1] << 32
|
||||
: dev - buf_lo;
|
||||
uint64_t twin = old_rec && twins && keep_twin ? (uint64_t)G.cpu[REC_WORD + old_rec * REC_WORDS] |
|
||||
(uint64_t)G.cpu[REC_WORD + old_rec * REC_WORDS + 1] << 32
|
||||
: dev - buf_lo;
|
||||
uint32_t r = dev ? rec_alloc(dev - buf_lo, twin) : 0;
|
||||
if (!r) { plat_mutex_unlock(&gpa_lock); return old_rec; }
|
||||
for (uint64_t p = p0; p < p1; p++) {
|
||||
@@ -264,6 +264,14 @@ uint32_t vk_gpa_remap(uint64_t lo, uint64_t hi, uint32_t old_rec, VkBuffer buf,
|
||||
return r;
|
||||
}
|
||||
|
||||
uint32_t vk_gpa_remap(uint64_t lo, uint64_t hi, uint32_t old_rec, VkBuffer buf, uint64_t buf_lo) {
|
||||
return remap(lo, hi, old_rec, buf, buf_lo, 1);
|
||||
}
|
||||
|
||||
uint32_t vk_gpa_remap_plain(uint64_t lo, uint64_t hi, uint32_t old_rec, VkBuffer buf, uint64_t buf_lo) {
|
||||
return remap(lo, hi, old_rec, buf, buf_lo, 0);
|
||||
}
|
||||
|
||||
void vk_gpa_report(void) {
|
||||
if (G.state <= 0) return;
|
||||
rt_log("vk_gpa: %llu pages (%.0f MiB) mapped, %u of %u blocks, %u records in use, %llu maps, %llu unmaps, %llu refused",
|
||||
|
||||
Reference in New Issue
Block a user