Use PEP 669 API for cprofile #103533
Labels
performance
Performance or resource usage
stdlib
Python modules in the Lib dir
type-feature
A feature request or enhancement
Feature or enhancement
Replace the current
setprofile
mechanism with PEP 669 API for cProfile.Pitch
It's faster.
Before:
After:
20%+ speed up for overhead.
I guess the incentive is not in doubt, but I did have some issues when I implemented it.
We can make it work as before, I just think this is not the right way to do it with PEP 669. Because of this, I changed an old (15 years) test in
test_cprofile
.We need to get the actual c function from the descriptor, for which I used the code in the current legacy tracing. However,
_PyInstrumentation_MISSING
is not exposed so I had to store it locally (keep reading it fromsys
is a bit expensive).On that matter, are we going to expose some APIs on C? It would be nice if I don't have to get
sys.monitoring
and do stuff from there. We have some defined constants but some APIs could be handy. We may be able to reduce the overhead a bit if we have an interface likePyEval_SetProfile
.Addendum:
Benchmark Code
Linked PRs
The text was updated successfully, but these errors were encountered: