René's URL Explorer Experiment


Title: bpo-40255: Implement Immortal Instances - Optimization 1 by eduardo-elizondo · Pull Request #31488 · python/cpython · GitHub

Open Graph Title: bpo-40255: Implement Immortal Instances - Optimization 1 by eduardo-elizondo · Pull Request #31488 · python/cpython

X Title: bpo-40255: Implement Immortal Instances - Optimization 1 by eduardo-elizondo · Pull Request #31488 · python/cpython

Description: Immortalizing Interned Strings This is an optimization on top of PR19474. The improvement here uses the assumption that all interned strings are alive during the entire lifecycle of the runtime. Thus, every time that a string is interned, it is automatically immortalized. Benchmark Results Overall: 1% slower compared to the master branch pyperformance results 2to3: Mean +- std dev: [cpython_master] 432 ms +- 15 ms -> [immortal_instances_opt1] 437 ms +- 15 ms: 1.01x slower chaos: Mean +- std dev: [cpython_master] 126 ms +- 4 ms -> [immortal_instances_opt1] 122 ms +- 5 ms: 1.03x faster deltablue: Mean +- std dev: [cpython_master] 7.35 ms +- 0.20 ms -> [immortal_instances_opt1] 7.49 ms +- 0.22 ms: 1.02x slower fannkuch: Mean +- std dev: [cpython_master] 664 ms +- 15 ms -> [immortal_instances_opt1] 654 ms +- 20 ms: 1.02x faster float: Mean +- std dev: [cpython_master] 128 ms +- 4 ms -> [immortal_instances_opt1] 133 ms +- 3 ms: 1.04x slower go: Mean +- std dev: [cpython_master] 244 ms +- 10 ms -> [immortal_instances_opt1] 232 ms +- 5 ms: 1.05x faster html5lib: Mean +- std dev: [cpython_master] 97.9 ms +- 4.2 ms -> [immortal_instances_opt1] 99.7 ms +- 5.3 ms: 1.02x slower json_dumps: Mean +- std dev: [cpython_master] 19.2 ms +- 0.7 ms -> [immortal_instances_opt1] 19.7 ms +- 0.7 ms: 1.02x slower json_loads: Mean +- std dev: [cpython_master] 39.5 us +- 0.9 us -> [immortal_instances_opt1] 39.1 us +- 1.3 us: 1.01x faster logging_format: Mean +- std dev: [cpython_master] 10.4 us +- 0.3 us -> [immortal_instances_opt1] 10.7 us +- 0.4 us: 1.03x slower meteor_contest: Mean +- std dev: [cpython_master] 164 ms +- 5 ms -> [immortal_instances_opt1] 161 ms +- 6 ms: 1.02x faster nbody: Mean +- std dev: [cpython_master] 163 ms +- 6 ms -> [immortal_instances_opt1] 160 ms +- 4 ms: 1.02x faster nqueens: Mean +- std dev: [cpython_master] 159 ms +- 5 ms -> [immortal_instances_opt1] 149 ms +- 5 ms: 1.07x faster pathlib: Mean +- std dev: [cpython_master] 28.5 ms +- 0.7 ms -> [immortal_instances_opt1] 27.5 ms +- 0.7 ms: 1.04x faster pickle: Mean +- std dev: [cpython_master] 16.0 us +- 0.5 us -> [immortal_instances_opt1] 16.3 us +- 0.4 us: 1.02x slower pickle_dict: Mean +- std dev: [cpython_master] 37.3 us +- 0.6 us -> [immortal_instances_opt1] 35.4 us +- 1.0 us: 1.05x faster pickle_list: Mean +- std dev: [cpython_master] 5.77 us +- 0.24 us -> [immortal_instances_opt1] 5.70 us +- 0.15 us: 1.01x faster pickle_pure_python: Mean +- std dev: [cpython_master] 572 us +- 14 us -> [immortal_instances_opt1] 582 us +- 24 us: 1.02x slower pidigits: Mean +- std dev: [cpython_master] 284 ms +- 15 ms -> [immortal_instances_opt1] 273 ms +- 8 ms: 1.04x faster pyflate: Mean +- std dev: [cpython_master] 770 ms +- 28 ms -> [immortal_instances_opt1] 742 ms +- 24 ms: 1.04x faster python_startup: Mean +- std dev: [cpython_master] 12.6 ms +- 0.4 ms -> [immortal_instances_opt1] 13.0 ms +- 0.6 ms: 1.04x slower python_startup_no_site: Mean +- std dev: [cpython_master] 8.89 ms +- 0.39 ms -> [immortal_instances_opt1] 8.97 ms +- 0.35 ms: 1.01x slower raytrace: Mean +- std dev: [cpython_master] 529 ms +- 16 ms -> [immortal_instances_opt1] 539 ms +- 10 ms: 1.02x slower regex_compile: Mean +- std dev: [cpython_master] 233 ms +- 6 ms -> [immortal_instances_opt1] 243 ms +- 6 ms: 1.04x slower regex_dna: Mean +- std dev: [cpython_master] 239 ms +- 6 ms -> [immortal_instances_opt1] 244 ms +- 7 ms: 1.02x slower regex_effbot: Mean +- std dev: [cpython_master] 4.53 ms +- 0.12 ms -> [immortal_instances_opt1] 4.73 ms +- 0.16 ms: 1.04x slower regex_v8: Mean +- std dev: [cpython_master] 33.2 ms +- 0.8 ms -> [immortal_instances_opt1] 33.6 ms +- 0.9 ms: 1.01x slower richards: Mean +- std dev: [cpython_master] 82.8 ms +- 3.7 ms -> [immortal_instances_opt1] 86.2 ms +- 5.2 ms: 1.04x slower scimark_fft: Mean +- std dev: [cpython_master] 571 ms +- 12 ms -> [immortal_instances_opt1] 603 ms +- 19 ms: 1.06x slower scimark_lu: Mean +- std dev: [cpython_master] 195 ms +- 6 ms -> [immortal_instances_opt1] 211 ms +- 4 ms: 1.08x slower scimark_monte_carlo: Mean +- std dev: [cpython_master] 116 ms +- 5 ms -> [immortal_instances_opt1] 119 ms +- 4 ms: 1.03x slower scimark_sor: Mean +- std dev: [cpython_master] 211 ms +- 6 ms -> [immortal_instances_opt1] 222 ms +- 4 ms: 1.05x slower scimark_sparse_mat_mult: Mean +- std dev: [cpython_master] 8.28 ms +- 0.40 ms -> [immortal_instances_opt1] 8.51 ms +- 0.23 ms: 1.03x slower spectral_norm: Mean +- std dev: [cpython_master] 208 ms +- 9 ms -> [immortal_instances_opt1] 211 ms +- 4 ms: 1.01x slower sympy_expand: Mean +- std dev: [cpython_master] 878 ms +- 34 ms -> [immortal_instances_opt1] 860 ms +- 24 ms: 1.02x faster sympy_integrate: Mean +- std dev: [cpython_master] 35.2 ms +- 1.0 ms -> [immortal_instances_opt1] 35.6 ms +- 1.0 ms: 1.01x slower sympy_sum: Mean +- std dev: [cpython_master] 291 ms +- 13 ms -> [immortal_instances_opt1] 300 ms +- 8 ms: 1.03x slower sympy_str: Mean +- std dev: [cpython_master] 514 ms +- 11 ms -> [immortal_instances_opt1] 522 ms +- 17 ms: 1.02x slower telco: Mean +- std dev: [cpython_master] 10.4 ms +- 0.2 ms -> [immortal_instances_opt1] 10.6 ms +- 0.5 ms: 1.02x slower unpack_sequence: Mean +- std dev: [cpython_master] 77.9 ns +- 2.3 ns -> [immortal_instances_opt1] 78.8 ns +- 2.3 ns: 1.01x slower unpickle_list: Mean +- std dev: [cpython_master] 6.77 us +- 0.25 us -> [immortal_instances_opt1] 6.90 us +- 0.16 us: 1.02x slower unpickle_pure_python: Mean +- std dev: [cpython_master] 463 us +- 17 us -> [immortal_instances_opt1] 448 us +- 9 us: 1.03x faster xml_etree_parse: Mean +- std dev: [cpython_master] 245 ms +- 6 ms -> [immortal_instances_opt1] 250 ms +- 11 ms: 1.02x slower xml_etree_generate: Mean +- std dev: [cpython_master] 146 ms +- 4 ms -> [immortal_instances_opt1] 144 ms +- 5 ms: 1.01x faster xml_etree_process: Mean +- std dev: [cpython_master] 102 ms +- 2 ms -> [immortal_instances_opt1] 100.0 ms +- 3.0 ms: 1.02x faster Benchmark hidden because not significant (6): django_template, hexiom, logging_silent, logging_simple, unpickle, xml_etree_iterparse Geometric mean: 1.01x slower Implementation Details Any time that PyUnicode_InternInPlace is called, the string will be automatically immortalized. This also re-utilizes the string state mechanism by setting the state to SSTATE_INTERNED_IMMORTAL. Given that all interned strings are now immortal, the SSTATE_INTERNED_MORTAL usage has been deprecated. Interned String Finalization The current change does not attempt to fully clean up the strings during the runtime shutdown. The main reason being that interned strings include both statically allocated strings (i.e Py_Identifiers) and dynamically allocated strings (i.e PyUnicode_New). During the runtime shutdown, it is hard to determined which strings in the interned dictionary are statically allocated vs dynamically allocated. Blindly calling the deallocation function will end up calling PyMem_RawFree on statically allocated memory which will crash the program. This could be in theory fixed by having a way to mark these statics strings differently than the dynamically allocated strings. If we distinguish them during the runtime shutdown, we can run the deallocation function on the dynamic strings. However, all the fields within these instances are already used and have no way to cleanly embed this information. Another option is to use the memory allocation range of _PyRuntime.global_objects.singletons.strings up to sizeof(_Py_global_strings) and anything outside of this is a dynamic string. However, this relies in exposing the internal _Py_global_strings struct. Given there's no clean option, I’ve decided to leave the interned strings as is and let the OS free the memory after the runtime shuts down. https://bugs.python.org/issue40255

Open Graph Description: Immortalizing Interned Strings This is an optimization on top of PR19474. The improvement here uses the assumption that all interned strings are alive during the entire lifecycle of the runtime. Th...

X Description: Immortalizing Interned Strings This is an optimization on top of PR19474. The improvement here uses the assumption that all interned strings are alive during the entire lifecycle of the runtime. Th...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:52906f47-cc86-38e9-404e-2f371735cac7
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idE3CA:C76C3:4B133B:671B32:6969DDE4
html-safe-nonce567586aadc11e7302209c70d3d039d2e3e0b7d2c4804ce99323b7cef18629fb9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0NBOkM3NkMzOjRCMTMzQjo2NzFCMzI6Njk2OURERTQiLCJ2aXNpdG9yX2lkIjoiNjAxNjkzNjc1MDM2MzU2NTU0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac553e2484bdb44d281a36f4f677456b9ecdd982f682144255e2712f7ef0796a9a
hovercard-subject-tagpull_request:860043724
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/31488/checks
twitter:imagehttps://avatars.githubusercontent.com/u/5315899?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/5315899?s=400&v=4
og:image:altImmortalizing Interned Strings This is an optimization on top of PR19474. The improvement here uses the assumption that all interned strings are alive during the entire lifecycle of the runtime. Th...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8
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
releasebdde15ad1b403e23b08bbd89b53fbe6bdf688cad
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/31488/checks#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F31488%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%2F31488%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/31488/checks
Reloadhttps://github.com/python/cpython/pull/31488/checks
Reloadhttps://github.com/python/cpython/pull/31488/checks
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/31488/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/31488/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
eduardo-elizondohttps://github.com/eduardo-elizondo
python:mainhttps://github.com/python/cpython/tree/main
eduardo-elizondo:immortal-references-opt1https://github.com/eduardo-elizondo/cpython/tree/immortal-references-opt1
Conversation 0 https://github.com/python/cpython/pull/31488
Commits 3 https://github.com/python/cpython/pull/31488/commits
Checks 0 https://github.com/python/cpython/pull/31488/checks
Files changed https://github.com/python/cpython/pull/31488/files
Please reload this pagehttps://github.com/python/cpython/pull/31488/checks
Please reload this pagehttps://github.com/python/cpython/pull/31488/checks
bpo-40255: Implement Immortal Instances - Optimization 1 https://github.com/python/cpython/pull/31488/checks#top
Please reload this pagehttps://github.com/python/cpython/pull/31488/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.