-
Notifications
You must be signed in to change notification settings - Fork 2.6k
refactor: replace InternedString with Cow in IndexPackage #15559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
5fdaca9
to
de4a534
Compare
I would recommend at least doing some benchmarking using our bench suite. https://github.com/rust-lang/cargo/tree/master/benches contains some documentation, and particularly the |
WIP: I need to do more testsI’ve tested this change several times using the resolve_ws/rust benchmark suite. My test env: Model Name: MacBook Pro
Chip: Apple M4 Max
Total Number of Cores: 14 (10 performance and 4 efficiency)
Memory: 36 GB Test result: First round:
Second round:
Third round:
Fourth round:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could change InternString::from_cow
to something like:
impl<'a> From<Cow<'a, str>> for InternedString {
fn from(cs: Cow<'a, str>) -> Self {
let mut cache = interned_storage();
let s = cache.get(cs.as_ref()).copied().unwrap_or_else(|| {
let s = cs.into_owned().leak();
cache.insert(s);
s
});
InternedString { inner: s }
}
}
So in other places we can rely on Into<InternedString>
.
Signed-off-by: 0xPoe <[email protected]>
What does this PR try to resolve?
ref #14834
As described in the issue, we want to move IndexPackage into cargo-util-schemas. However, it contains InternedString fields, which we don't want to expose as part of the public API.
This PR replaces InternedString with Cow.
How should we test and review this PR?
It shouldn't change or break any tests.
Additional information
None