Description
Feature or enhancement
Work is ongoing to implement deferred reference counting in the free-threaded build. The goal is to avoid many of the scaling bottlenecks caused by reference count contention. However, the work is complex and may not be finished in time for the 3.13 beta release and feature freeze.
In the meantime, we should temporarily immortalize objects that would use deferred reference counting in order to avoid bottlenecks that would inhibit scaling.
This has some real downsides: objects that are immortalized are never collected so an application that repeatedly creates many of these objects will leak memory. I think the trade-off is still worth it: if we can't scale multithreaded programs, then the free-threaded build is not particularly useful.
Once we implement deferred reference counting, we will get rid of this.
What types of objects use deferred reference counting?
- Top-level functions
- Descriptors
- Modules and their dictionaries
- Heap types
- Code objects
Refleak buildbots
We want the free-threading refleak buildbots to continue to work and catch leaks. In order to do that, we'll want to:
- Only do the deferred -> immortal conversion when the first non-main thread is started
- Disable the conversion at runtime in the refleak tests via an internal API