-
Notifications
You must be signed in to change notification settings - Fork 475
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
Split up crates so end users can get faster compile times #616
Comments
Your use case sounds rather atypical
Timing a build of both
2.4 seconds on my computer. I wouldn't consider that "a long time". |
On my computer it takes 8.8 seconds. And I find GitHub Actions tends to be about 4x slower than my machine.
The use case is the Solana Pubkey type, which needs to check if bytes are a curve point but otherwise doesn't need curve25519-dalek |
If that's all you need, you shouldn't be using I'm not sure how your proposed solution would help either. You seem more in need of feature gating than more crates. More crates help improve parallelism and can reduce the algorithmic complexity of compiling any one crate, and we do use them in spades as part of the @RustCrypto project, to the point people complain about the sheer number of dependencies. But at the end of the day, you're still compiling the same amount of code. To really micro-optimize for your use case, you'd probably need feature gating to be able to pull in just the field implementation alone. But that's also something we deliberately avoid exposing the |
curve25519-dalek takes 7.5 seconds to compile on my machine:
Features can also achieve the end result but I personally find that crates are cleaner and have fewer footguns (e.g. it's easy to forget to check a certain crate feature)
This is about being able to compile less code, by having a more lightweight dependency than curve25519-dalek |
Again, the only way we could micro-optimize for your use case is by creating a crate that contains something we're deliberately trying to avoid exposing |
One way I've seen projects address this shortcoming in Rust visibility is to publish an "internals" crate and put a notice in the README that you shouldn't use the crate directly e.g. polars-core. Additionally, an internals crate could have a default feature that prints a warning if someone tries to use the crate without disabling the feature. |
@kevinheavey you haven't mentioned specifically what you're doing beyond needing What are you doing exactly? |
If the only goal is to validate Ed points and that's it, then I think you need a super fine grained slice of this crate. I think the most appropriate thing might be to just copy the u32 backend, copy the If we had feature gates that fine, we'd have a lot of feature gates |
@tarcieri the Solana Pubkey struct has a find_program_address method that iterates until it finds an address that is not on the ed25519 curve and hence cannot have an associated private key. The only part of curve25519-dalek it uses for this is:
and if you pare that down a bit further it turns out it only needs the step_1 function. Or even more specifically, just the first element of the tuple returned by that function |
I have noticed I have some crates that need only the
decompress::step_1
function in curve25519-dalek, but they have to pull in the whole dependency, which takes a long time to compile. Some rough experiments on my machine found that stripping away the stuff I don't need reduces compile times for the crate by ~90%.I believe I have a similar situation with the ed25519-dalek crate, so before getting stuck on the details of what code could be extracted into a new crate (and re-exported for backwards compatibility), I'd like to check if this is something the maintainers are open to.
(Something similar could be achieved with features but it would be harder and messier in my opinion)
The text was updated successfully, but these errors were encountered: