René's URL Explorer Experiment


Title: gh-115999: Specialize `CALL_KW` in free-threaded builds by mpage · Pull Request #127713 · python/cpython · GitHub

Open Graph Title: gh-115999: Specialize `CALL_KW` in free-threaded builds by mpage · Pull Request #127713 · python/cpython

X Title: gh-115999: Specialize `CALL_KW` in free-threaded builds by mpage · Pull Request #127713 · python/cpython

Description: The CALL_KW family was already thread-safe. Only one change to fix a bug in _PY_FRAME_KW was needed: _PY_FRAME_KW pushes a pointer to the new frame onto the stack for consumption by the next uop. When pushing the frame fails, we do not want to push the result, NULL, to the stack because it is not a valid stackref. This works in the default build because PyStackRef_NULL and NULL are the same value, so the PyStackRef_XCLOSE() in the error handler ignores it. In the free-threaded build the values are not the same, causing PyStackRef_XCLOSE() to decref a null pointer. Single-threaded performance Performance looks neutral on both builds. I think this is still worth merging to keep the two builds consistent, however. Default build Free-threaded build Scalability Scalability looks roughly unchanged: Base PR object_cfunction 1.5x slower 1.4x slower cmodule_function 1.6x slower 1.6x slower mult_constant 12.8x faster 13.2x faster generator 13.5x faster 10.1x faster pymethod 1.9x slower 1.9x slower pyfunction 10.7x faster 13.4x faster module_function 2.1x slower 2.0x slower load_string_const 14.2x faster 13.1x faster load_tuple_const 13.6x faster 13.2x faster create_pyobject 15.5x faster 15.7x faster create_closure 12.3x faster 13.5x faster create_dict 13.3x faster 12.9x faster thread_local_read 4.0x slower 3.8x slower Thread safety The specialized instructions are composed of the follow uops, whose thread-safety is documented below. _CALL_KW_NON_PY - Tuples are immutable; it's fine to read their size non-atomically. _CHECK_FUNCTION_VERSION_KW - This uop guards that the top of the stack is a function and that its version matches the version stored in the inline cache. Instructions assume that if the guard passes, the version, and any properties verified by the version, will not change for the remainder of the instruction execution, assuming there are no escaping calls in between the guard and the code that relies on the guard. This property is preserved in free-threaded builds: the world is stopped whenever a function's version changes. _CHECK_IS_NOT_PY_CALLABLE_KW - Performs type checks. _CHECK_METHOD_VERSION_KW - This loads a function from a PyMethodObject and guards that its version matches what is stored in the cache. PyMethodObjects are immutable; their fields can be accessed non-atomically. The thread safety of function version guards was already documented above. _CHECK_PEP_523 - Thread safety was addressed as part of CALL. _CHECK_PERIODIC - Thread safety was previously addressed as part of the 3.13 release. _EXPAND_METHOD_KW - Only loads from PyMethodObjects and performs type checks. _PUSH_FRAME - Only manipulates tstate->current_frame and fields that are not read by other threads. _PY_FRAME_KW - Loads immutable fields (tuple size, code flags) or fields that require stopping the world to modify (function code) and uses thread-safe APIs. _SAVE_RETURN_OFFSET - Stores only to the frame's return_offset which is not read by other threads. Specialization only looks at properties that require stopping the world to update (i.e. instance type, eval_frame, func_code, and the function version) and contains no escaping calls. Issue: gh-115999

Open Graph Description: The CALL_KW family was already thread-safe. Only one change to fix a bug in _PY_FRAME_KW was needed: _PY_FRAME_KW pushes a pointer to the new frame onto the stack for consumption by the next uop. W...

X Description: The CALL_KW family was already thread-safe. Only one change to fix a bug in _PY_FRAME_KW was needed: _PY_FRAME_KW pushes a pointer to the new frame onto the stack for consumption by the next uop. W...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:72674e33-7c30-cc9d-b5c1-35795f49f60f
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD3DE:37ED2:8DBD1:BDFD7:6A5676AD
html-safe-nonce3fd261eaf23e9a1efd27dc71061cd6967007ec1f1be758657d00e5deef790eba
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0RFOjM3RUQyOjhEQkQxOkJERkQ3OjZBNTY3NkFEIiwidmlzaXRvcl9pZCI6IjYxMTY4MDg5NjQ5NDI3NTU1MDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac1c39bf82527f4229744e0c1cb0a43e063b40db493db874c7b8693c1b5dc09a78
hovercard-subject-tagpull_request:2221031920
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/127713/files
twitter:imagehttps://avatars.githubusercontent.com/u/577841?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/577841?s=400&v=4
og:image:altThe CALL_KW family was already thread-safe. Only one change to fix a bug in _PY_FRAME_KW was needed: _PY_FRAME_KW pushes a pointer to the new frame onto the stack for consumption by the next uop. W...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None19b5ee9431dcfce15ab4b001d626e4e3a6ba1acb7be814813a52bbebd9a86ef5
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
releaseafc01ffdb045f4ff81c6122091366ade7b6166b7
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/127713/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F127713%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
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
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
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/enterprise/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%2F127713%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/127713/files
Reloadhttps://github.com/python/cpython/pull/127713/files
Reloadhttps://github.com/python/cpython/pull/127713/files
Please reload this pagehttps://github.com/python/cpython/pull/127713/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/127713/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k 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.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
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 and quality 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
mpagehttps://github.com/mpage
python:mainhttps://github.com/python/cpython/tree/main
mpage:gh-115999-tlbc-call-kwhttps://github.com/mpage/cpython/tree/gh-115999-tlbc-call-kw
Conversation 5 https://github.com/python/cpython/pull/127713
Commits 3 https://github.com/python/cpython/pull/127713/commits
Checks 0 https://github.com/python/cpython/pull/127713/checks
Files changed https://github.com/python/cpython/pull/127713/files
Please reload this pagehttps://github.com/python/cpython/pull/127713/files
gh-115999: Specialize CALL_KW in free-threaded builds https://github.com/python/cpython/pull/127713/files#top
Show all changes 3 commits https://github.com/python/cpython/pull/127713/files
e56da80 Enable specialization of CALL_KW mpage Nov 17, 2024 https://github.com/python/cpython/pull/127713/commits/e56da806c880cacf7f5653816cddd11caf86048d
b22403e Fix bug pushing frame in _PY_FRAME_KW mpage Nov 17, 2024 https://github.com/python/cpython/pull/127713/commits/b22403e80ad3d099d4285e8c7f7f233f02cdb8b3
aef38b1 Merge branch 'main' into gh-115999-tlbc-call-kw mpage Dec 11, 2024 https://github.com/python/cpython/pull/127713/commits/aef38b14d309041bab77054007c572af76b72741
Clear filters https://github.com/python/cpython/pull/127713/files
Please reload this pagehttps://github.com/python/cpython/pull/127713/files
Please reload this pagehttps://github.com/python/cpython/pull/127713/files
bytecodes.c https://github.com/python/cpython/pull/127713/files#diff-729a985b0cb8b431cb291f1edb561bbbfea22e3f8c262451cd83328a0936a342
executor_cases.c.h https://github.com/python/cpython/pull/127713/files#diff-a1c3430c42a66c16e6d2e154491a6da993b187b27c628545a12a02c7b2a06b81
generated_cases.c.h https://github.com/python/cpython/pull/127713/files#diff-4ef46fa654f95502e49a24f7dc8ee31a4cac9b3433fe9cd2b2d4dd78cfbad448
specialize.c https://github.com/python/cpython/pull/127713/files#diff-22e653d878778ca28317261f7826545288d02fd9980cf485d0329f28a34993f2
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L225
Python/bytecodes.chttps://github.com/python/cpython/pull/127713/files#diff-729a985b0cb8b431cb291f1edb561bbbfea22e3f8c262451cd83328a0936a342
View file https://github.com/mpage/cpython/blob/aef38b14d309041bab77054007c572af76b72741/Python/bytecodes.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/127713/{{ revealButtonHref }}
https://github.com/python/cpython/pull/127713/files#diff-729a985b0cb8b431cb291f1edb561bbbfea22e3f8c262451cd83328a0936a342
https://github.com/python/cpython/pull/127713/files#diff-729a985b0cb8b431cb291f1edb561bbbfea22e3f8c262451cd83328a0936a342
https://github.com/python/cpython/pull/127713/files#diff-729a985b0cb8b431cb291f1edb561bbbfea22e3f8c262451cd83328a0936a342
https://github.com/python/cpython/pull/127713/files#diff-729a985b0cb8b431cb291f1edb561bbbfea22e3f8c262451cd83328a0936a342
Python/executor_cases.c.hhttps://github.com/python/cpython/pull/127713/files#diff-a1c3430c42a66c16e6d2e154491a6da993b187b27c628545a12a02c7b2a06b81
View file https://github.com/mpage/cpython/blob/aef38b14d309041bab77054007c572af76b72741/Python/executor_cases.c.h
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/python/cpython/pull/127713/files
Python/generated_cases.c.hhttps://github.com/python/cpython/pull/127713/files#diff-4ef46fa654f95502e49a24f7dc8ee31a4cac9b3433fe9cd2b2d4dd78cfbad448
View file https://github.com/mpage/cpython/blob/aef38b14d309041bab77054007c572af76b72741/Python/generated_cases.c.h
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/python/cpython/pull/127713/files
Python/specialize.chttps://github.com/python/cpython/pull/127713/files#diff-22e653d878778ca28317261f7826545288d02fd9980cf485d0329f28a34993f2
View file https://github.com/mpage/cpython/blob/aef38b14d309041bab77054007c572af76b72741/Python/specialize.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/127713/{{ revealButtonHref }}
https://github.com/python/cpython/pull/127713/files#diff-22e653d878778ca28317261f7826545288d02fd9980cf485d0329f28a34993f2
https://github.com/python/cpython/pull/127713/files#diff-22e653d878778ca28317261f7826545288d02fd9980cf485d0329f28a34993f2
https://github.com/python/cpython/pull/127713/files#diff-22e653d878778ca28317261f7826545288d02fd9980cf485d0329f28a34993f2
https://github.com/python/cpython/pull/127713/files#diff-22e653d878778ca28317261f7826545288d02fd9980cf485d0329f28a34993f2
https://github.com/python/cpython/pull/127713/files#diff-22e653d878778ca28317261f7826545288d02fd9980cf485d0329f28a34993f2
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.