Replace method_references HashMap with SortedVecMap#660
Draft
st0012 wants to merge 1 commit intooptimize-nonzero-idfrom
Draft
Replace method_references HashMap with SortedVecMap#660st0012 wants to merge 1 commit intooptimize-nonzero-idfrom
st0012 wants to merge 1 commit intooptimize-nonzero-idfrom
Conversation
b335509 to
47f6751
Compare
f936bb1 to
12f4741
Compare
a25874c to
dca9e03
Compare
Method references (8.96M entries) are bulk-loaded during indexing, never accessed during resolution, and only queried/removed during incremental updates and FFI queries. This access pattern is ideal for a sorted Vec: - HashMap: ~16M slots × 41 bytes = ~656 MB (load factor + control bytes) - SortedVec: 8.96M × 40 bytes = ~342 MB (no overhead) Introduces SortedVecMap<K, V> backed by a sorted Vec<(K, V)> with O(log n) binary search lookups. Uses UnsafeCell for lazy sorting so get() can take &self. Entries are bulk-pushed unsorted during indexing, then sorted lazily on first lookup. ## Benchmark (cumulative with NonZeroU64 change) | Metric | Before | After | Delta | |--------|--------|-------|-------| | Memory (peak footprint) | 4480 MB | 3542 MB | -20.9% | | Declarations | 895,844 | 895,844 | identical | | Definitions | 1,063,171 | 1,063,171 | identical |
dca9e03 to
1c52826
Compare
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
IdentityHashMap<ReferenceId, MethodRef>with a newSortedVecMap<K, V>backed by a sortedVec<(K, V)>with O(log n) binary search lookupsUnsafeCellfor lazy sorting soget()can take&selfDepends on #659.
Benchmark (cumulative with NonZeroU64 change)