Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a freelist for thread states #126096

Open
ZeroIntensity opened this issue Oct 28, 2024 · 0 comments
Open

Use a freelist for thread states #126096

ZeroIntensity opened this issue Oct 28, 2024 · 0 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage topic-subinterpreters type-feature A feature request or enhancement

Comments

@ZeroIntensity
Copy link
Member

ZeroIntensity commented Oct 28, 2024

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 to calloc 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

@ZeroIntensity ZeroIntensity added type-feature A feature request or enhancement performance Performance or resource usage topic-subinterpreters labels Oct 28, 2024
@ZeroIntensity ZeroIntensity self-assigned this Oct 28, 2024
@Eclips4 Eclips4 added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage topic-subinterpreters type-feature A feature request or enhancement
Projects
Status: Todo
Development

No branches or pull requests

2 participants