René's URL Explorer Experiment


Title: gh-104144: Skip scheduling a done callback if a TaskGroup task completes eagerly by itamaro · Pull Request #104140 · python/cpython · GitHub

Open Graph Title: gh-104144: Skip scheduling a done callback if a TaskGroup task completes eagerly by itamaro · Pull Request #104140 · python/cpython

X Title: gh-104144: Skip scheduling a done callback if a TaskGroup task completes eagerly by itamaro · Pull Request #104140 · 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 creating tasks as part of a TaskGroup, e.g.: asyncio.get_event_loop().set_task_factory(asyncio.eager_task_factory) async with asyncio.TaskGroup() as tg: tg.create_task(coro1) tg.create_task(coro2) tg.create_task(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 TaskGroup uses callbacks internally that end up getting scheduled to the event loop even if all the tasks were able to finish synchronously, and blocking the coroutine in which TaskGroup() was awaited, preventing the task from completing eagerly even if otherwise it could. applications that use multiple levels of nested TaskGroups can benefit significantly from eagerly completing multiple levels without blocking, as implemented in this PR by skipping scheduling the done callback if the future is done. Benchmarks this makes the async pyperformance benchmarks up to 4x faster (!!), using a patch to pyperformance that adds "eager" flavors and uses TaskGroups instead of gather 3.12-base.20230503.async.3.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 22:18:14.628900 End date: 2023-05-03 22:36:35.397630 3.12-tgcb.20230503.async.3.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 22:38:45.960219 End date: 2023-05-03 22:54:49.008951 +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | Benchmark | 3.12-base.20230503.async.3.json | 3.12-tgcb.20230503.async.3.json | Change | Significance | +===============================+=================================+=================================+==============+========================+ | async_tree_cpu_io_mixed | 843 ms | 827 ms | 1.02x faster | Not significant | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_eager | 383 ms | 92.9 ms | 4.12x faster | Significant (t=189.26) | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_eager_cpu_io_mixed | 708 ms | 412 ms | 1.72x faster | Significant (t=180.43) | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_eager_io | 1.40 sec | 1.39 sec | 1.01x faster | Not significant | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_eager_memoization | 515 ms | 232 ms | 2.22x faster | Significant (t=183.24) | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_io | 1.37 sec | 1.35 sec | 1.01x faster | Not significant | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_memoization | 644 ms | 634 ms | 1.01x faster | Not significant | +-------------------------------+---------------------------------+---------------------------------+--------------+------------------------+ | async_tree_none | 517 ms | 508 ms | 1.02x 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 creating tasks as part...

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 creating tasks as part...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:9b20d31e-8b2f-0b1d-a640-083f313b7dc0
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idACB6:25F5D0:3FA96A:569AB3:6969AE4A
html-safe-noncea4f33cc1a2b00b1bc75822f856fdf3ddcfba69327d6ed85b0b2a9fc73237d6bb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQ0I2OjI1RjVEMDozRkE5NkE6NTY5QUIzOjY5NjlBRTRBIiwidmlzaXRvcl9pZCI6Ijk1MjA0NDc5MDcyNDgwMDA3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac59b2907cd3910c77f1cf777acf0172c2a21e7cfd9c6671581ca3b90de7568686
hovercard-subject-tagpull_request:1337141007
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/104140/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 creating tasks as part...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7
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
release124667f43168afb6c9c03b7c02eb5b1d2e1be3d9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/104140/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F104140%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%2F104140%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/104140/files
Reloadhttps://github.com/python/cpython/pull/104140/files
Reloadhttps://github.com/python/cpython/pull/104140/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/104140/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/104140/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
gvanrossumhttps://github.com/gvanrossum
python:mainhttps://github.com/python/cpython/tree/main
itamaro:taskgroups-skip-done-callbackhttps://github.com/itamaro/cpython/tree/taskgroups-skip-done-callback
Conversation 7 https://github.com/python/cpython/pull/104140
Commits 6 https://github.com/python/cpython/pull/104140/commits
Checks 0 https://github.com/python/cpython/pull/104140/checks
Files changed https://github.com/python/cpython/pull/104140/files
Please reload this pagehttps://github.com/python/cpython/pull/104140/files
gh-104144: Skip scheduling a done callback if a TaskGroup task completes eagerly https://github.com/python/cpython/pull/104140/files#top
Show all changes 6 commits https://github.com/python/cpython/pull/104140/files
5397cd9 gh-NNNN: Skip scheduling a done callback if a TaskGroup task complete… itamaro May 3, 2023 https://github.com/python/cpython/pull/104140/commits/5397cd9f62db0e695d94c59bafc119613110b672
8d6a77e Add NEWS entry itamaro May 3, 2023 https://github.com/python/cpython/pull/104140/commits/8d6a77e8c312bb1cbdaaca2f316897412fce4da3
a125c1f Apply review feedback to NEWS entry itamaro May 4, 2023 https://github.com/python/cpython/pull/104140/commits/a125c1fc495782429baca2f892b7a798ec9bdf4c
dae3e06 Merge branch 'main' into taskgroups-skip-done-callback itamaro May 5, 2023 https://github.com/python/cpython/pull/104140/commits/dae3e063e7d9c7d523ca114291116e23f7fb9ba2
161d0f8 revert skipping _set_task_name if name is None; fix typo in comment itamaro May 5, 2023 https://github.com/python/cpython/pull/104140/commits/161d0f8c6f0241bb20f887522659b1bc8700452d
2b98bd9 Merge branch 'main' into taskgroups-skip-done-callback itamaro May 5, 2023 https://github.com/python/cpython/pull/104140/commits/2b98bd99b9b545620bafdc2ca96d90d1e0b898a5
Clear filters https://github.com/python/cpython/pull/104140/files
Please reload this pagehttps://github.com/python/cpython/pull/104140/files
Please reload this pagehttps://github.com/python/cpython/pull/104140/files
taskgroups.py https://github.com/python/cpython/pull/104140/files#diff-b90f92a0a4d63d1c6e9e82f28f7281db5fd468c356db4309e87c06a65f5606dc
2023-05-03-16-51-53.gh-issue-104144.653Q0P.rst https://github.com/python/cpython/pull/104140/files#diff-8cd098b0f3d62773c0bc494355244d69c09472bdbdb2df4c729d9c5aa22090ef
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L369
Lib/asyncio/taskgroups.pyhttps://github.com/python/cpython/pull/104140/files#diff-b90f92a0a4d63d1c6e9e82f28f7281db5fd468c356db4309e87c06a65f5606dc
View file https://github.com/itamaro/cpython/blob/2b98bd99b9b545620bafdc2ca96d90d1e0b898a5/Lib/asyncio/taskgroups.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/104140/{{ revealButtonHref }}
https://github.com/python/cpython/pull/104140/files#diff-b90f92a0a4d63d1c6e9e82f28f7281db5fd468c356db4309e87c06a65f5606dc
https://github.com/python/cpython/pull/104140/files#diff-b90f92a0a4d63d1c6e9e82f28f7281db5fd468c356db4309e87c06a65f5606dc
Misc/NEWS.d/next/Library/2023-05-03-16-51-53.gh-issue-104144.653Q0P.rsthttps://github.com/python/cpython/pull/104140/files#diff-8cd098b0f3d62773c0bc494355244d69c09472bdbdb2df4c729d9c5aa22090ef
View file https://github.com/itamaro/cpython/blob/2b98bd99b9b545620bafdc2ca96d90d1e0b898a5/Misc/NEWS.d/next/Library/2023-05-03-16-51-53.gh-issue-104144.653Q0P.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/104140/{{ revealButtonHref }}
kumaraditya303https://github.com/kumaraditya303
May 6, 2023https://github.com/python/cpython/pull/104140/files#r1186714354
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/104140/files
itamarohttps://github.com/itamaro
May 7, 2023https://github.com/python/cpython/pull/104140/files#r1186762338
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
itamaro@ac1ee82https://github.com/itamaro/cpython/commit/ac1ee82a311b86d78f422364bf8ada660df21ecb
gh-104251https://github.com/python/cpython/pull/104251
Please reload this pagehttps://github.com/python/cpython/pull/104140/files
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.