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
rustPlatform: increase build-speed of checkPhase
for rust-packages
#82342
Conversation
Since you note that this needs testing, I tried it on the recently-added After building
EDIT: If there's anything else I can help with, let me know -- excited to see this land to reduce unnecessary compilation. |
@cole-h thanks for taking a look at this!
Well, this might be pretty time-consuming, but in case someone finds a crate (preferably something used in a NixOS-package) that breaks with this patch it would be fairly helpful (I didn't find any, but I don't consider myself an expert in the rust ecosystem though :) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I tried (unsuccessfully) to do this a while ago. Looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I built a few packages that I use (hyperfine
, alacritty
, and ripgrep
) with this patch applied and it was all sunshine and rainbows. No more compiling 250+ dependencies twice for a test run!
Looks like a great change in general. Build performance optimizations aside, this is also arguably superior on its own right: we're shipping optimizied binaries built against optimized libraries, but previously we were running the test suite against debug libs. This gets us closer to testing what we're deploying. The fact that it basically halves our compilations is nice too :) That said, after trying several successfully, I think I found a package that has issues. (It builds on master, and still fails when this PR is rebased onto master.) @GrahamcOfBorg build zcash |
67e82fb
to
b790f3a
Compare
Fix the build issue and also changed the base to |
While I was messing with #82982, I noticed that, when combined with this PR, I have no idea how this should be worked around, but it's something that should be dealt with before this merges. This worked in the past (I assume) because there was only 1 possible match in the (I guess I didn't properly test this with
EDIT4: The real solution (IMHO) is to use the EDIT3: Probably the most annoying side-effect of this change is |
Not sure yet. In case I have sufficient time, I will start investigating tomorrow :) |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/speeding-up-rust-app-packaging/6384/6 |
I wonder if this is actually a good idea, debug doesn’t just compile with fewer optimizations, it also turns on integer overflow checks and debug assertions (which are used throughout the standard library and crates to do more expensive checks). Doing tests with release builds may miss some bugs which are captured by regular testing using debug builds. |
<opinion> In general I see nix tests as a quick check to ensure that you didn't compile things terribly wrong. In this case I think that integer overflow checks should be caught by the application developers. Debug assertions are more difficult to categorize as catching build/configuration issues but I think that in general it is worth the time savings to turn them off. The job of nix isn't to check that the code is perfect, but mostly to ensure that we built it correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I see nix tests as a quick check to ensure that you didn't compile things terribly wrong. In this case I think that integer overflow checks should be caught by the application developers. Debug assertions are more difficult to categorize as catching build/configuration issues but I think that in general it is worth the time savings to turn them off. The job of nix isn't to check that the code is perfect, but mostly to ensure that we built it correctly.
Agreed. See also my comment in discourse: https://discourse.nixos.org/t/speeding-up-rust-app-packaging/6384/8?u=ma27
ab0743d
to
352e4d1
Compare
c303244
to
7e8d602
Compare
Docs have been fixed, thanks @cole-h and @asymmetric ! I'd love to see a final review, after that I'd consider this mergable (will leave a comment, then). /cc @FRidh @vcunat |
Sadly I don't have time for a full review/test, but I'll at least comment to say I'm morally in favor of this change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits, and the rest LGTM. Thanks for your work on this! Can't wait to compile packages like Alacritty only once when testing ;-)
7e8d602
to
84e1ff8
Compare
@cole-h fixed :) |
Co-authored-by: cole-h <cole.e.helbling@outlook.com> Co-authored-by: asymmetric <lorenzo@mailbox.org>
84e1ff8
to
59e8e7a
Compare
Motivation for this change
As noted later on, I consider this rather usable after several iterations of reviews and tests, however we need more extensive testing before merging this to upstream.
When running
cargo test --release
, the artifacts frombuildPhase
will be reused here. Previously, most of the stuff had to be recompiled
without optimizations.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)