Repository navigation
[subinterpreters] Make free lists and unicode caches per-interpreter #84701
Description
Activity
tuple, dict and frame use free lists to optimize the creation of objects.
Unicode uses "interned" strings to reduce the Python memory footprint and speedup dictionary lookups.
Unicode also uses singletons for single letter Latin1 characters ([U+0000; U+00FF] range).
All these optimizations are incompatible with isolated subinterpreters, since caches are currently shared by all inteprepreters. These caches should be made per-intepreter. See bpo-40512 "Meta issue: per-interpreter GIL" for the rationale.
I already made small integer singletons per interpreter in bpo-38858:
- addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)3.9 (EOL)end of lifeend of life
on May 5, 2020 I wrote a draft PR to make interned strings per-interpreter. It does crash because it requires to make method cache and _PyUnicode_FromId() (bpo-39465) compatible with subinterpreters.
- added and removedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
on May 15, 2020 - changed the title
[-]Make tuple, dict, frame free lists, unicode interned strings, unicode latin1 singletons per-interpreter[/-][+][subinterpreters] Make free lists and unicode caches per-interpreter[/+]on May 15, 2020 55 remaining items
I reopen the issue to remind me that collections.deque() freelist is shared by all interpreters.
I reopen the issue to remind me that collections.deque() freelist is shared by all interpreters.
Each deque instance now has its own free list.
But dtoa.c still has a per-process cache, shared by all interpreters.
[Victor Stinner]
My plan is to merge changes which have no significant
impact on performancesFWIW, PyFloat_FromDouble() is the most performance critical function in floatobject.c.
My commit ea25180 (interned strings) introduced bpo-46006 "[subinterpreter] _PyUnicode_EqualToASCIIId() issue with subinterpreters" regression.
To unblock the Python 3.11.0a4 release, I just reverted the change. It reintroduces the issue, so I created bpo-46283: "[subinterpreters] Unicode interned strings must not be shared between interpreters".
I don't have the bandwidth to fix the remaining issues, so I just close again the issue.
- added a commit that references this issue
on Jun 14, 2024
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: