Skip to content

Make the specializing interpreter thread-safe in --disable-gil builds#115999

@swtaarrs

Description

@swtaarrs

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:

  1. specialize: make specialization thread-safe
  2. specialize: optimize for single-threaded programs

There are two primary concerns to balance while implementing this functionality on main:

  1. Runtime overhead: There should be no performance impact on normal builds, and minimal performance impact on single-threaded code running in free-threaded builds.
  2. Reducing code duplication/divergence: We should come up with a design that is minimally disruptive to ongoing work on the specializing interpreter. It should be easy for other devs to keep the free-threaded build working without having to know too much about it.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

Specialization Families

- [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 

Linked PRs

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions