In free-threaded builds, the specializing adaptive interpreter needs to be made thread-safe. We should start with a small PR to simply disable it in free-threaded builds, which will be correct but will incur a performance penalty. Then we can work out how to properly support specialization in a free-threaded build.
There are two primary concerns to balance while implementing this functionality on main:
- [x] BINARY_OP
- [x] BINARY_SUBSCR - @corona10
- [x] CALL - @mpage
- [x] CALL_KW - @mpage
- [x] COMPARE_OP - @Yhg1s
- [x] CONTAINS_OP - @corona10
- [x] FOR_ITER - @Yhg1s
- [x] LOAD_ATTR - @mpage
- [x] LOAD_CONST
- [x] LOAD_GLOBAL - @mpage
- [x] LOAD_SUPER_ATTR - @nascheme
- [x] RESUME
- [x] SEND - @nascheme
- [x] STORE_ATTR - -@nascheme
- [x] STORE_SUBSCR - @colesbury
- [x] TO_BOOL - @corona10
- [x] UNPACK_SEQUENCE - @Eclips4
Feature or enhancement
Proposal:
In free-threaded builds, the specializing adaptive interpreter needs to be made thread-safe. We should start with a small PR to simply disable it in free-threaded builds, which will be correct but will incur a performance penalty. Then we can work out how to properly support specialization in a free-threaded build.
These two commits from Sam's nogil-3.12 branch can serve as inspiration:
There are two primary concerns to balance while implementing this functionality on
main:Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
Specialization Families
Linked PRs
BINARY_OP#123926LOAD_GLOBALspecializations to avoid reloading {globals, builtins} keys #124953UNPACK_SEQUENCE#126600LOAD_GLOBALin free-threaded builds #126607TO_BOOL#126616CALLinstructions in free-threaded builds #127123LOAD_SUPER_ATTRin free-threaded builds #127128specialize#127167STORE_SUBSCR#127169SEND. #127426CALL_KWin free-threaded builds #127713STORE_ATTRin free-threaded builds. #127838LOAD_ATTRfor instance and class receivers in free-threaded builds #128164_STORE_ATTR_WITH_HINT#136249