Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-126220: Adapt _lsprof to Argument Clinic#126233
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
sobolevn commented Oct 31, 2024 • edited by bedevere-app bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-app bot
Uh oh!
There was an error while loading. Please reload this page.
ZeroIntensity left a comment
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.
LGTM. I'm always happy with fixes via AC, because they're much more scalable.
gaogaotiantian commented Oct 31, 2024
What's the perf impact here? |
sobolevn commented Oct 31, 2024
@gaogaotiantian I've never had experience with profiling |
gaogaotiantian commented Oct 31, 2024
Just do a quick fib() with cprofile and compare it with the previous implementation would do. Maybe also with one without cprofile. |
sobolevn commented Oct 31, 2024
@gaogaotiantian maybe I did something wrong, but looks like we also got a speedup from my numbers 😅 (I have little idea about how # Test code: ex.pydeftest(): deffib(): start, nextn=0, 1whileTrue: yieldstartstart, nextn=nextn, start+nextngen=fib() for_inrange(100000): next(gen) importcProfilecProfile.run(test.__code__)Running it on Running on this PR: Am I missing something? |
gaogaotiantian commented Oct 31, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Sorry I meant a recursive importtimedeffib(n): ifn<=1: return1returnfib(n-1) +fib(n-2) start=time.time() # enable profilerfib(24) # disable profilerprint(time.time() -start)We need to consider the worst case for cprofile, which is when the code has a lot of function calls. We need to know the overhead of the profiler, and how that is compared with before. You can also refer to #103533, there's a profiling code listed. That might give some extra information. Moving to |
sobolevn commented Oct 31, 2024
It still gives me a perf boost for some reason 🤔 importtimeimportcProfileprofiler=cProfile.Profile() deffib(n): ifn<=1: return1returnfib(n-1) +fib(n-2) start=time.perf_counter() profiler.enable() fib(30) # 100thprofiler.disable() print(time.perf_counter() -start) # Old: 0.9349823750017094# New: 0.9253051670020795# 1% faster |
gaogaotiantian commented Oct 31, 2024
Is the boost stable(reproducible)? |
sobolevn commented Oct 31, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Yes, it is pretty much the same on m2 macos: |
gaogaotiantian commented Oct 31, 2024
Yeah from the result I don't think there's an observable boost. On the other hand, that's good, because no observable regression either. |
gaogaotiantian left a comment
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.
Just a side note - this needs to be backported to 3.12 as well :) I added the tags so you should be able to just merge it.
sobolevn commented Oct 31, 2024
@gaogaotiantian sorry, I forgot to highlight it initially. Please, double check params names that I introduced. Are they correct? |
gaogaotiantian commented Oct 31, 2024
Actually, I have some doubts about the changes for functions that are not crashing. This is a bug fix, which would be backported. I don't think we should mix in the code polish to the PR. Even though I think changing this in As for the argument name, the |
gaogaotiantian commented Oct 31, 2024
Can we split this PR into 2? One with the changes to only the 4 callbacks, and the other with all the other methods? |
sobolevn commented Oct 31, 2024
Fair enough, I would split this PR later! 👍 |
gaogaotiantian left a comment
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.
LGTM!
sobolevn commented Oct 31, 2024
@erlend-aasland maybe you would be interested in double checking the AC part? :) |
_lsprof.Profiler methods with 0 args_lsprof to ACUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
_lsprof to AC_lsprof to Argument ClinicCo-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
sobolevn commented Nov 4, 2024
Done! |
Thanks @sobolevn for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
sobolevn commented Nov 4, 2024
Thanks everyone! |
(cherry picked from commit c806cd5) Co-authored-by: sobolevn <mail@sobolevn.me> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Sorry, @sobolevn, I could not cleanly backport this to |
GH-126402 is a backport of this pull request to the 3.13 branch. |
sobolevn commented Nov 4, 2024
Oups, backports are not needed anymore. Closing them. |
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
I decided to go with the AC, because:
But, I believe it will be slower. If we really want to preserve speed in this case, I can add manual
sizechecks forargs.Refs #103534
_lsprof.Profiler._creturn_callback()segfaults #126220