Reduce asyncio heapq overhead #122881
Labels
performance
Performance or resource usage
topic-asyncio
type-feature
A feature request or enhancement
Feature or enhancement
Proposal:
The
heapq
calls in base_events.py represents quite a bit of asyncio scheduling overhead because they have to run__lt__
quite often inTimerHandle
cpython/Lib/asyncio/events.py
Line 128 in 0fd97e4
cpython/Lib/asyncio/base_events.py
Line 1968 in 0fd97e4
cpython/Lib/asyncio/base_events.py
Line 815 in 0fd97e4
cpython/Lib/asyncio/base_events.py
Line 1975 in 0fd97e4
Avoiding running
__lt__
can speed up processingcall_at
s by ~10%Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
Wrapping
TimerHandle
in a tuple starting withwhen
avoids the__lt__
call. Thank you to whoever wrote theheapq
docs for help getting there https://docs.python.org/3/library/heapq.html#basic-examples6f80b4c
Example benchmark
Linked PRs
The text was updated successfully, but these errors were encountered: