René's URL Explorer Experiment


Title: gh-104144: Optimize gather to finish eagerly when all futures complete eagerly by itamaro · Pull Request #104138 · python/cpython · GitHub

Open Graph Title: gh-104144: Optimize gather to finish eagerly when all futures complete eagerly by itamaro · Pull Request #104138 · python/cpython

X Title: gh-104144: Optimize gather to finish eagerly when all futures complete eagerly by itamaro · Pull Request #104138 · python/cpython

Description: gh-97696 introduced eager tasks factory, which speeds up some async-heavy workloads by up to 50% when opted in. installing the eager tasks factory applies out-of-the-box when gathering futures (asyncio.gather(...)), e.g.: asyncio.get_event_loop().set_task_factory(asyncio.eager_task_factory) await asyncio.gather(coro1, coro2, coro3) coro{1,2,3} will eagerly execute the first step, and potentially complete without scheduling to the event loop if the coros don't block. the implementation of eager uses callbacks internally that end up getting scheduled to the event loop even if all the futures were able to finish synchronously, and blocking the coroutine in which gather() was awaited, preventing the task from completing eagerly even if otherwise it could. applications that use multiple levels of nested gathers can benefit significantly from eagerly completing multiple levels without blocking, as implemented in this PR by skipping scheduling done callbacks for futures that are already done (e.g. finished eagerly). Benchmarks this makes the async pyperformance benchmarks up to 3x faster (!!), using a patch to pyperformance that adds "eager" flavors 3.12-base.20230503.async.4.json =============================== Performance version: 1.0.7 Python version: 3.12.0a7+ (64-bit) revision da1980afcb Report on Linux-5.15.0-1033-aws-x86_64-with-glibc2.31 Number of logical CPUs: 72 Start date: 2023-05-03 23:27:23.329046 End date: 2023-05-03 23:46:37.706326 3.12-nogf.20230503.async.2.json =============================== Performance version: 1.0.7 Python version: 3.12.0a7+ (64-bit) revision 5397cd9f62 Report on Linux-5.15.0-1033-aws-x86_64-with-glibc2.31 Number of logical CPUs: 72 Start date: 2023-05-03 23:05:45.011427 End date: 2023-05-03 23:22:44.908094 +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | Benchmark | 3.12-base.20230503.async.4.json | 3.12-nogf.20230503.async.2.json | Change | Significance | +===============================+=================================+=================================+==============+========================+ | async_tree_cpu_io_mixed | 868 ms | 859 ms | 1.01x faster | Not significant | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_eager | 391 ms | 129 ms | 3.03x faster | Significant (t=209.74) | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_eager_cpu_io_mixed | 756 ms | 490 ms | 1.54x faster | Significant (t=167.41) | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_eager_io | 1.51 sec | 1.50 sec | 1.00x faster | Not significant | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_eager_memoization | 595 ms | 314 ms | 1.89x faster | Significant (t=70.25) | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_io | 1.39 sec | 1.40 sec | 1.00x slower | Not significant | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_memoization | 677 ms | 683 ms | 1.01x slower | Not significant | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_none | 575 ms | 574 ms | 1.00x faster | Not significant | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ Issue: gh-104144

