Repository navigation
gh-97696: asyncio eager tasks factory - #102853
Conversation
2a961d3 to
245a52b
Compare
245a52b to
bcf40dc
Compare
|
I'm still chasing a refleak, but otherwise this should be ready for review |
|
It looks like @graingert's observation is a serious problem. How can we fix this? |
Always create a task object to resolve the design flaw with structured concurrency. Push the eager step execution into the task implementation, so the task itself knows to eagerly execute the first step if created via the eager task factory. Co-authored-by: Jacob Bower <jbower@meta.com>
Co-authored-by: Jacob Bower <jbower@meta.com>
29d04c2 to
10a03a0
Compare
|
latest version of this PR resolves the issues raised on the issue. tests pass, and rerunning the benchmarks results in pretty much the same results (differences from the original impl within noise margins). benchmarks ran using pyperformance with this patch. |
|
@gvanrossum @carljm Could you please take a quick look at this and make sure it resolved your comments? If so, we can merge. Thanks! |
left a comment
There was a problem hiding this comment.
LGTM (assuming the refcount leak buildbots are happy). Go ahead without waiting for me with further changes!
PS. Next time please resist the urge to rebase -- it's harder to pick up a review after a rebase has happened. We squash commits when we merge them into main anyways.
commented
May 1, 2023
| } | ||
| } else { | ||
| // This seems to really help performance on pyperformance benchmarks | ||
| Py_CLEAR(task->task_coro); |
There was a problem hiding this comment.
Is this documented anywhere? I can't find it
commented
May 9, 2023
|
Great to see this land @itamaro. Thanks for being so collaborative on working through the PR. 🎉 |
commented
Aug 8, 2024
|
The proposal at the start of this thread suggested a new method or parameter for eager start. Is there a link to any discussion on why this changed? Are there plans to do something like that in future (or just to make it the default, and remove the old behaviour)? I'm thinking about this from a library side. Changing the global task factory is inappropriate for a library to do, but we still have certain tasks that would strongly benefit from eager execution (I also wonder if a user enabling this globally could end up breaking a library that wasn't expecting eager tasks...). So, some way to execute individual tasks eagerly would be useful (unless it simply becomes the default behaviour). We currently instantiate |
fixes gh-97696
pyperformance results:
pyperformance run performed with local patch that installs the eager tasks factory by default (modifying the benchmark itself to use it requires psf/pyperf#157)
full comparison in this gist