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

coreutils: use openssl for faster *sum tools #44937

Closed
wants to merge 5 commits into from

Conversation

viric
Copy link
Member

@viric viric commented Aug 12, 2018

sha256sum, md5sum,. run much faster. Factor 2x to 4x.

You can evaluate that by comparing the cpu time of your 'time sha256sum bigfile' and 'time openssl sha256 bigfile'.

I tried this PR in #43983 not noticing that it altered stdenv.

I modified stdenv allowedRequisites so it is allowed in linux & darwin stdenv; @edolstra said that openssl for coreutils does not rise the stdenv size too much.

The other solution is to add a new coreutils-with-openssl that is referenced in NixOS but not in stdenv, so the user always calls the fast *sum versions.

Suggested by matthewbauer review.
In Darwin there is a complain:

output '/nix/store/2806zdbv3zdxpy8aslijdml84vrpqf39-stdenv-darwin' is not allowed to refer to the following paths:
/nix/store/4q1c84f1ynfvsd85a932375sg0jc89v8-bootstrap-tools
/nix/store/6r6xsb18p7cp32b2yhf5v46n0d50ng2s-openssl-1.0.2o
I updated stdenv derivations of linux and darwin to allow it.
It worked for me in parallel, but I didn't mean to change it in this
branch.

Worth trying to enable it if upstream fixed anything.
@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: coreutils

Partial log (click to expand)

shrinking /nix/store/6gbqqzl2qjvfms568v1s0sdsvg2qghqy-coreutils-8.29/bin/coreutils
shrinking /nix/store/6gbqqzl2qjvfms568v1s0sdsvg2qghqy-coreutils-8.29/libexec/coreutils/libstdbuf.so
gzipping man pages under /nix/store/6gbqqzl2qjvfms568v1s0sdsvg2qghqy-coreutils-8.29/share/man/
strip is /nix/store/d1prcspbh2qsviipvnaxizcj8l3g7fpw-bootstrap-tools/bin/strip
stripping (with command strip and flags -S) in /nix/store/6gbqqzl2qjvfms568v1s0sdsvg2qghqy-coreutils-8.29/libexec  /nix/store/6gbqqzl2qjvfms568v1s0sdsvg2qghqy-coreutils-8.29/bin
checking for references to /build in /nix/store/6gbqqzl2qjvfms568v1s0sdsvg2qghqy-coreutils-8.29...
shrinking RPATHs of ELF executables and libraries in /nix/store/3lcd9n8h7ivvqp8pk6ybm0m18lqx1yy1-coreutils-8.29-info
strip is /nix/store/d1prcspbh2qsviipvnaxizcj8l3g7fpw-bootstrap-tools/bin/strip
checking for references to /build in /nix/store/3lcd9n8h7ivvqp8pk6ybm0m18lqx1yy1-coreutils-8.29-info...
/nix/store/6gbqqzl2qjvfms568v1s0sdsvg2qghqy-coreutils-8.29

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: coreutils

Partial log (click to expand)

shrinking /nix/store/f308qnvz5zz3qck0miz9hl1p6g0mj73y-coreutils-8.29/libexec/coreutils/libstdbuf.so
shrinking /nix/store/f308qnvz5zz3qck0miz9hl1p6g0mj73y-coreutils-8.29/bin/coreutils
gzipping man pages under /nix/store/f308qnvz5zz3qck0miz9hl1p6g0mj73y-coreutils-8.29/share/man/
strip is /nix/store/gfgczbs0cy0blibb0acv39cayq7qbplg-bootstrap-tools/bin/strip
stripping (with command strip and flags -S) in /nix/store/f308qnvz5zz3qck0miz9hl1p6g0mj73y-coreutils-8.29/libexec  /nix/store/f308qnvz5zz3qck0miz9hl1p6g0mj73y-coreutils-8.29/bin
checking for references to /build in /nix/store/f308qnvz5zz3qck0miz9hl1p6g0mj73y-coreutils-8.29...
shrinking RPATHs of ELF executables and libraries in /nix/store/byv3hyxyq0d1qqhq4frsrq3mdyz1qjix-coreutils-8.29-info
strip is /nix/store/gfgczbs0cy0blibb0acv39cayq7qbplg-bootstrap-tools/bin/strip
checking for references to /build in /nix/store/byv3hyxyq0d1qqhq4frsrq3mdyz1qjix-coreutils-8.29-info...
/nix/store/f308qnvz5zz3qck0miz9hl1p6g0mj73y-coreutils-8.29

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: coreutils

Partial log (click to expand)

shrinking /nix/store/7y8z3wk5pp13ww1amp4vi1n3l8spk1br-coreutils-8.29/libexec/coreutils/libstdbuf.so
shrinking /nix/store/7y8z3wk5pp13ww1amp4vi1n3l8spk1br-coreutils-8.29/bin/coreutils
gzipping man pages under /nix/store/7y8z3wk5pp13ww1amp4vi1n3l8spk1br-coreutils-8.29/share/man/
strip is /nix/store/d1prcspbh2qsviipvnaxizcj8l3g7fpw-bootstrap-tools/bin/strip
stripping (with command strip and flags -S) in /nix/store/7y8z3wk5pp13ww1amp4vi1n3l8spk1br-coreutils-8.29/libexec  /nix/store/7y8z3wk5pp13ww1amp4vi1n3l8spk1br-coreutils-8.29/bin
checking for references to /build in /nix/store/7y8z3wk5pp13ww1amp4vi1n3l8spk1br-coreutils-8.29...
shrinking RPATHs of ELF executables and libraries in /nix/store/c2z3r13als8vwmsri5qllnragbiayg3m-coreutils-8.29-info
strip is /nix/store/d1prcspbh2qsviipvnaxizcj8l3g7fpw-bootstrap-tools/bin/strip
checking for references to /build in /nix/store/c2z3r13als8vwmsri5qllnragbiayg3m-coreutils-8.29-info...
/nix/store/7y8z3wk5pp13ww1amp4vi1n3l8spk1br-coreutils-8.29

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: coreutils

Partial log (click to expand)

shrinking /nix/store/4cpmcsbq8k3j7b9mn4j9jnp1ayfavm3d-coreutils-8.29/libexec/coreutils/libstdbuf.so
shrinking /nix/store/4cpmcsbq8k3j7b9mn4j9jnp1ayfavm3d-coreutils-8.29/bin/coreutils
gzipping man pages under /nix/store/4cpmcsbq8k3j7b9mn4j9jnp1ayfavm3d-coreutils-8.29/share/man/
strip is /nix/store/gfgczbs0cy0blibb0acv39cayq7qbplg-bootstrap-tools/bin/strip
stripping (with command strip and flags -S) in /nix/store/4cpmcsbq8k3j7b9mn4j9jnp1ayfavm3d-coreutils-8.29/libexec  /nix/store/4cpmcsbq8k3j7b9mn4j9jnp1ayfavm3d-coreutils-8.29/bin
checking for references to /build in /nix/store/4cpmcsbq8k3j7b9mn4j9jnp1ayfavm3d-coreutils-8.29...
shrinking RPATHs of ELF executables and libraries in /nix/store/14cxds2cn138zd911zd0j8drnby6n4s6-coreutils-8.29-info
strip is /nix/store/gfgczbs0cy0blibb0acv39cayq7qbplg-bootstrap-tools/bin/strip
checking for references to /build in /nix/store/14cxds2cn138zd911zd0j8drnby6n4s6-coreutils-8.29-info...
/nix/store/4cpmcsbq8k3j7b9mn4j9jnp1ayfavm3d-coreutils-8.29

@Mic92
Copy link
Member

Mic92 commented Aug 16, 2018

I assume someone then needs to build a new bootstrap tarball?

@Mic92 Mic92 requested a review from vcunat August 16, 2018 08:23
@edolstra
Copy link
Member

New bootstrap tarballs are built by Hydra, see https://hydra.nixos.org/job/nixos/trunk-combined/nixpkgs.stdenvBootstrapTools.x86_64-linux.dist and https://hydra.nixos.org/job/nixos/trunk-combined/nixpkgs.stdenvBootstrapTools.x86_64-linux.test. You could give those a try (e.g. see if you can rebuild stdenv using them). If they work we can upload them to tarballs.nixos.org.

@viric
Copy link
Member Author

viric commented Aug 18, 2018

Why is a new bootstrap tarball required? I don't think it is required.

@viric
Copy link
Member Author

viric commented Aug 19, 2018

Another option may be to use a static openssl to build coreutils - I guess that will keep the stdenv closure size smaller.

@vcunat
Copy link
Member

vcunat commented Aug 28, 2018

I'm sorry to say this, but I don't think it's strategic to make openssl a stdenv-rebuilding package. It's relatively common that it contains a security bug that we want to fix very fast across all channels, and having to rebuild completely everything might be a significant hindrance.

Therefore I'd give a thought to options where the default coreutils in stdenv does not have this support, though there are complications with this as well – packages will tend to keep reference to that one (unless we put the coreutils-with-openssl into their build inputs), so it will be hard to avoid having both versions in system closure.

Impact of that slight bloat could be significantly reduced by making coreutils-with-openssl mostly from symlinks to the version from stdenv (most of size is locale, for example), though that makes the expression a little more complex. EDIT: actually, the best approach might be to simply delete locale and man pages from the stdenv's coreutils :-)

@viric
Copy link
Member Author

viric commented Aug 28, 2018 via email

@vcunat
Copy link
Member

vcunat commented Aug 28, 2018

Change in linking doesn't prevent rebuilds (by itself) – it would work if we split away openssl-for-coreutils and didn't update that version too often.

@viric
Copy link
Member Author

viric commented Aug 28, 2018 via email

@vcunat
Copy link
Member

vcunat commented Aug 28, 2018

OK, that also sounds a nice way.

I didn't mean to suggest to give up on the speed increase. The checksumming tools seem rather unlikely to be used much during build, so that's why I first considered that approach. For multiple tools it seems that the optimal configuration for builds and "other" usage differs ("other" = typically system envs, interactive usage, etc.)

@vcunat
Copy link
Member

vcunat commented Aug 28, 2018

BTW, I believe we don't need to immediately propagate this change to the currently used bootstrap tools. (Though we should make sure they still build and test OK, and the Hydra job checks that.)

@viric
Copy link
Member Author

viric commented Aug 28, 2018 via email

@vcunat
Copy link
Member

vcunat commented Aug 28, 2018

I thought we might keep the one in stdenv without openssl but explicit coreutils reference with openssl. I expect that would mitigate almost all the extra rebuilds on openssl updates. (And perhaps create alias stdenv.coreutils for explicit references wanting to avoid that.)

@viric
Copy link
Member Author

viric commented Aug 28, 2018 via email

@vcunat
Copy link
Member

vcunat commented Aug 28, 2018

I have computing power for testing. It's worse with time, but I might be able to catch it if there are no complications with it. I'll certainly write here when/before I put a noticeable amount of time into it; feel free (anyone) to do that first, as there are many other nix* things I want to do, especially with release not far off.

@vcunat
Copy link
Member

vcunat commented Aug 28, 2018

Well, the planned part was easy (a few minutes)... but it turned out that keeping stdenv without openssl isn't enough to keep the rebuild amount due to openssl sane – probably due to some spurious coreutils references. I'll try to track down the worst ones quickly.

@LnL7
Copy link
Member

LnL7 commented Aug 28, 2018

Security updates and to reduce the difference of packages in the darwin stdenv vs linux is exactly why I spent a bunch of time on getting rid of openssl and libarchive in the darwin stdenv. While adding it to the stdenv build is not a major problem, I prefer the coreutils-with-openssl idea.

@vcunat vcunat self-assigned this Aug 28, 2018
@vcunat
Copy link
Member

vcunat commented Aug 28, 2018

I wanted stdenv with minimal coreutils and default coreutils attribute with features like openssl, but I'm giving that up. There are too many trivial references like ${coreutils}/bin/true to have the heavier default, killing my target not to blow rebuilds due to openssl updates. I'll go with a separate attribute name, at least for now. I'll file a PR against staging when it's in some shape (very soon, I hope).

@vcunat
Copy link
Member

vcunat commented Aug 28, 2018

I propose this: #45720

@vcunat vcunat closed this Sep 1, 2018
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

6 participants