Open Graph Description: gh-97696 introduced eager tasks factory, which speeds up some async-heavy workloads by up to 50% when opted in. installing the eager tasks factory applies out-of-the-box when gathering futures (asy...

X Description: gh-97696 introduced eager tasks factory, which speeds up some async-heavy workloads by up to 50% when opted in. installing the eager tasks factory applies out-of-the-box when gathering futures (asy...

Opengraph URL: https://github.com/python/cpython/pull/104138

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:25022f8c-b0e1-a6b7-1bfe-579a86e6cfda
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD59C:15D295:2110764:2D90DE8:696ABA29
html-safe-nonce987bb7bccac2cb92645cbe28cd4dacd723f9f512e336d139620ee445d61a42d4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTlDOjE1RDI5NToyMTEwNzY0OjJEOTBERTg6Njk2QUJBMjkiLCJ2aXNpdG9yX2lkIjoiMzU5ODM1NzkxMDU1NjE2MjYwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac5ec2f231ab8d0aca41ba13915afea9d866c0ab6c5d1b481fc6016e998a2150e2
hovercard-subject-tagpull_request:1337117158
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/104138/files
twitter:imagehttps://avatars.githubusercontent.com/u/290943?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/290943?s=400&v=4
og:image:altgh-97696 introduced eager tasks factory, which speeds up some async-heavy workloads by up to 50% when opted in. installing the eager tasks factory applies out-of-the-box when gathering futures (asy...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None46ce962e0e18113ea447391b6ace8b02d4d2861e57b4fbab3658698f73d8855b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release30300f30bb3949de255e84a146706a3bdb5c19c9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/104138/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F104138%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F104138%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/104138/files
Reloadhttps://github.com/python/cpython/pull/104138/files
Reloadhttps://github.com/python/cpython/pull/104138/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/104138/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/pull/104138/files
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
kumaraditya303https://github.com/kumaraditya303
python:mainhttps://github.com/python/cpython/tree/main
itamaro:asyncio-skip-gathering-futurehttps://github.com/itamaro/cpython/tree/asyncio-skip-gathering-future
Conversation 15 https://github.com/python/cpython/pull/104138
Commits 8 https://github.com/python/cpython/pull/104138/commits
Checks 0 https://github.com/python/cpython/pull/104138/checks
Files changed https://github.com/python/cpython/pull/104138/files
Please reload this pagehttps://github.com/python/cpython/pull/104138/files
gh-104144: Optimize gather to finish eagerly when all futures complete eagerly https://github.com/python/cpython/pull/104138/files#top
Show all changes 8 commits https://github.com/python/cpython/pull/104138/files
b3e479a gh-NNNN: Skip creating GatheringFuture if all futures finished eagerly itamaro May 3, 2023 https://github.com/python/cpython/pull/104138/commits/b3e479ac2830642ba6d4dcf22259e22a8145a2d9
8eeebaf Add NEWS entry itamaro May 3, 2023 https://github.com/python/cpython/pull/104138/commits/8eeebaf125c113f640b9e36ec302bd1164f1ae5e
9289c9e Apply review suggestion to NEWS entry itamaro May 4, 2023 https://github.com/python/cpython/pull/104138/commits/9289c9e5ada4dd01f539edf86717a7a8798f2de4
edbb04c Merge branch 'main' into asyncio-skip-gathering-future itamaro May 5, 2023 https://github.com/python/cpython/pull/104138/commits/edbb04cf1b18b4eb7a009d64b237675d75f293ee
9be6e51 Modify implementation to eagerly call done callbacks at the end of th… itamaro May 5, 2023 https://github.com/python/cpython/pull/104138/commits/9be6e519273e8ce3078e9f9e9e2c61bb292417c7
250b73c update inline comment and NEWS entry itamaro May 5, 2023 https://github.com/python/cpython/pull/104138/commits/250b73ca49192d446ab492ff06cbbe51805523e0
7df90eb Merge branch 'main' into asyncio-skip-gathering-future itamaro May 5, 2023 https://github.com/python/cpython/pull/104138/commits/7df90eb7ce152e8d08571299bf2d7798d087e035
ce52714 Fix NEWS typo gvanrossum May 6, 2023 https://github.com/python/cpython/pull/104138/commits/ce52714dc6d0a3ada7a925cec631ff6cccc2a06d
Clear filters https://github.com/python/cpython/pull/104138/files
Please reload this pagehttps://github.com/python/cpython/pull/104138/files
Please reload this pagehttps://github.com/python/cpython/pull/104138/files
tasks.py https://github.com/python/cpython/pull/104138/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
2023-05-03-16-50-24.gh-issue-104144.yNkjL8.rst https://github.com/python/cpython/pull/104138/files#diff-9d3cece13d78b048d2df5098a3044bb2f5b11b188a084d2485b57d176098b29d
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L369
Lib/asyncio/tasks.pyhttps://github.com/python/cpython/pull/104138/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
View file https://github.com/itamaro/cpython/blob/ce52714dc6d0a3ada7a925cec631ff6cccc2a06d/Lib/asyncio/tasks.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/104138/{{ revealButtonHref }}
https://github.com/python/cpython/pull/104138/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
https://github.com/python/cpython/pull/104138/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
https://github.com/python/cpython/pull/104138/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
https://github.com/python/cpython/pull/104138/files#diff-429f4ed1e0f89ea2c92e2a8e8548ea8ae1a3d528979554fbfa4c38329e951529
Misc/NEWS.d/next/Library/2023-05-03-16-50-24.gh-issue-104144.yNkjL8.rsthttps://github.com/python/cpython/pull/104138/files#diff-9d3cece13d78b048d2df5098a3044bb2f5b11b188a084d2485b57d176098b29d
View file https://github.com/itamaro/cpython/blob/ce52714dc6d0a3ada7a925cec631ff6cccc2a06d/Misc/NEWS.d/next/Library/2023-05-03-16-50-24.gh-issue-104144.yNkjL8.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/104138/{{ revealButtonHref }}
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.