Use a freelist for thread states #126096
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
performance
Performance or resource usage
topic-subinterpreters
type-feature
A feature request or enhancement
Feature or enhancement
Proposal:
Subinterpreter switching relies on allocating a new thread state every time we want to switch to the target interpreter. Unfortunately, thread states use the system
malloc
via the raw allocators, so there can be some overhead if there's a lot of switching going on, depending on the system and the state of it. This can be slightly optimized by using a thread-local freelist for thread states, instead of going straight tocalloc
every time.I've measured a slight performance increase on my end (~2%), but this should but much better for systems with a lot less memory, where the allocator has to do a lot more work.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: