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

patchShebangs: performance/readability optimization #94642

Merged
merged 3 commits into from Feb 4, 2021

Conversation

Mic92
Copy link
Member

@Mic92 Mic92 commented Aug 4, 2020

Motivation for this change

need for speed

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 via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • 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.

@Mic92
Copy link
Member Author

Mic92 commented Aug 4, 2020

The following built for me:

nix-build -A tests.patch-shebangs

@zowoq
Copy link
Contributor

zowoq commented Aug 4, 2020

We might want to find a way of clearing unneeded jobs.

Screen Shot 2020-08-05 at 09 01 19

@Mic92
Copy link
Member Author

Mic92 commented Aug 5, 2020

We might want to find a way of clearing unneeded jobs.

Screen Shot 2020-08-05 at 09 01 19

Travis has a feature to cancel previous jobs. For github there was a github action that emulates this behavior.

@andir
Copy link
Member

andir commented Oct 19, 2020

This looks fine to me. Perhaps we should reorganize the commits once more but otherwise this looks like it deserves a shot in the staging branch.

@SuperSandro2000
Copy link
Member

SuperSandro2000 commented Oct 19, 2020

I can confirm that it builds on other Linux distributions.

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash the commits.

builtins for small input sizes should be faster due to less forking.
according to shellcheck [[ foo == "bla" ]] && [[ ... ]] has better posix
semantics over [ foo = "bla" -a ... ]. It is also easier to read.
@Mic92
Copy link
Member Author

Mic92 commented Jan 14, 2021

done.

@Mic92
Copy link
Member Author

Mic92 commented Feb 4, 2021

/marvin opt-in
/status needs_reviewer

@marvin-mk2 marvin-mk2 bot added the marvin label Feb 4, 2021
@marvin-mk2
Copy link

marvin-mk2 bot commented Feb 4, 2021

Hi! I'm an experimental bot. My goal is to guide this PR through its stages, hopefully ending with a merge. You can read up on the usage here.

@Mic92 Mic92 merged commit 2dcc858 into NixOS:staging Feb 4, 2021
@Mic92 Mic92 deleted the patch-shebangs branch February 4, 2021 21:20
@mweinelt
Copy link
Member

mweinelt commented Feb 9, 2021

I have reverted this patch in staging-next as it apparently caused the stdenv.x86_64-darwin build to fail.

thefloweringash added a commit to thefloweringash/nixpkgs that referenced this pull request Feb 9, 2021
This caused shebangs that were already store paths to be rewritten.

Introduced by ab4c359 in NixOS#94642

Example difference:

    $ echo "hello world" | tail -c+3
    llo world

    $ str="hello world"; echo ${str:3}
    lo world
dasj19 pushed a commit to dasj19/nixpkgs that referenced this pull request Feb 11, 2021
This caused shebangs that were already store paths to be rewritten.

Introduced by ab4c359 in NixOS#94642

Example difference:

    $ echo "hello world" | tail -c+3
    llo world

    $ str="hello world"; echo ${str:3}
    lo world
@@ -105,12 +105,12 @@ patchShebangs() {
}

patchShebangsAuto () {
if [ -z "${dontPatchShebangs-}" -a -e "$prefix" ]; then
if [[ -z "${dontPatchShebangs-}" && -e "$prefix" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed dontPatchShebangs not being respected for the androidStudioPackages.{canary,dev} a bit ago, could this have anything to do with this change?

I'm not too familair with the stdenv or bash scripting, so please disregard this comment if it does not make any sense.

Suggested change
if [[ -z "${dontPatchShebangs-}" && -e "$prefix" ]]; then
if [[ -z "${dontPatchShebangs-}" || -e "$prefix" ]]; then

Copy link
Member Author

@Mic92 Mic92 May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -a stands for &&, so the code is correct. Is dontPatchShebangs unset by anything in the package you mention?

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

9 participants