-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
sys.settrace dramatic slowdown in 3.12 #107674
Comments
This issue can be seen starting from the commit 411b169 with usual numpy-1.25.2. |
cc. @markshannon |
…events (pythonGH-107780) (cherry picked from commit 37d8b90) Co-authored-by: Mark Shannon <mark@hotpy.org>
@markshannon Is there any news about this? |
@iritkatriel perhaps you have some idea? |
Did #107780 help? |
@gaogaotiantian Thanks. I tried #114986, and it didn't run faster. I used the https://github.com/Quansight-Labs/ndindex repo test suite: I wish I had better news. |
Oh, did you test it with an empty trace function? |
I will do more tests, but the ultimate goal is to perform better in real-world scenarios. Here is more data from a subset of the test suite (
|
Thank you for the test. Yes the PR only improves the performance of the actual trace function - which is normally the major cost for tracing tools. Good to know it helps with the more real-life benchmark. Unfortunately, due to the change of the tracing mechanism, the overhead for |
Now that the eval_breaker is part of the thread state, here's an alternative approach that might work.
If the code and global versions differ do the following:
I think this is correct, but I've not drawn up a full state diagram. |
#114986 caused refleaks tests ( |
…nGH-114986)" This reverts commit 0a61e23.
Python 3.12 has a significant regression in coverage analysis. Related issue: python/cpython#107674 . This patch replaces coverage with a custom framework built using `sys.monitoring`, which is only available as of Python 3.12.
Python 3.12 has a significant regression in coverage analysis. Related issue: python/cpython#107674 . This patch replaces coverage with a custom framework built using `sys.monitoring`, which is only available as of Python 3.12.
Python 3.12 has a significant regression in coverage analysis. Related issue: python/cpython#107674 . This patch replaces coverage with a custom framework built using `sys.monitoring`, which is only available as of Python 3.12.
Python 3.12 has a significant regression in coverage analysis. Related issue: python/cpython#107674 . This PR replaces coverage with a custom framework built using `sys.monitoring`, which is only available as of Python 3.12.
Hi @nedbat , do you have a chance to test the performance of coverage on 3.13b against 3.12? I made a few optimizations and I'd hope the performance issue is relieved a bit. |
I'm having a hard time re-creating the scenarios I used before :( |
That's okay. Does coveragepy have nightly validations for 3.13b? Is there a basic timing benchmark that we can refer to? Just a ballpark would be helpful. |
You can try running the ndindex tests, which was the original thing I noticed this issue with in nedbat/coveragepy#1665. Just clone
then install the packages in
(coverage is enabled automatically). On my computer with Python 3.11.9, the tests take 2:48 and with Python 3.12.0 they take 4:21 (both with coverage 7.5.2). If you want to run the tests with coverage disabled you should remove the coverage options from |
Coverage.py has an overnight job that runs its test suite on nightly builds of Python, including 3.13 and 3.14 now: https://github.com/nedbat/coveragepy/actions/runs/9265205433 There isn't a timing test in there though. |
I have a benchmarking framework, but it's fragile. I will try to patch it up later this week. |
I ran benchmarks again on 3.11, 3.12, and 3.13:
The specific versions were the newly released 3.11.10, 3.12.6, and 3.13.0rc2. The test suites were run three times, and the median time used. |
Thanks @nedbat . I'm a bit surprised that on some cases 3.13 is slower than 3.12 - I did not think of anything that we did to slow down the tracing. Glad to see we had some significant improvements on certain cases. |
I continue to get people reporting serious performance problems on 3.12. Is there any chance of an improvement? |
Considering the issue observed in enthought/comtypes#775, where execution time increased nearly tenfold, there is a performance "regression" in Python 3.12. Only one bugfix release remains for Python 3.12: If #107841 is not merged by then, I believe the Python community will miss an opportunity to reconsider this issue. If "the fix patch" is merged before Python 3.12 transitions to security-fix only status, I would accept enabling coverage measurement in the As discussed in #107841, I understand that this issue doesn't involve "broken" programs but rather a "performance improvement", and that the changes are complex to accept during the bugfix phase. However, fixing this could potentially benefit projects and the wider ecosystem running on Python 3.12. I would like to, once again, hear the opinions of the core developers and the community on this matter. |
Ah, @markshannon merged #128350 in main but did not backport it to 3.12 and 3.13 due to conflicts. #107841 is not the problem fixer. I believe backporting #128350 should fix the issue in 3.12 and 3.13. |
- v3.12.8 - cc90ef8
python/cpython#107674 - v3.12.8 - junkmd/cpython@cc90ef8
I tested whether #107841 is the problem fixer. I built Python from
The build with 37d8b90 changes is about 153s faster than I haven't tested backporting #128350 yet because I'm not sure how to resolve conflicts. |
Bug report
Checklist
A clear and concise description of the bug
A bug report in coverage (nedbat/coveragepy#1665) is reduced here to a pure do-nothing trace function for sys.settrace.
Reproduction:
I don't know if the unusual numpy build has something to do with this.
Linked PRs
sys.settrace
line events #107780sys.settrace
line events (GH-107780) #107841sys.settrace
#114986sys.settrace
#117133The text was updated successfully, but these errors were encountered: