René's URL Explorer Experiment


Title: Use tagged pointers on the stack in the default build. · Issue #127705 · python/cpython · GitHub

Open Graph Title: Use tagged pointers on the stack in the default build. · Issue #127705 · python/cpython

X Title: Use tagged pointers on the stack in the default build. · Issue #127705 · python/cpython

Description: Currently all references to objects in frameobjects use _PyStackRef instead of PyObject *. This is necessary for the free-threaded build to support deferred references. For the default build _PyStackRef is just an alias for PyObject *. W...

Open Graph Description: Currently all references to objects in frameobjects use _PyStackRef instead of PyObject *. This is necessary for the free-threaded build to support deferred references. For the default build _PySta...

X Description: Currently all references to objects in frameobjects use _PyStackRef instead of PyObject *. This is necessary for the free-threaded build to support deferred references. For the default build _PySta...

Opengraph URL: https://github.com/python/cpython/issues/127705

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use tagged pointers on the stack in the default build.","articleBody":"Currently all references to objects in frameobjects use `_PyStackRef` instead of `PyObject *`.\r\nThis is necessary for the free-threaded build to support deferred references.\r\n\r\nFor the default build `_PyStackRef` is just an alias for `PyObject *`.\r\nWe should change `_PyStackRef` to use proper tagged pointers in the default build for two important reasons:\r\n\r\n* It will reduce the maintenance burden of using tagged pointers if they were the same in both builds\r\n* It offers a lot of optimization potential. The overhead of reference counting operations is large, and tagged pointers will allow us to reduce that overhead considerably.\r\n\r\nMy initial implementation is [0.8% slower](https://github.com/faster-cpython/benchmarking-public/tree/main/results/bm-20241206-3.14.0a2+-0c20416), although I'd like to get that closer to 0 before merging anything. There is some speedup in the GC due to streamlined immortality checks, and some slowdown due to increased overhead of turning new `PyObject *` references into `_PyStackRef`s.\r\n\r\nThis small slowdown will allow us a large speedup (maybe more than 5%) as we can do the following:\r\n* Reduce the overhead of refcount operations by using tagged references for the majority of `LOAD_` instructions in the interpreter.\r\n* Completely eliminate many decref operations by tracking which references are tagged in the JIT.\r\n\r\nThe tagging scheme:\r\n Tag | Meaning\r\n--- | --- \r\n00 | Normal pointers\r\n01 | Pointers with embedded reference count\r\n10 | Unused\r\n11 | Pointer to immortal object\u003csup\u003e1\u003c/sup\u003e (including NULL)\r\n\r\nThis tagging scheme is chosen as it provides the best performance for the most common operations:\r\n* PyStackRef_DUP: Can check to see if the object's reference count needs updating with a single check and no memory read: `ptr \u0026 1`\r\n* PyStackRef_CLOSE: As for PyStackRef_DUP, only a single bit check is needed\r\n* PyStackRef_XCLOSE: Since `NULL` is treated as immortal and tagged, this is the same as PyStackRef_CLOSE.\r\n\r\nMaintaining the invariant that tag `11` is used for all immortal objects is a bit expensive, but can be mitigated by pushing the conversion from `PyObject *` to `_PyStackRef` down to a point where it is known whether an object is newly created or not.\r\nFor newly created objects `PyStackRef_FromPyObjectStealMortal` can be used which performs no immortality check.\r\n\r\n --------------\r\n\r\n1. Actually, any object that was immortal when the reference was created. References to objects that are made immortal after the reference is created would have the low bits set to `00`, or `01`.   This is OK as immortal refcounts have a huge margin of error and the number of possible references to one of these immortal objects is very small.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-127875\n* gh-128121\n* gh-130785\n* gh-131072\n* gh-131140\n* gh-131198\n* gh-131365\n* gh-131500\n* gh-131508\n* gh-136178\n* gh-136206\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/markshannon","@type":"Person","name":"markshannon"},"datePublished":"2024-12-06T18:31:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/127705/cpython/issues/127705"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:34d8a1d9-57ae-2e66-38c6-805a7ab8b5c7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id80A4:1D81B0:13AC001:1B07350:696AA00E
html-safe-noncea2ff0608f2d9ea1fa7f46f5176eda3cc38376e85f09208b72288b8df268d0b07
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEE0OjFEODFCMDoxM0FDMDAxOjFCMDczNTA6Njk2QUEwMEUiLCJ2aXNpdG9yX2lkIjoiNzU0Mjg5NTI5NDQxMjM5ODYwNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac1125411e1c470f4c86c25f99879e2a2ed5167f44aefa13ba6f6632c0cee81224
hovercard-subject-tagissue:2723682975
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/127705/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7bc7eb720a9228ef3c61745e9dbd9bcf0eda1c3b9862951d250fc2436befec15/python/cpython/issues/127705
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7bc7eb720a9228ef3c61745e9dbd9bcf0eda1c3b9862951d250fc2436befec15/python/cpython/issues/127705
og:image:altCurrently all references to objects in frameobjects use _PyStackRef instead of PyObject *. This is necessary for the free-threaded build to support deferred references. For the default build _PySta...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemarkshannon
hostnamegithub.com
expected-hostnamegithub.com
Nonea51f97dbb9326f71c08ecb61577457d543c602124d1a2672871258ef37ac5261
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4bd0eac606c70914085176ef312ebdcd97a8cdf1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/127705#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F127705
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%2Fissues%2F127705
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%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/127705
Reloadhttps://github.com/python/cpython/issues/127705
Reloadhttps://github.com/python/cpython/issues/127705
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/127705
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/issues/127705
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
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/127705
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/127705
Use tagged pointers on the stack in the default build.https://github.com/python/cpython/issues/127705#top
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/markshannon
https://github.com/markshannon
markshannonhttps://github.com/markshannon
on Dec 6, 2024https://github.com/python/cpython/issues/127705#issue-2723682975
0.8% slowerhttps://github.com/faster-cpython/benchmarking-public/tree/main/results/bm-20241206-3.14.0a2+-0c20416
GH-127705: Use _PyStackRefs in the default build. #127875https://github.com/python/cpython/pull/127875
GH-127705: Add debug mode for _PyStackRefs inspired by HPy debug mode #128121https://github.com/python/cpython/pull/128121
GH-127705: better double free message. #130785https://github.com/python/cpython/pull/130785
GH-127705: Check for immortality in refcount accounting #131072https://github.com/python/cpython/pull/131072
GH-127705: Fix _Py_RefcntAdd to handle objects becoming immortal #131140https://github.com/python/cpython/pull/131140
GH-127705: Handle trace refs in specialized decref #131198https://github.com/python/cpython/pull/131198
GH-127705: Adds the missing bits from #131198 #131365https://github.com/python/cpython/pull/131365
GH-127705: Revert "Move mortal decrefs to internal header and make sure _PyReftracerTrack is called" #131500https://github.com/python/cpython/pull/131500
GH-127705: Don't call _Py_ForgetReference before _Py_Dealloc #131508https://github.com/python/cpython/pull/131508
gh-127705: Move Py_INCREF_MORTAL() to the internal C API #136178https://github.com/python/cpython/pull/136178
[3.14] gh-127705: Move Py_INCREF_MORTAL() to the internal C API (GH-136178) #136206https://github.com/python/cpython/pull/136206
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
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.