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

Make Spack's compiler wrapper compatible with dash #8703

Closed
adamjstewart opened this issue Jul 13, 2018 · 3 comments · Fixed by #26259
Closed

Make Spack's compiler wrapper compatible with dash #8703

adamjstewart opened this issue Jul 13, 2018 · 3 comments · Fixed by #26259

Comments

@adamjstewart
Copy link
Member

adamjstewart commented Jul 13, 2018

Currently, Spack's compiler wrapper is hardcoded to use /bin/bash. However, if we changed this to /bin/sh and made things POSIX compliant, systems like Ubuntu that default to dash could see vast slight improvements to build times for large, complex packages. If we changed it to /usr/bin/env sh, Spack users could install dash on other systems and add it to their PATH, although I don't know how much env will slow down runtimes.

If no one else gets to this, I'll probably experiment with it eventually. I just wanted to make a dedicated issue before I forget.

Related to #4048. Probably depends on #7604. See https://unix.stackexchange.com/questions/148035 for performance comparisons between common shells.

@tgamblin
Copy link
Member

tgamblin commented Jul 13, 2018

@adamjstewart: The wrappers were originally in Python, and the difference using bash vs python was up to 8x speedup for some builds. The main bottleneck for wrappers is startup time -- there isn't really anything major actually done in the cc script.

I'm not sure dash will add a lot more:

(atala):env$ time for x in `seq 1 100`; do python -c 'exit()'; done
real	0m3.461s
user	0m1.222s
sys	0m1.479s

(atala):env$ time for x in `seq 1 100`; do bash -c 'exit'; done
real	0m0.429s
user	0m0.196s
sys	0m0.204s

(atala):env$ time for x in `seq 1 100`; do dash -c 'exit'; done
real	0m0.355s
user	0m0.120s
sys	0m0.146s

Python -> bash was at least a 10x startup time improvement (and it's generally more on clusters). bash -> dash is maybe a 20% improvement on top of that, but it's only an improvement to the startup time. I suspect we're already at the point where the compile/build time dominates, and this won't result in "vast improvements".

It's also worth noting that if you use #!/usr/bin/env sh as you suggest, you lose any speedup over bash:

(atala):env$ time for x in `seq 1 100`; do /usr/bin/env dash -c exit; done

real	0m0.536s
user	0m0.189s
sys	0m0.227s

You're paying for two process launches now (env and dash) as well as the path search that env does. The absolute #!/bin/bash shebang will be faster.

@adamjstewart
Copy link
Member Author

@tgamblin Thanks for the tests! I'll probably still try to get /bin/sh working if we don't need too many Bashisms. We may encounter a system without /bin/bash someday, although it's pretty unlikely.

@adamjstewart
Copy link
Member Author

@tgamblin I think this is worth revisiting. I see a much larger performance boost from switching to dash:

$ time for x in `seq 1 100`; do python -c 'exit()'; done

real	0m11.198s
user	0m3.478s
sys	0m2.193s
$ time for x in `seq 1 100`; do bash -c 'exit'; done

real	0m1.740s
user	0m0.253s
sys	0m0.548s
$ time for x in `seq 1 100`; do dash -c 'exit'; done

real	0m1.055s
user	0m0.085s
sys	0m0.238s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants