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

Shall rand be a dev-dependency in parking_lot_core, like in parking_lot? #138

Closed
vi opened this issue May 7, 2019 · 11 comments
Closed

Shall rand be a dev-dependency in parking_lot_core, like in parking_lot? #138

vi opened this issue May 7, 2019 · 11 comments

Comments

@vi
Copy link

vi commented May 7, 2019

Just connecting parking_lot brings entire chunk of rand_* entries into cargo tree.

@vi vi changed the title Shall rand be a dev-dependeny in parking_lot_core, like in parking_lot? Shall rand be a dev-dependency in parking_lot_core, like in parking_lot? May 7, 2019
@Amanieu
Copy link
Owner

Amanieu commented May 7, 2019

This is by design, some randomness is used as part of the fairness mechanism in parking_lot_core.

@matklad
Copy link
Contributor

matklad commented May 30, 2019

Note that the future version of rand plans to prune dependencies a bit: rust-random/rand#715

@faern
Copy link
Collaborator

faern commented May 30, 2019

Could we not swap the rand dependency for rand_pcg? parking_lot currently only uses SmallRng which in the background is just rand_pcg::Pcg64Mcg or rand_pcg::Pcg32 depending on architecture.

@matklad
Copy link
Contributor

matklad commented May 30, 2019

Another option, if we don't need super-high-quality randomness, is to just vendor xor-shift RNG, like the [T]::sort does:

https://github.com/rust-lang/rust/blob/c28084ac16af4ab594b6860958df140e7c876a13/src/libcore/slice/sort.rs#L486-L493

@faern
Copy link
Collaborator

faern commented May 30, 2019

If we include a simple PRNG in parking_lot itself we get the benefit of being able to use it when parking_lot acts as the locking implementation inside libstd (#119) and we get less conditional compilation and a bit more randomness to the fairness in libstd.

@Amanieu
Copy link
Owner

Amanieu commented May 30, 2019

Vendoring a simple PRNG sounds like a good idea that will solve multiple problems.

@faern
Copy link
Collaborator

faern commented May 30, 2019

I copied the linked PRNG from libstd and took a stab at implementing this. See #144. I have not evaluated the quality of that PRNG or anything. But this compiles and the tests pass.

@vi
Copy link
Author

vi commented May 30, 2019

Vendoring a simple PRNG

What about vendoring a simple PRNG into Rust's libcore? It doesn't look OK if everybody around starts vendoring a simple PRNG.

@Amanieu
Copy link
Owner

Amanieu commented May 30, 2019

No, crates that need a PRNG should just use the rand crate. We only need to vendor one here because parking_lot is intended to be used as part of libstd, which cannoy depend on other crates.

@matklad
Copy link
Contributor

matklad commented Jul 2, 2019

It might be worthwhile to do a release of parking_lot without rand: rand recieved a major version bump recently, so published parking_lot now depends on outdated version.

@Amanieu
Copy link
Owner

Amanieu commented Jul 3, 2019

I just published 0.8.1 without rand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants