René's URL Explorer Experiment


Title: Use dict keys-version stamps and entry-index hints in LOAD_ATTR/STORE_ATTR specializations by youknowone · Pull Request #8350 · RustPython/RustPython · GitHub

Open Graph Title: Use dict keys-version stamps and entry-index hints in LOAD_ATTR/STORE_ATTR specializations by youknowone · Pull Request #8350 · RustPython/RustPython

X Title: Use dict keys-version stamps and entry-index hints in LOAD_ATTR/STORE_ATTR specializations by youknowone · Pull Request #8350 · RustPython/RustPython

Description: Even after LOAD_ATTR specializes, the specialized handlers still paid for a full hash+probe dict lookup on every execution — LoadAttrWithHint ignored its hint, LoadAttrMethodWithValues probed the instance dict as its shadow check, and StoreAttr* re-probed on every store. This PR replaces those probes with two cheap guards. Changes Dict keys-version stamp (dict_inner.rs) Dict gets a keys_version: AtomicU32. Stamps are allocated from a global counter and never reused, so equal nonzero stamps guarantee an unchanged key set. Any key-set change (new key, deletion, pop, clear, drain_entries) resets the stamp while holding the write lock, before the mutation; value-only updates keep it. New get_with_hint (lookup returning the entry index) and insert_with_hint (identity-checked value replace by entry index, falling back to a full insert). LOAD_ATTR_METHOD_WITH_VALUES / LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES — the shadow check caches the instance dict's stamp in the instruction's pointer-cache slot. While the stamp matches, the per-call dict probe is skipped entirely (an integer compare, like CPython's keys-version check). The stamp is taken before the absence probe so a concurrent key-set change can never leave a stale skip. Dict subclasses never get a stamp and always probe. LOAD_ATTR_WITH_HINT — the specializer now stores the entry index in the cache. A hit is a single identity check on the hinted entry's key — no hashing, no probe sequence. On miss the handler re-probes and refreshes the hint in place. STORE_ATTR_WITH_HINT / STORE_ATTR_INSTANCE_VALUE — same treatment via set_item_with_hint: value replace through the cached entry index, self-refreshing on miss. Results (Apple M5 Max, release, vs CPython 3.14.5) benchmark before after CPython c.x read overhead vs local read 25.4 ns ~16 ns (−37%) 2.2 ns self.value r/w + c.add(i) loop 183 ns/iter ~163 ns/iter (−11%) 24.4 ns Profiles confirm the Dict::get hash-probe frames (~7–10% of samples) are gone from both loops; the remaining gap is dominated by call overhead, int boxing, and dispatch (tracked separately). Testing cargo test workspace (the pre-existing rustpython-capi pyo3 build failure is unrelated) -m test for test_dict, test_descr, test_class, test_weakref, test_gc, test_property, test_super, test_builtin, test_types, test_copy, test_pickle, test_ordered_dict, test_userdict, test_collections — all SUCCESS New regression tests in extra_tests/snippets/vm_specialization.py (shadowing after warmup, value-only updates, hint invalidation across key churn / __dict__ replacement / clear()), also validated against CPython 3.14 Multithreaded stress test of concurrent shadowing/deletion and key-set churn against the stamp and hint paths Fixes youknowone#42 🤖 Generated with Claude Code Summary by CodeRabbit Performance Improved instance attribute access and dict lookups using refreshed hint-based fast paths that account for per-dictionary keyset/layout changes. Enhanced hinted attribute store/update so cached attribute resolution remains valid with fewer slow-path fallbacks. Bug Fixes Strengthened cache invalidation on keyset mutations (including clears/drains and related updates) to avoid stale results. Improved correctness when attributes/methods are shadowed and when dicts have “holes” after deletions. Tests Expanded VM specialization regression coverage for method/value shadowing, hint survival across attribute/dict churn, shared layout behavior, and hole handling.

Open Graph Description: Even after LOAD_ATTR specializes, the specialized handlers still paid for a full hash+probe dict lookup on every execution — LoadAttrWithHint ignored its hint, LoadAttrMethodWithValues probed the i...

X Description: Even after LOAD_ATTR specializes, the specialized handlers still paid for a full hash+probe dict lookup on every execution — LoadAttrWithHint ignored its hint, LoadAttrMethodWithValues probed the i...

Opengraph URL: https://github.com/RustPython/RustPython/pull/8350

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:69a37fca-536d-d99f-1180-ecd5bae2d844
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC7BE:13B657:D34E9B:121AFD4:6A628E80
html-safe-nonceeb323edb8730391530a1bb093e28661dd702ed8fc3b2ba82790f63306aa98416
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDN0JFOjEzQjY1NzpEMzRFOUI6MTIxQUZENDo2QTYyOEU4MCIsInZpc2l0b3JfaWQiOiI2NDUyNDgzMzM2NTUzMjcwOTEyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacb4743836917c20cf309e52084a14ba6de5fa8a861da27cff1a27bef9a2a216bd
hovercard-subject-tagpull_request:4112961018
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/RustPython/RustPython/pull/8350/files
twitter:imagehttps://avatars.githubusercontent.com/u/69878?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/69878?s=400&v=4
og:image:altEven after LOAD_ATTR specializes, the specialized handlers still paid for a full hash+probe dict lookup on every execution — LoadAttrWithHint ignored its hint, LoadAttrMethodWithValues probed the i...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneac2209d8cb6970a1bd08cb0a3f821d7166ac544c2ca1c87819c335bb84310ecd
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
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
release2fca8cd598678aaa64706088ad13b4e19177e108
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/8350/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F8350%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
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
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%2FRustPython%2FRustPython%2Fpull%2F8350%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=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/8350/files
Reloadhttps://github.com/RustPython/RustPython/pull/8350/files
Reloadhttps://github.com/RustPython/RustPython/pull/8350/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8350/files
RustPython https://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Notifications https://github.com/login?return_to=%2FRustPython%2FRustPython
Fork 1.5k https://github.com/login?return_to=%2FRustPython%2FRustPython
Star 22.2k https://github.com/login?return_to=%2FRustPython%2FRustPython
Code https://github.com/RustPython/RustPython
Issues 294 https://github.com/RustPython/RustPython/issues
Pull requests 104 https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality 0 https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Code https://github.com/RustPython/RustPython
Issues https://github.com/RustPython/RustPython/issues
Pull requests https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
youknowonehttps://github.com/youknowone
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
youknowone:load-attr-dict-hintshttps://github.com/youknowone/RustPython/tree/load-attr-dict-hints
Conversation 22 https://github.com/RustPython/RustPython/pull/8350
Commits 5 https://github.com/RustPython/RustPython/pull/8350/commits
Checks 25 https://github.com/RustPython/RustPython/pull/8350/checks
Files changed https://github.com/RustPython/RustPython/pull/8350/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8350/files
Use dict keys-version stamps and entry-index hints in LOAD_ATTR/STORE_ATTR specializations https://github.com/RustPython/RustPython/pull/8350/files#top
Show all changes 5 commits https://github.com/RustPython/RustPython/pull/8350/files
5c75bae Use dict keys-version stamps and entry-index hints in attr specializa… youknowone Jul 23, 2026 https://github.com/RustPython/RustPython/pull/8350/commits/5c75bae2a32b2e838e034763411def7f98db8637
33b55c7 Share keys-version stamps between dicts with identical layouts youknowone Jul 23, 2026 https://github.com/RustPython/RustPython/pull/8350/commits/33b55c7031cb17ea770bc8d244d2ba900c25bd46
4f04de4 Address clippy and review feedback for keys-version stamps youknowone Jul 23, 2026 https://github.com/RustPython/RustPython/pull/8350/commits/4f04de434a272821f79e29edec5f31b934564e8a
88dd489 Restore try_read_cached_descriptor doc comment to its function youknowone Jul 23, 2026 https://github.com/RustPython/RustPython/pull/8350/commits/88dd489ee2d4636bf603a0ac5bf01f69d8e969a4
6ccc0fe Specialize LoadAttrWithHint even when the entry index exceeds u16 youknowone Jul 23, 2026 https://github.com/RustPython/RustPython/pull/8350/commits/6ccc0fe1429711b73df943404f272712e6be7933
Clear filters https://github.com/RustPython/RustPython/pull/8350/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8350/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8350/files
bytecode.rs https://github.com/RustPython/RustPython/pull/8350/files#diff-14e38729fc9f6fc42fa6a3125689aa0034480a2cf3ebd59f1c4d1f40fdcd36a0
dict.rs https://github.com/RustPython/RustPython/pull/8350/files#diff-da22219fe05502509c75f7b1ba56079fecf076601f219531bef523705764e68b
dict_inner.rs https://github.com/RustPython/RustPython/pull/8350/files#diff-aa3e0344e8fe84f229558c441057af178d20ee5bb19fda4bc01485a9a62bf99e
frame.rs https://github.com/RustPython/RustPython/pull/8350/files#diff-03f2741d7d424014f3d2f0c82226be52fa58134aab34bf0780714ee67a248deb
vm_specialization.py https://github.com/RustPython/RustPython/pull/8350/files#diff-f73a26851dceecd61fc4f4d1437c85fb5b21ff271a3c90c4858ce21273712139
crates/compiler-core/src/bytecode.rshttps://github.com/RustPython/RustPython/pull/8350/files#diff-14e38729fc9f6fc42fa6a3125689aa0034480a2cf3ebd59f1c4d1f40fdcd36a0
View file https://github.com/youknowone/RustPython/blob/6ccc0fe1429711b73df943404f272712e6be7933/crates/compiler-core/src/bytecode.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8350/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8350/files#diff-14e38729fc9f6fc42fa6a3125689aa0034480a2cf3ebd59f1c4d1f40fdcd36a0
https://github.com/RustPython/RustPython/pull/8350/files#diff-14e38729fc9f6fc42fa6a3125689aa0034480a2cf3ebd59f1c4d1f40fdcd36a0
crates/vm/src/builtins/dict.rshttps://github.com/RustPython/RustPython/pull/8350/files#diff-da22219fe05502509c75f7b1ba56079fecf076601f219531bef523705764e68b
View file https://github.com/youknowone/RustPython/blob/6ccc0fe1429711b73df943404f272712e6be7933/crates/vm/src/builtins/dict.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8350/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8350/files#diff-da22219fe05502509c75f7b1ba56079fecf076601f219531bef523705764e68b
https://github.com/RustPython/RustPython/pull/8350/files#diff-da22219fe05502509c75f7b1ba56079fecf076601f219531bef523705764e68b
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8350/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8350/files
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.