Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-128002: use per threads tasks linked list in asyncio#128869
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 ourterms of service andprivacy 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
First, great work on this, this is legitimately a cool PR. That said, I'm feeling really uneasy about Also please wait for reviews from@pablogsal and@ambv. I'm curious if this would make external introspection harder. |
Uh oh!
There was an error while loading.Please reload this page.
Does this work where an event loop is used on one thread, stopped then resumed on another thread? |
This comment was marked as resolved.
This comment was marked as resolved.
I have pushed some more changes:
TODO: benchmark it before merging |
pablogsal left a comment• 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.
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.
If I am not mistaken this solution seems incompatible with the asyncio introspecction workflow we are adding on#124640. Please, ensure that this change is compatible with the changes in that PR to avoid problems in the future.
When you're done making the requested changes, leave the comment: |
This PR has nothing to do with asyncio introspection. As I said in other PR, the change which would affect that is moving current task to per-loop which isn't done in this PR. |
Hummm, I must have misread how this affects the task management. Let me dismiss my request for changes meanwhile. Thanks for the patience with this@kumaraditya303! |
@colesbury PTAL |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
This LGTM, but would you please also get this reviewed by another asyncio expert?
add_tasks_interp(PyInterpreterState *interp, PyListObject *tasks) | ||
{ | ||
#ifdef Py_GIL_DISABLED | ||
assert(interp->stoptheworld.world_stopped); |
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.
👍🏻
Uh oh!
There was an error while loading.Please reload this page.
0d68b14
intopython:mainUh oh!
There was an error while loading.Please reload this page.
…#128869)Co-authored-by: Łukasz Langa <lukasz@langa.pl>
…#128869)Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Uh oh!
There was an error while loading.Please reload this page.
Use per-thread linked list of tasks in asyncio. This design allows for lock free register/unregister of tasks of loops running concurrently in different threads. It uses the stop the world pause to traverse the list of tasks from all threads from the thread where
all_tasks
is called. This has no performance impact on regular builds as perbenchmarks and performs a bit faster on free-threadingbenchmarks. pyperformance benchmarks aren't good for this because it uses just one thread so there is little lock contention, this however performs much better when multiple threads are running.On free-threading:
Benchmark hidden because not significant (1): asyncio_websockets