Bug report
There are scaling bottlenecks in the slow paths of _PyType_LookupStackRefAndVersion(), and it turns out that these can be a major bottleneck in larger applications.
For context, I've been testing Zulip with 3.14t and multithreading. The problem is basically:
- There are a lot of attribute loads that are not monomorphic (so specialization is of limited help)
- There are lots of unique (type, attr) lookups, so there are frequent collisions in the global MRO cache
The slow path for this case acquires the global type lock.
We should avoid acquiring the global type lock if the type already has a valid version tag. We'll also want to avoid reference count contention on the MRO tuple.
Linked PRs
- gh-145685: Update find_name_in_mro() to return a _PyStackRef (gh-145693) #145693
- gh-145685: Stop the world when updating MRO of existing types #145707
- [3.14] gh-145685: Stop the world when updating MRO of existing types (gh-145707) #145715
- [3.14] gh-145685: Update find_name_in_mro() to return a _PyStackRef (gh-145693) #145769
- gh-145685: Improve scaling of type attribute lookups #145774
- gh-145685: Avoid contention on TYPE_LOCK in super() lookups #145775
- [3.14] gh-145685: Avoid contention on TYPE_LOCK in super() lookups (gh-145775) #145804
- [3.14] gh-145685: Improve scaling of type attribute lookups (gh-145774) #145874
- gh-145685: per-type method cache implementation #150160
- gh-145685: Remove
_PySeqLockthat is not used anymore (gh-155243) #155243