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

buildRustCrate: remove superfluous dependency overrides #79816

Merged
merged 1 commit into from
Feb 18, 2020

Conversation

andir
Copy link
Member

@andir andir commented Feb 11, 2020

Motivation for this change

By overriding each dependency on every level of the dependency tree we
are creating a lot of unnecessary instances of the same derivation

Looking at the output size of nix-instantiate --trace-function-calls -vvvv … and the execution time I got about a 10x improvement after
applying this change.

It was probably good intentions that lead to these overrides but in
practice no tooling (that I know of) really needs this. carnix and
crate2nix are fine without those overrides. Furthermore I believe that
it is the job of the tooling around buildRustCrate to provide a
coherent set of overrides. By not enforcing all of the overrides, debug
flags, verbosity, … to be the same throughout the closure we also allow
consumers to override specific aspects of the crates. Some (older?)
crates might need different crateOverrides then newer crates with the
same name. Currently such situations can not (easily) be implemented
with the override in-place.

cc nix-community/crate2nix#90 @nagisa @kolloch

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

By overriding each dependency on every level of the dependency tree we
are creating a lot of unnecessary instances of the same derivation

Looking at the output size of `nix-instantiate --trace-function-calls
-vvvv …` and the execution time I got about a 10x improvement after
applying this change.

It was probably good intentions that lead to these overrides but in
practice no tooling (that I know of) really needs this. `carnix` and
`crate2nix` are fine without those overrides. Furthermore I believe that
it is the job of the tooling around `buildRustCrate` to provide a
coherent set of overrides. By not enforcing all of the overrides, debug
flags, verbosity, … to be the same throughout the closure we also allow
consumers to override specific aspects of the crates. Some (older?)
crates might need different `crateOverrides` then newer crates with the
same name. Currently such situations can not (easily) be implemented
with the override in-place.
nagisa added a commit to standard-ai/nixpkgs-tensorflow-rust that referenced this pull request Feb 11, 2020
@nagisa
Copy link
Contributor

nagisa commented Feb 11, 2020

This indeed appears to be much faster for a large workspace:

this: 104% (12.29 real, 0.52 kernel, 12.26 user); 943872k resident
before: 108% (120.91 real, 4.05 kernel, 127.24 user); 5063676k resident

We do still instantiate the most depended-on crates dozens of times, but it is definitely more livable now.

r+

@andir
Copy link
Member Author

andir commented Feb 12, 2020

@GrahamcOfBorg eval
@GrahamcOfBorg build buildRustCrateTests

@kolloch
Copy link
Contributor

kolloch commented Feb 18, 2020

Is anything holding this up? It would be great to get this in. @andir @Mic92

@andir andir merged commit 4535896 into NixOS:master Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants