Description
Currently asyncio
tasks are stored in a Weakset
, this is inefficient and in some cases causes bugs because of thread safety (#80788). In terms of memory usage it requires maintaining a full set and their corresponding weakref callback to cleanup objects when deallocated and finalized by the gc. In applications where tasks are created at fast pace this becomes a bottle neck, to mitigate this now asyncio
tasks will now be stored in a global double linked of tasks for cases where Task is a subclass of _asyncio.Task
in other cases we still rely on the weakset. This reduces the work done by the gc speedups the execution and reduces memory usage. In some of my own benchmarks I have seen 15- 20% improvement and pyperformance benchmarks reflect roughly the same.
Linked PRs
Metadata
Metadata
Assignees
Projects
Status