Title: Optimize `asyncio.get_running_loop` · Issue #100363 · python/cpython · GitHub
Open Graph Title: Optimize `asyncio.get_running_loop` · Issue #100363 · python/cpython
X Title: Optimize `asyncio.get_running_loop` · Issue #100363 · python/cpython
Description: asyncio.get_running_loop is one of the most performance critical functions in asyncio. With #66285 the running loop can be reset in the fork handler thereby avoiding the need for the getpid checks. The whole running loop holder object is...
Open Graph Description: asyncio.get_running_loop is one of the most performance critical functions in asyncio. With #66285 the running loop can be reset in the fork handler thereby avoiding the need for the getpid checks....
X Description: asyncio.get_running_loop is one of the most performance critical functions in asyncio. With #66285 the running loop can be reset in the fork handler thereby avoiding the need for the getpid checks....
Opengraph URL: https://github.com/python/cpython/issues/100363
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Optimize `asyncio.get_running_loop`","articleBody":"`asyncio.get_running_loop` is one of the most performance critical functions in `asyncio`. With https://github.com/python/cpython/issues/66285 the running loop can be reset in the fork handler thereby avoiding the need for the `getpid` checks. The whole running loop holder object is unnecessary now and adds up unnecessary dependent memory loads. \r\n\r\nBenchmark: \r\n```py\r\nimport asyncio\r\nfrom pyperf import Runner\r\n\r\nasync def main():\r\n for i in range(10000):\r\n asyncio.get_running_loop()\r\n\r\n\r\nrunner = Runner()\r\nrunner.bench_async_func(\"main\", main)\r\n```\r\n\r\nResult: \r\n\r\n| Benchmark | base | patch |\r\n|-----------|:-------:|:---------------------:|\r\n| main | 5.03 ms | 328 us: 15.33x faster |\r\n\r\n\r\nThe numbers speak for themselves. \r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-100364\r\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/kumaraditya303","@type":"Person","name":"kumaraditya303"},"datePublished":"2022-12-20T11:02:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/100363/cpython/issues/100363"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7ad82e92-d75d-ee0a-78b6-c4e9b20841b3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9422:3E1F41:BFE4CC:10C5024:6968DBC8 |
| html-safe-nonce | 24dcbd7d9232efcb90cab85ded2d2e92cf01fdaaa2443f3c437c9db739562263 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDIyOjNFMUY0MTpCRkU0Q0M6MTBDNTAyNDo2OTY4REJDOCIsInZpc2l0b3JfaWQiOiIxNDY5MjAwNTQ4NzA1NjU1NzUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 53a262396effcab9813f046afb8a01f2314eb674198f247244693c1252baf693 |
| hovercard-subject-tag | issue:1504374245 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/100363/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4a2c1703229eb7b2abee9a0686ca8f63d39504d5ffb98b64ded338dcea3b14e5/python/cpython/issues/100363 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4a2c1703229eb7b2abee9a0686ca8f63d39504d5ffb98b64ded338dcea3b14e5/python/cpython/issues/100363 |
| og:image:alt | asyncio.get_running_loop is one of the most performance critical functions in asyncio. With #66285 the running loop can be reset in the fork handler thereby avoiding the need for the getpid checks.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kumaraditya303 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3c4e9f2fc1db52c609205138be6a397cfde4574cb54d53015014de30dd49f27e |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1fb1ea11f8c37dd4dd50347cca70d89824e93788 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width