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/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:a258e507-8e67-9ea0-43ea-82fbeb09ab5a
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idD13A:247E0C:40FAAE:5AB98B:696A7551
html-safe-noncee4f45ba563815c29f33bf4e7708da65fe2fb0a562839030c0f344129a614cbe3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTNBOjI0N0UwQzo0MEZBQUU6NUFCOThCOjY5NkE3NTUxIiwidmlzaXRvcl9pZCI6IjYyMzQ1ODUyNzQ2NTAzNTkxMjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacae2c415cf423e2d8cabc5c3deceaa50e9cc52ce1c2f2f96afdb92fa683ef2893
hovercard-subject-tagpull_request:1337117158
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/checks
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/104138/checks
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
Nonecfa223d62d272274e0b68350b4bd7741f3ca7498b8c4b8b1bc1e6deabbdbc09d
turbo-cache-controlno-preview
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 full-width-p-0
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release6a0b6893c221f98f607598e939299fdf5763435d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/104138/checks#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F104138%2Fchecks
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%2Fchecks
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%2Fchecks&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/104138/checks
Reloadhttps://github.com/python/cpython/pull/104138/checks
Reloadhttps://github.com/python/cpython/pull/104138/checks
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/104138/checks
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/checks
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/checks
Please reload this pagehttps://github.com/python/cpython/pull/104138/checks
gh-104144: Optimize gather to finish eagerly when all futures complete eagerly https://github.com/python/cpython/pull/104138/checks#top
Please reload this pagehttps://github.com/python/cpython/pull/104138/checks
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.