Repository navigation
perf(runtime): size the canonical-handle address index and release what it retires (-7.63% command CPU) - #1
Open
proggeramlug wants to merge 1 commit into
Conversation
Measurement arm without the census counters: the same change as the census branch's b76dc1c, applied to the retained own-read-cache candidate source so this binary is comparable with the retained control. The 1,024-bit RegistryAddrFilter stopped discriminating for the canonical-handle owner: 643-648 live wrapper addresses admitted 57.7-74.6% of 21.6-21.8 M classifications per command, 0.021% of them genuine. WORDS becomes a per-owner parameter; RegistryAddrIndex keeps an exact live-address set, mutated only on wrapper creation and retirement, and recomputes the bit array from it when enough has changed, which releases retired addresses. The hot side is unchanged. The canonical owner moves to 256 words and retires at all three sites that end a registration, each after the authoritative table.
This was referenced Sep 12, 2026
proggeramlug
pushed a commit
to PerryTS/perry
that referenced
this pull request
Sep 14, 2026
Refs #10110. Adapt the reusable index and population/churn witnesses from proggeramlug#1 for main. Scale all three hash slices with the per-owner width and cover concurrent refreshes and address reuse. The canonical-wrapper owner is still on the campaign branch; document its required integration without closing the issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three of the cheapest address predicates in
value::addr_classembedis_canonical_handle_addr, so on this stack every ordinary heap pointer whose numeric arm cannot decide pays an exact malloc-registry lookup. Measured on one offlineclaude-codecommand: 65,133,719 classifications, 43,150,678 reaching the registry (66.25 %), 9,225 finding a real wrapper (0.021 %) — 43,141,453 queries per command with nothing in them, which is thegc_malloc_header_is_trackedsymbol the profiles rank at 4.35 % of command cycles.This sizes the guard to its measured population and makes it release what it retires. Minimum command CPU 1.18 → 1.09 s (−7.63 %), node gap 2.81× → 2.60×.
Base
This PR targets the campaign base, not
main. Its subject does not exist onmain:is_above_handle_bandthere is still a bareaddr >= HANDLE_BAND_MAXandnative_handle/canonical.rsis absent. The canonical-handle wrapper subsystem (9fcd96d1c) is one of 15 commits on this base, which diverged frommain290 commits ago. The fix should travel with that subsystem; see the linked issue.The defect
The guard is a 1,024-bit monotone Bloom filter and the population does not fit: 643–648 live wrapper addresses, 712–721 admissions and 69–76 retirements per command. Selectivity collapses inside a single process — 0.021–0.154 % of addresses pass after startup, 57.7–74.6 % after the command — a 430–3,500× loss with no configuration involved. Sizing dominates monotonicity: clearing retired bits would still leave ~640 live addresses in a filter that cannot hold 60. The type's own sizing note anticipated the cliff and prescribed "raise
WORDS", butWORDSwas one shared constant, and the same note records that bits accrue per admission, so a larger fixed filter alone only postpones saturation.The change
WORDSbecomes a per-owner const-generic parameter, so one owner can be sized without moving the other three.RegistryAddrIndexkeeps an exact set of the addresses the owner currently holds — mutated only on wrapper creation and retirement, 712–721 and 69–76 times per command against tens of millions of probes — and recomputes the bit array from it once enough has changed. Refresh is O(live) per O(live) changes: amortized O(1), with no interval, schedule or workload-specific setting.retireafterfinalize_once, so no window exists in which the runtime recognises an address the index denies.Why overwriting the bits is sound
RegistryAddrFilterdeliberately has noclear, because clearing could make a live registered address read as unregistered. The refresh is not a clear, and the argument is written out on the type:admitand every refresh for one index is serialized by the same guard, so no admission's bit-set can be lost to a refresh's store — which is whyadmittakes the guard before setting the bits.false— the point — and a staletruecosts only the authoritative lookup that was always there. The authoritative path is unchanged, so a missed retirement can cost performance but never correctness.Measurement
Five interleaved pairs plus three node rows on the quiet Linux box, campaign lock held, load1 1.27–1.62. Control is the retained base binary reused by exact digest; compiler, object cache and bundle unchanged.
Minima −7.63 %, medians 1.24 → 1.16 s, paired median −5.08 %; startup minima unchanged at 0.95 s; startup-plus-command minima −4.65 % with every pair improving; command wall minima −5.93 %, every pair improving. Largest per-pair peak-RSS increase +3.78 %, which is larger than the change's own footprint (2 KiB of bits plus a 643–648-entry set), so its cause is not the structure and was not measured — pair 3's control likewise sits 14–17 MiB above the other four controls. Node anchor in the same session: command 0.44 / 0.43 / 0.42 s. Parity is still unmet; this removes one named cost.
Mechanism
A counter arm of the same change, same workload:
Resolutions are 3,075 in every row of both arms: the index changes which addresses reach the authoritative lookup, not what it answers.
Tests
test result: ok. 33 passed; 0 failedforregistry_latch;native_handle(15) andaddr_class(8) unchanged. Three tests are new and each fails without the change:Disabling the refresh fails two of them; reverting the width fails the third. This is a focused set, not the repository's full gap gate, and no broad CI verdict is claimed.
Not in scope
The 232 call sites of the three range predicates are untouched; separating the numeric range test from semantic receiver classification is the larger, independent change an earlier caller census recommended.