Index recording copies by 64 KiB block instead of 4 KiB page: AddControlMemory walked about 500 pages per call under the exclusive copy lock (53 calls a frame, 2 MiB ranges on the 1.4.3 field), and the main thread and job workers recording command buffers waited on it; field walk 72-77 fps to 78-80

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-10-27 10:17:14 +03:00
1 parent 95ae91687c
commit dc69797746
1 file changed
+5 -3
+5 -3
View File
@@ -29,7 +29,7 @@
#define MIN_COMMAND_SIZE 512 // NVN_DEVICE_INFO_COMMAND_BUFFER_MIN_COMMAND_SIZE (nvn_api_core.c devinfo)
#define MIN_CONTROL_SIZE 256 // NVN_DEVICE_INFO_COMMAND_BUFFER_MIN_CONTROL_SIZE
#define CTL_PER_RECORDING 64 // control memory one recording is reported to use
#define COPY_PAGE_SHIFT 12
#define COPY_PAGE_SHIFT 16 // recording copy index granularity (release_copies)
static cmd_t *cmd_of(const Cpu *c) { return arg_p(c, 0); }
@@ -158,8 +158,10 @@ static const tex_t *tex_pin(const NVNtexture *nt) {
}
// ---------- recording copies
// A handle points just past a copy_prefix. Copies are indexed by the 4 KiB page of their control-memory position, so
// adding control memory again releases the copies recorded there without walking every live copy.
// A handle points just past a copy_prefix. Copies are indexed by the 64 KiB block of their control-memory position, so
// adding control memory again releases the copies recorded there without walking every live copy. 4 KiB pages cost
// about 500 lookups per AddControlMemory under the exclusive lock (1.4.3 field: 53 calls a frame, 2 MiB ranges, 3.7
// copies per page), and the recording threads waited on it.
typedef struct { uint64_t magic, bytes, made_at, used_at, deferred; } copy_prefix; // deferred: 0 unknown, 1 none, 2 some
_Static_assert(sizeof(copy_prefix) % 8 == 0, "records stay 8-byte aligned");
typedef struct { uintptr_t lo, hi; uint8_t *copy; } cmd_copy;