Commit 8d3c62b
authored
Declare free-threaded safety for _scalene_unwind module (#1065)
The _scalene_unwind native extension (native_unwind.cpp) was the only one
of Scalene's three C extension modules that did not call
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED) in its init. On
free-threaded builds (3.13t/3.14t) importing a module that has not declared
free-threaded safety makes CPython silently re-enable the GIL and emit a
RuntimeWarning. Because Scalene always imports _scalene_unwind, the GIL was
restored on every free-threaded run -- so Scalene never actually ran
free-threaded, adding startup overhead and serializing threads.
pywhere.cpp and get_line_atomic.cpp already make this call; this brings
_scalene_unwind in line with them.
Verified on Linux (3.13t and 3.14t): after the fix sys._is_gil_enabled()
stays False after importing scalene, the RuntimeWarning is gone, the memory
attribution suite passes, and the free-threaded parity test shows the
contention ratio drop below 1.0 (real parallel scaling) instead of being
masked by a re-enabled GIL.1 parent ee11ad1 commit 8d3c62b
1 file changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
806 | 806 | | |
807 | 807 | | |
808 | 808 | | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
809 | 816 | | |
810 | 817 | | |
811 | 818 | | |
| |||
0 commit comments