python / python/cpython

Move stackref buffer to per-eval loop to reduce interp stack usage

Open
#138,115 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

3.14 3.15 interpreter-core type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

The interpreter main loop's stack usage is huge. We should try to reduce it a little. Currently, the stackref buffer takes up 10 words on 64-bit machines. We could lessen that by moving it to the heap (thread state).

This might mean slightly less perf due to worse locality and one memory indirection. So let's benchmark this to be sure.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-138116

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the interpreter main loop and locate the stackref buffer and thread state referenced in the proposal. Benchmark the current and proposed arrangements, including stack usage, locality or indirection costs, and performance. Done means the stackref buffer is moved as proposed only if the measurements support the change; gh-138116 indicates work is already underway.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.