-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
GH-139951: Fix major GC performance regression #140262
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
base: main
Are you sure you want to change the base?
Conversation
* Count number of actually tracked objects, instead of trackable objects. This ensures that untracking tuples has the desired effect of reducing GC overhead * Do not track most untrackable tuples during creation. This prevents large numbers of small tuples causing execessive GCs.
I'm not sure I get what android (x86_64) fails.
|
I'm not at all familiar with the garbage collector, but one of the ways that Android differs from the other platforms is that it runs all the test suite serially in a single process. |
} | ||
intptr_t new_objects = gcstate->young.count; | ||
intptr_t max_heap_fraction = new_objects*3/2; | ||
intptr_t max_heap_fraction = new_objects*2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment above is not in line with this one, but I don't want to stop this PR from merge now. We can fix this in follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me, thanks!
Should we redo the benchmarks to see how the final version impacts performance? Maybe we can run it on https://github.com/faster-cpython/benchmarking-public (but I don't know how). |
PyThreadState *tstate = _PyThreadState_GET(); | ||
struct _gc_runtime_state *gcstate = &tstate->interp->gc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PyThreadState *tstate = _PyThreadState_GET(); | |
struct _gc_runtime_state *gcstate = &tstate->interp->gc; | |
struct _gc_runtime_state *gcstate = &_PyInterpreterState_GET()->gc; |
Maybe it'll be better to use the same expression as below?
There's no another call of _PyThreadState_GET
in this file.
small tuples. | ||
|
||
* Counts number of actually tracked objects, instead of trackable objects. | ||
This ensures that untracking tuples has the desired effect of reducing GC overhead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures that untracking tuples has the desired effect of reducing GC overhead | |
This ensures that untracking tuples has the desired effect of reducing GC overhead. |
/* Fast, but conservative check if an object maybe tracked | ||
May return true for an object that is not tracked, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* Fast, but conservative check if an object maybe tracked | |
May return true for an object that is not tracked, | |
/* Fast, but conservative check if an object maybe tracked. | |
May return true for an object that is not tracked. |
This PR:
For the example in the original report this makes performance on main a bit better than 3.13.
Benchmarking results show this is about neutral on performance otherwise.