Repository navigation
Feat: Compiled loops and calls run CPython's eval breaker (#141 phase 1) - #207
Merged
Merged
Conversation
Member
Author
|
Re-measured after a report that another session ran a model test for about 60 s while the MEASURING flag was set earlier today. Both re-runs started in a quiet window (5-minute load at most 3, no torchnative gate running), interleaved, 11 pairs:
The figures agree, so the recorded numbers stand. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #141 (phase 1; phase 2 is folded into #159; the open decision is #152).
Defect fixed: compiled loops and recursion never ran the eval breaker. KeyboardInterrupt did not reach a compiled loop, other threads starved, and on free-threaded builds a stop-the-world request would wait for the loop to end.
Feature added:
tp_pc_tick), entries the per-thread counter.tp_poll_slowcalls a module-heldlambda: None. Its RESUME runs CPython's own eval-breaker handling: signals, pending calls, forced GIL switching, async exceptions and scheduled GC, exactly as between bytecodes. Public API only.Tests added:
test_eval_breaker.py.Measured cost (quiet window, load 2 to 4, interleaved against develop, 11 pairs; raw data in
benchmarks/typedpython/results/2026-10-17-eval-breaker-*.json):The whole remaining cost is the per-iteration countdown in short inner loops; CPython pays the same kind of check on every back-edge. Accepted by the leader as the price of the fix. Chunked polling for range loops is #206.
Verification (local): full TypedPython suite on CPython 3.14.7: 966 passed, 3 skipped.