-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Compiler search uses a pool of workers #10190
Compiler search uses a pool of workers #10190
Conversation
Local workstation (Ubuntu 18.04 - SSD local filesystem) With a1565f1: <this branch>$ time spack compiler add
==> Added 3 new compilers to /home/mculpo/.spack/linux/compilers.yaml
gcc@8.2.0 gcc@7.3.0 clang@6.0.1-svn334776-1~exp1~20181018152737.116
==> Compilers are defined in the following files:
/home/mculpo/.spack/linux/compilers.yaml
real 0m0,808s
user 0m0,910s
sys 0m0,289s
while using develop at ec2c5e5: <develop>$ time spack compiler add
==> Added 3 new compilers to /home/mculpo/.spack/linux/compilers.yaml
gcc@8.2.0 gcc@7.3.0 clang@6.0.1-svn334776-1~exp1~20181018152737.116
==> Compilers are defined in the following files:
/home/mculpo/.spack/linux/compilers.yaml
real 0m1,508s
user 0m3,755s
sys 0m0,718s Fidis front-end (rhel 7.3 - GPFS filesystem) <this-branch>$ time spack compiler add
==> Added 1 new compiler to /home/culpo/.spack/linux/compilers.yaml
gcc@4.8.5
==> Compilers are defined in the following files:
/home/culpo/.spack/linux/compilers.yaml
real 0m0.611s
user 0m0.432s
sys 0m0.180s while using develop at ec2c5e5: <develop>$ time spack compiler add
==> Added 1 new compiler to /home/culpo/.spack/linux/compilers.yaml
gcc@4.8.5
==> Compilers are defined in the following files:
/home/culpo/.spack/linux/compilers.yaml
real 0m1.908s
user 0m1.449s
sys 0m0.463s |
02c2cdf
to
8b5c342
Compare
@tgamblin @becker33 I need to check what's going on with Travis (I get an error similar to #10186 but I can't reproduce it locally with python 2.7). Anyhow, the numbers above seem interesting - if you could give me an early feedback whether you like this approach or not I'll proceed fixing the Cray environments. |
9d49d2a
to
fd4e9aa
Compare
The tests now pass, even though I had to skip logging some errors for Python 2.6 (see da56be6). The command: $ spack compiler add is 2x-3x faster than |
FYI, while working on this PR I noticed that Python 2.6 and Python 2.7, on Command exited with status 1:
'/usr/bin/cc' '-V'
cc: error: unrecognized command line option ‘-V’
cc: fatal error: no input files where the non ascii characters The problem can be trimmed down to the different behavior $ python2.6
Python 2.6.9 (default, Apr 29 2018, 12:56:59)
[GCC 7.3.0] on linux4
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdout.write(u'\u2018\n')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 0: ordinal not in range(128)
$ python2.7
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdout.write(u'\u2018\n')
‘ This essentially means that |
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.
@alalazo: this looks awesome to me. Especially the performance results.
The only major piece of feedback I have is that it would be nice to use ThreadPool.map()
directly, without the execute
/invoke
stuff. I just think it's easier to read and more familiar to people if you do that. For example, why not do this (or similar with a function):
python tp.map(lambda args: f(*args), arguments)
instead of flipping it around with execute()?
- As kind of indicated above, I think it would be better if we made it so that the mapped functions don't take callback arguments, because I see that as more portable to a multiprocess pool if it ever makes sense to use one.
More details in comments. See what you think.
da56be6
to
e72f8eb
Compare
@tgamblin If the code in |
5448ef0
to
e8133ea
Compare
55d88a0
to
61368e2
Compare
Real time reported for compiler detection as of 397cdf3:
Summary: the time to detect compilers for usual linux systems improved substantially, Cray remained quite the same (not surprising as the main optimizations were on avoiding useless |
This is to be consistent with the 'can_access' function already present in the module.
* Simplified _CompilerID * Extracted search_compiler_commands from Compiler * Added search_regexps to Compiler * A few functions manipulating paths that could be useful in other parts of the code have been moved to llnl.util.filesystem * Removed deferred functions in favor of mapping arguments to functions as required in the review * Moved most of the code involved in compiler detection in spack.compilers
This permits to deal more neatly with peculiarities of Cray systems when detecting compilers.
The function doesn't use anymore 'map', 'filter' and 'os.path.realpath' + it's based on a single loop.
1237a14
to
ea7910a
Compare
Ready for further review! |
for o in oss: | ||
compiler_lists.extend(o.find_compilers(*paths)) | ||
return compiler_lists | ||
if path_hints is None: |
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.
@alalazo I think this check might be overly strict. I'm seeing cases where path_hints
is []
for spack compiler find
(which I expect would check PATH
) and so this check is not triggered.
- spack.compilers.find_compilers now uses a multiprocess.pool.ThreadPool to execute system commands for the detection of compiler versions. - A few memoized functions have been introduced to avoid poking the filesystem multiple times for the same results. - Performance is much improved, and Spack no longer fork-bombs the system when doing a `compiler find`
- spack.compilers.find_compilers now uses a multiprocess.pool.ThreadPool to execute system commands for the detection of compiler versions. - A few memoized functions have been introduced to avoid poking the filesystem multiple times for the same results. - Performance is much improved, and Spack no longer fork-bombs the system when doing a `compiler find`
closes #10127
Following the request in #10127 (review) I started refactoring the logic underneath:
$ spack compiler add
The version in this PR shows much better performance than the version in
develop
. The main modifications are:spack.compilers.find_compilers
employs amultiprocess.pool.ThreadPool
to execute system commands for the detection of compiler versions.Timing tests will be posted in the discussion below.