Skip to content

Dispatch registrations table is published whole under a lock (#76 B6) - #112

Merged
b-re-w merged 1 commit into
developfrom
feat/thread-capture-rng
Oct 17, 2026
Merged

b-re-w merged 1 commit into
developfrom
feat/thread-capture-rng

Conversation

@b-re-w

@b-re-w b-re-w commented Oct 17, 2026

Copy link
Copy Markdown
Member

Closes #76

The last open item of #76. The capture flag (992c69c) and the Arc-held RNG streams (f506e52) already landed in develop via #70; per-thread grad mode and device stack via #77.

  • defect fixed: _scan_dispatch_registrations (bootstrap.py) filled the shared _DISPATCH_REGISTRATIONS in place, and its "already built" check fired as soon as the keys existed. It now builds into a local dict and publishes it under _DISPATCH_REGISTRATIONS_LOCK.
  • test added: test_dispatch_registrations_built_by_eight_threads_at_once_are_whole (tests/api/test_threadstate.py), 8 threads behind a Barrier, three fresh subprocesses.
    • red before: seen [0, 0, 0, 0, 0, 0, 0, 743].
    • green after on 3.13 (GIL).
    • green on 3.15t with PYTHON_GIL=0, using a free-threaded _C built into .scratch: 743 names x 8 threads, 3 of 3 runs, sys._is_gil_enabled() False.

What the test cannot see: removing only the lock (keeping the local build) still passes, because the rebinding alone already keeps readers whole. The lock only avoids two threads scanning the file twice.

Local: test_threadstate 8/8, test_shim 480 ok EXIT=0, test_style EXIT=0. Full gate not run; CI on develop push (#109).

…er a lock (#76 B6)

_scan_dispatch_registrations filled the shared dict in place, and its
"already built" check was true as soon as the keys were inserted, before
any name was. Eight threads asking at once at a 1 us switch interval got
back seven empty lists and one 743-name list. The table is now built into
a fresh dict and bound to the global under a lock, so a reader sees no
table or the finished one.

- test_threadstate: 8 threads behind a Barrier, three fresh subprocesses;
  red before (seen [0,0,0,0,0,0,0,743]), green after.
- 3.15t with PYTHON_GIL=0 (free-threaded _C, .scratch stage): 743 x 8,
  three runs of three.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant