Repository navigation
Reduce spare capacity in metadata lookup vectors - #5465
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the capacity-one allocation changes in metadata and bindgen name lookups.
No open issues 🎉
What changed in this PR
This PR reduces spare vector capacity in metadata and bindgen name lookups by starting each new per-name vector at capacity one. Duplicate names can still grow normally.
Changes:
- Use capacity-one vectors for metadata type, function, and constant lookups.
- Apply the same allocation strategy to bindgen's type lookup helper.
| File | Description |
|---|---|
crates/libs/metadata/src/reader/index.rs |
Initialize per-name lookup vectors with capacity one. |
crates/libs/bindgen/src/winmd/reader.rs |
Initialize type lookup vectors with capacity one. |
Review effort: Balanced
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.
Most names have only one definition, so start their vectors at capacity one instead of growing from empty. Duplicate names still grow normally.
With the bundled Win32 and WinRT metadata on x64, this saves about 72 MiB of vector backing storage across metadata and bindgen and improves generation time. Generated output is unchanged.