-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Intern more kinds of things #6207
Comments
Note that |
There is interning infrastructure used in the html5ever crate. Might be useful here - you can pre-intern anything you want at compile-time EDIT the crates are |
For |
I think we find a cargo-local solution. I was thinking of making an |
Agreed this should probably be Cargo-specific for now, we can always upstream later if it's useful! |
I think the box-leaking, interning solution only gives us access to a
Either way, I'll try and finish up this ticket on Sunday. |
@alexcrichton if you get a chance could you write down those hashing shenanigans you were explaining to me are happening with package id and source id? The part I'm most interested in is the ideal setup we'd like to be in, in terms of interned values and their hashes. |
Sure thing! I think you ended up finding it on the |
Follow-up task: remove all the no longer necessary |
#6468 implements the last bit about semver, but there were some uncertainty on whether it's a desired change which halted the PR. So I'm going to consider this done for the time being. |
Cargo sometimes makes a lot of copies of data structures. For example the string "serde", was copied for the name of each dependency on that crate, as the name of each version of that package, and for each feature that enables that package. This got fixed by adding a
InternedString
data type that deduplicates the data and leaks it into a&'static
reference. We have other data structures which useArc/Rc
to make cloning cheaper.We should experiment with Interning them to see if it is a Speed or Memory or Ergonomic win.
Off the top of my head:
PackageId
is already usingArc
, is copied and hashed and compared all over the place in hot code.SourceId
is already usingArc
, has a manual cache forcrates.io
and will probably be leaked anyway by cachingPackageId
.semver::Version/semver::VersionReq
are used a lot, probably often with the same value, and are bigger structures then they seem.The text was updated successfully, but these errors were encountered: