-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Deferred reference counts #120024
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
performance
Performance or resource usage
type-feature
A feature request or enhancement
Comments
markshannon
added
type-feature
A feature request or enhancement
performance
Performance or resource usage
labels
Jun 4, 2024
#119866 shows that it is possible to keep all stack pointers reachable in memory whenever execution escapes from the interpreter. This means that we make reclamation as prompt as want. |
markshannon
added
3.14
new features, bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
labels
Jun 6, 2024
This was referenced Jul 17, 2024
markshannon
added a commit
that referenced
this issue
Jul 18, 2024
markshannon
added a commit
that referenced
this issue
Aug 6, 2024
…in spill code in code generator (GH-122693)
markshannon
added a commit
that referenced
this issue
Aug 6, 2024
markshannon
added a commit
that referenced
this issue
Aug 6, 2024
brandtbucher
pushed a commit
to brandtbucher/cpython
that referenced
this issue
Aug 7, 2024
…apped in spill code in code generator (pythonGH-122693)
brandtbucher
pushed a commit
to brandtbucher/cpython
that referenced
this issue
Aug 7, 2024
brandtbucher
pushed a commit
to brandtbucher/cpython
that referenced
this issue
Aug 7, 2024
markshannon
added a commit
that referenced
this issue
Aug 8, 2024
markshannon
added a commit
that referenced
this issue
Aug 14, 2024
blhsing
pushed a commit
to blhsing/cpython
that referenced
this issue
Aug 22, 2024
…apped in spill code in code generator (pythonGH-122693)
blhsing
pushed a commit
to blhsing/cpython
that referenced
this issue
Aug 22, 2024
blhsing
pushed a commit
to blhsing/cpython
that referenced
this issue
Aug 22, 2024
blhsing
pushed a commit
to blhsing/cpython
that referenced
this issue
Aug 22, 2024
blhsing
pushed a commit
to blhsing/cpython
that referenced
this issue
Aug 22, 2024
* Factor some instructions into micro-ops to isolate CHECK_EVAL_BREAKER for escape analysis * Eliminate CHECK_EVAL_BREAKER macro
markshannon
added a commit
that referenced
this issue
Oct 9, 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
type-feature
A feature request or enhancement
Feature or enhancement
Proposal:
Approximately 80% of reference count operations occur in the interpreter. stats
The vast majority of these operations are needed only to maintain the correct reference counts for references in local variables and the evaluation stack.
We should not count these references, instead deferring them until we wish to perform incremental collection.
Doing so will give us a reasonable speedup on default builds, but the real value is for free-threading.
Free-threading requires that some references on the frame stack are deferred, but tagging those references is expensive. It is much more efficient to simply deferred all references on the frame stack.
This is not a new idea, in fact it is a very old one.
The implementation is conceptually fairly simple:
Like many "simple" ideas, the devil is in the detail.
There are two main concerns:
We can keep reclamation acceptably prompt, by tracking the size of objects in the Zero Count Table, the size of objects allocated.
Once this number gets large enough, we perform a collection at the next opportunity.
We can keep the overhead of updating the reference counts low, by only deferring the top of the stack. Parts of the stack that are not accessed between collections, can be counted eagerly, reducing the amount of scanning needed to a few frames.
Previous discussion
faster-cpython/ideas#677
Linked PRs
CHECK_EVAL_BREAKER
macro. #122968LOAD_FAST
instructions toLOAD_FAST_TEMP
when it is guaranteed the reference is consumed immediately. #125192Tasks
The text was updated successfully, but these errors were encountered: