-
Notifications
You must be signed in to change notification settings - Fork 102
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
Make the const-random
dependency optional
#18
Conversation
What I don't like about this is that it makes all the constants the same. If you're willing to wait for it I am working on a chance in constrandom to allow it to derive a number from the file name and row/column of call. That way it will still be random but consistent from one machine to the next. |
I completely agree that it'd be nice if the constants weren't the same. However, the main point of this is mostly to get rid of the extra dependencies. Will your changes in Basically, if someone either:
then the extra dependencies are just dead weight, and I think it'd be nice to have a way to disable them. (And of course there is also rust-lang/cargo#5730.) All of those transient dependencies can add up; as an example, one of my personal apps has 57 total dependencies when compiled in development mode and.... 436 dependencies when compiled in production mode. It works almost exactly the same, just without some production-only features and without a few nice-to-have-but-in-this-case-unnecessary features (like |
While I certainly won't add any dependencies. It's already a dev dependency so it shouldn't bring anything at runtime. I suspect your concern is around the fact that it is downloading another thing, and it is in turn using random, which also needs to be downloaded, and has its own dependencies. I can remove the dependency on Random via a the flag that triggers deterministic behaviour. So at that point cargo should only have to download one other thing (const-random). I don't however see a way to avoid const-random being separate because it is a procedural macro which currently requires it to be in it's own crate. And I don't know any way to make a macro-rules style macro emit different values at different invocation sites. |
Thinking about it more, it might be possible to do as a macro-rules macro. I'll look into this. |
Well, to put it simply my main concern is that when I depend on
That is a lot of extra dependencies just for a feature that - while I agree is the default (and should be the default) for a very good reason - is completely unnecessary in my case. Yes, I know that at runtime it doesn't matter, however what I care about here is what happens at build time, as every extra transitive dependency that I have increases my compile times. |
Alternatively if you don't want to introduce a possibility of using non-random keys then perhaps we could instead have a feature which would control whenever |
Interesting, I can definitely replace rand with getrandom even in the case where we do want const-random values. That should help. Right now there are two places const-random is used:
So the easiest thing to do is via flag replace the seed with a constant, and just not implement |
Okay, so I've made the One extra thing I've noticed - the fallback hasher exports only this constructor: pub fn new_with_key(key: u64) -> AHasher while the AES hasher exports only this constructor: pub fn new_with_keys(key0: u64, key1: u64) -> Self This means that depending on whenever |
This makes the `const-random` dependency optional.
Yeah, I saw that too. I pushed a fix. |
Not everyone needs this, and the
const-random
adds a few extra relatively heavy dependencies which does cost build time, so I'd be nice to be able to disable it.This also has the side effect of enabling reproducible builds, though, obviously, at a cost.