KEMBAR78
gh-110733: Optimize _run_once for many iterations of the event loop by bdraco · Pull Request #110735 · python/cpython · GitHub
Skip to content

Conversation

@bdraco
Copy link
Contributor

@bdraco bdraco commented Oct 11, 2023

Replace min and max in _run_once with simple < and >

close #110733

benchmarks in #110733

new: 0.36033158400096
original: 0.4667800000170246

@bdraco bdraco marked this pull request as ready for review October 11, 2023 19:41
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch LGTM. I haven't confirmed the speedup but I agree that not calling min() or max() is slightly faster. It will matter even more in 3.13 when we expect to have a basic tracing JIT.

I noticed that you considered calling time() only once -- do you want to add that to the PR? Or did you already measure it and it doesn't help?

@bdraco
Copy link
Contributor Author

bdraco commented Oct 11, 2023

I noticed that you considered calling time() only once -- do you want to add that to the PR? Or did you already measure it and it doesn't help?

I couldn't come up with a way to get it to work that wasn't a breaking change since we need the time before the select and the time after the select in most cases because time moves forward during the select

@gvanrossum gvanrossum enabled auto-merge (squash) October 11, 2023 20:45
bdraco added a commit to bdraco/docker-base that referenced this pull request Oct 11, 2023
@gvanrossum gvanrossum merged commit 3ac8e69 into python:main Oct 11, 2023
@bdraco bdraco deleted the run_once_overhead branch October 11, 2023 21:01
@bdraco
Copy link
Contributor Author

bdraco commented Oct 11, 2023

Thanks!

Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce overhead to run one iteration of the asyncio event loop

2 participants