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

refactor: Replace custom ThinVec with thin-vec crate #19440

Merged
merged 1 commit into from
Mar 24, 2025

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Mar 24, 2025

This replaces a bunch of unsafe code that isn't well tested in favor of a library that has been well tested doing mostly the same.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 24, 2025
@Veykril Veykril enabled auto-merge March 24, 2025 12:44
@Veykril Veykril added this pull request to the merge queue Mar 24, 2025
Merged via the queue into rust-lang:master with commit 3ed13b4 Mar 24, 2025
9 checks passed
@Veykril Veykril deleted the push-lotzuulstwpw branch March 24, 2025 13:16
@ChayimFriedman2
Copy link
Contributor

It means more boxing, are you should it doesn't regress performance/memory?

@Veykril
Copy link
Member Author

Veykril commented Mar 25, 2025

Yes I am aware this will slightly regress perf (probably), but I believe this to be neglible in the grandscheme. These are the rarer cases anyways. I prefer the readability of less macros and also favor the solution here that is less complicated and uses less unsafe. Feel free to argue against it though, should've probably not self-merged this one, sorry :^)

@ChayimFriedman2
Copy link
Contributor

I honestly don't know. Paths are extremely common, and even though most of them are BarePath, a non-negligible part has generics (I don't remember the ratios, but I once checked that). Boxing them may turn too much. I guess we will need a benchmark to be sure, I'll try to check it later.

@ChayimFriedman2
Copy link
Contributor

So I benchmarked this and this does not regress memory/time (lowering probably takes a fraction of time/memory, the most significant is inference), so this generally gets an approval from me. However I do think we need to bring EmptyOptimizedThinVec back, as it's used in diagnostics (and will be used more with the diagnostic queries I'm writing), so might as well use it for tuple types.

@ChayimFriedman2
Copy link
Contributor

My bad, I now see that ThinVec::new() will not allocate, so we can keep it as is.

@Veykril
Copy link
Member Author

Veykril commented Mar 27, 2025

Cool, thanks for double checking this

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.

3 participants