You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypedPython: compiled code never checks the eval breaker (signals, GC, GIL hand-off) #141
Since N-8, compiled loops do not check the eval breaker, so during a long compiled loop four things are deferred until it returns: signals (KeyboardInterrupt), scheduled garbage collections, pending calls, and dropping the GIL for other threads. The first three only move in time. The last starves other Python threads, which is a behaviour difference, not only a timing one.
Proposal: check the eval breaker at loop back-edges and at calls, with a cost measurement (nbody, spectral-norm, fannkuch) before and after. Design note: docs/design/typedpython.md §4.3.4 마.2 (PR for N-12).
Done when: a test shows a second Python thread makes progress while a compiled loop runs, KeyboardInterrupt reaches a compiled loop, and the measured cost is recorded.
Phase 1 (feat/tp-eval-breaker) cost, interleaved A/B against develop in a quiet window (load 2.2 to 3.0), 11 pairs:
after / before, median
range
fannkuch-redux
1.109
1.045 to 1.135
nbody
1.005
0.975 to 1.036
The first version, which decremented a module-global countdown in every loop iteration, cost fannkuch about 38%. Switching to a function-local countdown brought that down to about 11%.
nbody is unaffected, as expected: its loops are in functions holding array snapshots, which do not poll.
11% is still too much for fannkuch's short inner while loops. Next: poll only at the back-edges of loops that are not innermost, plus innermost loops by strip-mining (a chunked inner loop with one poll per chunk), then re-measure.
The audit for TypedPython: a compiled module re-enables the GIL on a free-threaded build #159 found that functions holding array parameters may still contain user-code calls (e.g. a callback), despite the ArrayParam contract that no user code runs. This needs checking and likely a fix: such functions should be required to be closed.
Activity
Perf: Poll loops through a function-local countdown (#141)
Docs: Bring the TypedPython design up to date (N-11 landed, #141 phas…
b-re-w commentedon Oct 3, 2026
Phase 1 (
feat/tp-eval-breaker) cost, interleaved A/B against develop in a quiet window (load 2.2 to 3.0), 11 pairs:whileloops. Next: poll only at the back-edges of loops that are not innermost, plus innermost loops by strip-mining (a chunked inner loop with one poll per chunk), then re-measure.Follow-ups:
feat/tp-free-threaded) is committed on top of phase 1: 974 passed, 3 skipped on 3.15t.Perf: Keep the eval-breaker slow path out of line and the loop tick i…
Docs: Record the eval-breaker polling cost (#141)
Merge pull request #207 from thisisthepy/feat/tp-eval-breaker
b-re-w commentedon Oct 17, 2026
Landed in develop via #207. Measured cost: fannkuch +8.2% (accepted, see the PR); chunked range-loop polling is #206; phase 2 is in #159.