Skip to content
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

Optimise Msrv for common one item case #13472

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GnomedDev
Copy link
Contributor

Currently, Msrv is cloned around a lot in order to handle the #[clippy::msrv] attribute. This attribute, however, means RustcVersion will be heap allocated if there is only one source of an msrv (eg: rust-version in Cargo.toml).

This PR optimizes for said case, while keeping the external interface the same by:

  • Storing RustVersion inline for the common one element case.
  • Swapping to ThinVec to shrink Msrv to 16 bytes, from 24, to optimize for the zero and one element cases.

changelog: none

@rustbot
Copy link
Collaborator

rustbot commented Sep 28, 2024

r? @Centri3

rustbot has assigned @Centri3.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 28, 2024
@flip1995
Copy link
Member

r? @Jarcho as they looked into this most recently.

@rustbot rustbot assigned Jarcho and unassigned Centri3 Sep 30, 2024
@Jarcho
Copy link
Contributor

Jarcho commented Oct 1, 2024

I don't see any reason to use ThinVec here over SmallVec which would be the same size and be simpler.

@GnomedDev
Copy link
Contributor Author

SmallVec would be 24 bytes inline, as it stores the capacity and length inline in the heap allocated variant. I also didn't think it was already in the dependency tree, which this solution keeps the same. If you want to undo the ThinVec win, I can swap to SmallVec, but there is a benefit to this method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants