Skip to content

startup: resource and heap lookups queue on note_lock behind every view creation and descriptor copy #3390

Backlog

Description

@lukaslw-lab

In the main executable's startup run (#870), note_lock is one reader-writer lock for the view records, the
descriptor shadows and the tables of resources, slot 133 placements and descriptor heaps. View creation (note_view)
and descriptor copies (note_copy) take it exclusively on every call, about 180,000 times per second late in the load.
Four lookups read only the resource, placement and heap tables: resource_info, placed_buffer_range,
memory_srv_destination and resolve_title_table. Together they take it shared about 490,000 times per second, so
each of them queues behind those writers although the tables they read change only when a resource or heap is created
or a placement is retired.

Windows 10 22H2, i7-4790K (4 cores, 8 threads), RTX 3080 Ti, NVIDIA 32.0.16.1047, release, warm shader cache, scripted
input, 250 s, merged switches (#2949, #2977, #3028, #3313). Lock waits from a local measurement build: main
aec2e084 with #3097 and #3377 merged, plus per-site wait and hold timers around every note_lock take (not part of
the proposal); window ~100k–175k loaded blocks:

note_lock take per second threads waiting wait per take
note_view (exclusive) 118,000 0.49 4.1 µs
note_copy (exclusive) 59,000 0.21 3.5 µs
memory_srv_destination (shared) 87,000 0.16 1.9 µs
resolve_title_table (shared) 115,000 0.15 1.3 µs
resource_info (shared) 185,000 0.06 0.3 µs
placed_buffer_range (shared) 101,000 0.05 0.5 µs
all sites 1.18
  • The four table lookups wait ~0.42 threads in total; every lock hold is short (≤ 1.2 µs), so this is contention, not
    work under the lock.
  • Frame rate in that window is 12–9 fps and falls as the load goes on; the stand-in's view and copy calls cost a
    near-constant ~9 µs each while the title makes about twice as many per frame at 175–200k as at 100–125k.

Proposed in #3391: an opt-in X2W_D3D12_TABLE_LOCK=1 that gives those tables their own lock, so the four lookups stop
queueing on note_lock. The default stays as on main.

This report was prepared with AI assistance (Claude); the runs are mine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions