René's URL Explorer Experiment


Title: gh-120196: Faster ascii_decode and find_max_char implementations by rhpvorderman · Pull Request #120212 · python/cpython · GitHub

Open Graph Title: gh-120196: Faster ascii_decode and find_max_char implementations by rhpvorderman · Pull Request #120212 · python/cpython

X Title: gh-120196: Faster ascii_decode and find_max_char implementations by rhpvorderman · Pull Request #120212 · python/cpython

Description: One byte find_max_char. This now follows the following algorithm. Find the start where the first aligned load can take place. Bitwise OR all characters together up to the aligned start and check with ASCII_MASK. At aligned start, start loading size_t units in groups of 4. Bitwise OR together and check with ASCII_MASK. When there are less than 4 * size_t units left, get the remaining size_t units and the remainder of the single char units and bitwise OR them all together. This methodology has the following advantages: The number of checks is significantly reduced. (Both ASCII_MASK check and loop iterator check). Due to the extremely low cost of a OR operation handling 4x size_t chunks of data is barely more expensive than single size_t s. As a result the penalty for not exiting earlier if a byte larger than 127 is found is minimal. The compiler is able to vectorize the bitwise OR on the 32 KB chunks. Please note that this only works for GCC 14.1 and higher. Two and four byte find_max_char. Increase the unroll size from 4 to 8. This means loading 16 and 32 bytes simultaneously for Py_UCS2 and Py_UCS4. GCC 14.1 can now vectorize the load and the bitwise OR, which should result in faster speed. ascii_decode: The same advantages as decribed in find_max_char. This function also performs some copying. Using the restrict qualifier on the pointers allows GCC to do a vector store operation. Unfortunately GCC < 14.1 loads the value once for the bitwise OR and once for the load store. Only the load store is vectorized in GCC < 14.1. Luckily, since both loads are from the same cache line and no other loads are performed in between, the latency this introduces should be near zero. So from GCC 14.1 onwards the performance should improve. My debian system has GCC 12.2 but that also should give some improvements. If only I could benchmark: https://discuss.python.org/t/building-python-takes-longer-than-an-hour-due-to-freezing-objects-and-still-counting/55144 Issue: gh-120196

Open Graph Description: One byte find_max_char. This now follows the following algorithm. Find the start where the first aligned load can take place. Bitwise OR all characters together up to the aligned start and check w...

X Description: One byte find_max_char. This now follows the following algorithm. Find the start where the first aligned load can take place. Bitwise OR all characters together up to the aligned start and check w...

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

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:893f49f5-3ea0-8deb-58ca-c97bd54ed97a
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id944A:27CA4:2AA0DA:381CDF:6B023430
html-safe-nonce58cee61d1bb63dfd88ff0aca8aa0845ab88a837bed81f035c626a4a5a0c82250
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDRBOjI3Q0E0OjJBQTBEQTozODFDREY6NkIwMjM0MzAiLCJ2aXNpdG9yX2lkIjoiMTQwNDc3MDAwNDg2MzQzMTcyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacfcc4ef52afc97b2cf990862141c3867f8ef79079dc346025137b3582dd4a7bea
hovercard-subject-tagpull_request:1908908300
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/120212/files
twitter:imagehttps://avatars.githubusercontent.com/u/26142226?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/26142226?s=400&v=4
og:image:altOne byte find_max_char. This now follows the following algorithm. Find the start where the first aligned load can take place. Bitwise OR all characters together up to the aligned start and check w...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
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
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/120212/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F120212%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F120212%2Ffiles
Sign uphttps://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/120212/files
Reloadhttps://github.com/python/cpython/pull/120212/files
Reloadhttps://github.com/python/cpython/pull/120212/files
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
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
rhpvordermanhttps://github.com/rhpvorderman
python:mainhttps://github.com/python/cpython/tree/main
rhpvorderman:MICROOPTIMIZATIONShttps://github.com/rhpvorderman/cpython/tree/MICROOPTIMIZATIONS
Conversation 64 https://github.com/python/cpython/pull/120212
Commits 24 https://github.com/python/cpython/pull/120212/commits
Checks 0 https://github.com/python/cpython/pull/120212/checks
Files changed https://github.com/python/cpython/pull/120212/files
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
gh-120196: Faster ascii_decode and find_max_char implementations https://github.com/python/cpython/pull/120212/files#top
Show all changes 24 commits https://github.com/python/cpython/pull/120212/files
a54bf86 Write an unrolled version of find_max_char rhpvorderman Jun 5, 2024 https://github.com/python/cpython/pull/120212/commits/a54bf86c19c6dc5867e6cf783932eee580041897
71ff457 Unroll 8 characters rather than 4 to improve vectorization in find_ma… rhpvorderman Jun 7, 2024 https://github.com/python/cpython/pull/120212/commits/71ff457d0ff4ede9486ce9160568cd00ab6f7307
98a6449 Bigger chunk ascii decoding rhpvorderman Jun 7, 2024 https://github.com/python/cpython/pull/120212/commits/98a6449411264f42f8151778a490a8ec5b29dbaa
10527c6 Fix whitespace issues rhpvorderman Jun 7, 2024 https://github.com/python/cpython/pull/120212/commits/10527c647f6b6a2d8642815f0dbcc913d2326e32
f0f4139 Fix compiler warnings rhpvorderman Jun 7, 2024 https://github.com/python/cpython/pull/120212/commits/f0f413923ed0dea05c3446f17a80d3cc2090d94e
849a068 Prevent re-read of same value rhpvorderman Jun 7, 2024 https://github.com/python/cpython/pull/120212/commits/849a068cc900cda1bc2feb92ebfc83c12c9337b5
fad19a0 Simplify find_max_char initialization rhpvorderman Jun 7, 2024 https://github.com/python/cpython/pull/120212/commits/fad19a046fcbf071d39b57c56b81b89ee04355e8
f04bb2c Add missing increments rhpvorderman Jun 7, 2024 https://github.com/python/cpython/pull/120212/commits/f04bb2c85c53ca41c3d06098f79c0201aed8190c
cd0fc5e Add blurb rhpvorderman Jun 7, 2024 https://github.com/python/cpython/pull/120212/commits/cd0fc5ef6803689d1aad07b18a294f0ce8b1b19e
8f0fd56 Replace unroll_end with unrolled_end rhpvorderman Jun 7, 2024 https://github.com/python/cpython/pull/120212/commits/8f0fd56b7512dc648861392c05c794594136c869
37aee7a Reword burb rhpvorderman Jun 11, 2024 https://github.com/python/cpython/pull/120212/commits/37aee7a930d79691927b826f7dd51058bd926baf
a6fc417 Update Objects/stringlib/find_max_char.h rhpvorderman Jun 11, 2024 https://github.com/python/cpython/pull/120212/commits/a6fc417ea1b68342a31fa5b49c41196f508c99af
104ca62 Merge branch 'main' into MICROOPTIMIZATIONS rhpvorderman Jun 12, 2024 https://github.com/python/cpython/pull/120212/commits/104ca623d8cca2658aa33c94f598910f867f3bf8
d465517 Merge branch 'main' into MICROOPTIMIZATIONS rhpvorderman Jun 14, 2024 https://github.com/python/cpython/pull/120212/commits/d46551735a3e99c9ccb67495e69df32c7d05a567
1ce308e Reuse find_max_char for bytes objects rhpvorderman Jun 14, 2024 https://github.com/python/cpython/pull/120212/commits/1ce308e9d70f806e507ab1efb1e68c988ebeffa3
48f1e84 Simplify the find_max_char function by loading unaligned rhpvorderman Jun 14, 2024 https://github.com/python/cpython/pull/120212/commits/48f1e84750e2dac0db0d295e68318a8cbaac5616
21de804 Allow optimized unaligned loads and simplify ascii_decode rhpvorderman Jun 14, 2024 https://github.com/python/cpython/pull/120212/commits/21de80470399163865acf0dc2c760180c8df08d1
1ec2113 Add loop for more optimal assembly rhpvorderman Jun 14, 2024 https://github.com/python/cpython/pull/120212/commits/1ec2113f2e64aaed97cfe74fba26975a6b078a97
0258ae0 Also perform an unalgined load at the end rhpvorderman Jun 14, 2024 https://github.com/python/cpython/pull/120212/commits/0258ae0b47b5b0efa9d44f435bd3475e09a9763a
ec76b74 Fix compiler warning rhpvorderman Jun 14, 2024 https://github.com/python/cpython/pull/120212/commits/ec76b74c74a04350c9c761e013ee37c3181ea01c
845eb4e Revert "Reuse find_max_char for bytes objects" rhpvorderman Jun 14, 2024 https://github.com/python/cpython/pull/120212/commits/845eb4e14749292ff5b3ddb6f0c64876f8d05ca7
f8cc68d Merge branch 'main' into MICROOPTIMIZATIONS rhpvorderman Jun 17, 2024 https://github.com/python/cpython/pull/120212/commits/f8cc68ded0ea9fb689536ce4661e199add21b87a
89ab2c9 Improve comments rhpvorderman Jun 17, 2024 https://github.com/python/cpython/pull/120212/commits/89ab2c98cefeeeb5f1d3f99049b284d1fd95c17d
002b7ec Merge branch 'main' into MICROOPTIMIZATIONS rhpvorderman Sep 10, 2024 https://github.com/python/cpython/pull/120212/commits/002b7ec85915dbd27a3068dbc8549316e9655572
Clear filters https://github.com/python/cpython/pull/120212/files
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
2024-06-07-13-29-57.gh-issue-120196.uf2pIh.rst https://github.com/python/cpython/pull/120212/files#diff-f5c2936fbf66421c46ea7222f542e715b71e1bae6895cb7da50e8a999677e456
find_max_char.h https://github.com/python/cpython/pull/120212/files#diff-8956a8f467b218ff8cccf2c348fd30f9225a7bb47cd1df7e469e047f8233f930
unicodeobject.c https://github.com/python/cpython/pull/120212/files#diff-34c966e7876d6f8bf801dd51896327e4f68bba02cddb95fbf3963f0b2e39c38a
Misc/NEWS.d/next/Core and Builtins/2024-06-07-13-29-57.gh-issue-120196.uf2pIh.rsthttps://github.com/python/cpython/pull/120212/files#diff-f5c2936fbf66421c46ea7222f542e715b71e1bae6895cb7da50e8a999677e456
View file https://github.com/rhpvorderman/cpython/blob/002b7ec85915dbd27a3068dbc8549316e9655572/Misc/NEWS.d/next/Core%20and%20Builtins/2024-06-07-13-29-57.gh-issue-120196.uf2pIh.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/120212/{{ revealButtonHref }}
Objects/stringlib/find_max_char.hhttps://github.com/python/cpython/pull/120212/files#diff-8956a8f467b218ff8cccf2c348fd30f9225a7bb47cd1df7e469e047f8233f930
View file https://github.com/rhpvorderman/cpython/blob/002b7ec85915dbd27a3068dbc8549316e9655572/Objects/stringlib/find_max_char.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/120212/{{ revealButtonHref }}
https://github.com/python/cpython/pull/120212/files#diff-8956a8f467b218ff8cccf2c348fd30f9225a7bb47cd1df7e469e047f8233f930
vstinnerhttps://github.com/vstinner
Sep 10, 2024https://github.com/python/cpython/pull/120212/files#r1751915168
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
rhpvordermanhttps://github.com/rhpvorderman
Sep 11, 2024https://github.com/python/cpython/pull/120212/files#r1753311483
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
#123895https://github.com/python/cpython/pull/123895
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
https://github.com/python/cpython/pull/120212/files#diff-8956a8f467b218ff8cccf2c348fd30f9225a7bb47cd1df7e469e047f8233f930
https://github.com/python/cpython/pull/120212/files#diff-8956a8f467b218ff8cccf2c348fd30f9225a7bb47cd1df7e469e047f8233f930
picnixzhttps://github.com/picnixz
Jun 13, 2024https://github.com/python/cpython/pull/120212/files#r1637933140
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
rhpvordermanhttps://github.com/rhpvorderman
Jun 14, 2024https://github.com/python/cpython/pull/120212/files#r1639249570
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
picnixzhttps://github.com/picnixz
Jun 13, 2024https://github.com/python/cpython/pull/120212/files#r1637934244
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
picnixzhttps://github.com/picnixz
Jun 13, 2024https://github.com/python/cpython/pull/120212/files#r1637995098
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
vstinnerhttps://github.com/vstinner
Jun 14, 2024https://github.com/python/cpython/pull/120212/files#r1639499864
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
https://github.com/python/cpython/pull/120212/files#diff-8956a8f467b218ff8cccf2c348fd30f9225a7bb47cd1df7e469e047f8233f930
https://github.com/python/cpython/pull/120212/files#diff-8956a8f467b218ff8cccf2c348fd30f9225a7bb47cd1df7e469e047f8233f930
Objects/unicodeobject.chttps://github.com/python/cpython/pull/120212/files#diff-34c966e7876d6f8bf801dd51896327e4f68bba02cddb95fbf3963f0b2e39c38a
View file https://github.com/rhpvorderman/cpython/blob/002b7ec85915dbd27a3068dbc8549316e9655572/Objects/unicodeobject.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/120212/{{ revealButtonHref }}
https://github.com/python/cpython/pull/120212/files#diff-34c966e7876d6f8bf801dd51896327e4f68bba02cddb95fbf3963f0b2e39c38a
pitrouhttps://github.com/pitrou
Jun 11, 2024https://github.com/python/cpython/pull/120212/files#r1634728344
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
@encukouhttps://github.com/encukou
_Alignofhttps://en.cppreference.com/w/c/language/_Alignof
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
encukouhttps://github.com/encukou
Jun 12, 2024https://github.com/python/cpython/pull/120212/files#r1635902688
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Discoursehttps://discuss.python.org/c/core-dev/c-api/30
Please reload this pagehttps://github.com/python/cpython/pull/120212/files
https://github.com/python/cpython/pull/120212/files#diff-34c966e7876d6f8bf801dd51896327e4f68bba02cddb95fbf3963f0b2e39c38a
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.