Speed up install of environments with dev packages#27167
Speed up install of environments with dev packages#27167becker33 merged 2 commits intospack:developfrom
Conversation
f7cf2c4 to
0567509
Compare
Initial analysis of the codecov/patch code coverage issue:@tmadlener From looking at the report diff, the red background color of the line number and the hover text of the 🛈 symbol left to the red line number indicates that Line 1420 is not covered by tests: https://app.codecov.io/gh/spack/spack/compare/27167/diff#D1L1420 |
becker33
left a comment
There was a problem hiding this comment.
The line that codecov is complaining about should be covered by the test test_dev_build_rebuild_on_source_changes in lib/spack/spack/test/cmd/dev_build.py. I'm struggling to see why this change would make it uncovered. It looks like this PR also removes coverage for the rest of the _get_overwrite_specs method.
|
|
||
| def _get_overwrite_specs(self): | ||
| # TODO: Can the cache even be populated at this point? | ||
| self._spec_needs_overwrite.cache.clear() |
There was a problem hiding this comment.
I think the only way this could be populated at this point is if the user is using spack-python and doing multiple spack installs from the same python shell.
|
If we're not able to figure out why the codecov is dropping, another option would be to avoid memoizing and just precompute the set of all specs we need to check. Something like: Since specs are appropriately hashable, that should eliminate the duplicate work that memoizing eliminated. |
That sounds like an overall nicer solution in any case in my opinion. I will give that a go and see if it works. |
|
Ah, I just realized why I went with the memoization. I have not been able yet to come up with some clever changes to |
|
I found an alternative solution that avoids memoizing internal function calls. In my testing it seems to be only slightly slower compared to the memoized version (order of roughly 10 %). The basic principle now is:
This still does a bit more work than it would need to, but at least it skips the costly part of repeatedly going to the file system to check time stamps for the same files over and over again, as that is done only once now per each dev build package. |
1ecf831 to
069b898
Compare
|
@tmadlener, the CI Pipeline failure seems to be from:
Just to be one the safe side: Maybe could to rebase this PR to the current develop? (Just rerunning the CI could work too, but maybe it's a good idea to also rebase it) |
069b898 to
9853568
Compare
* only check file modification times once per dev package
* only check file modification times once per dev package Co-authored-by: Thomas Madlener <[email protected]>
I am currently experimenting with using environments as development environments, and I have an environment with roughly 50 root specs, with about 20 of them being local dev packages, i.e.
This seems to work as expected, i.e. changing a dev package will result in a rebuild of the package itself and all its dependents via
spack install. The problem I ran into was that it takes quite long (order of 15 - 20 minutes) for spack to figure out which packages need to be built again. This is also the case when there were no changes at all.I have tracked this down to the fact that
Environment._spec_needs_overwriteis called over and over again with the same specs, because when figuring out which packages to rebuild, spack walks the complete DAGs of all root packages (and then recursively the DAGs of dependencies as far as I can tell). This becomes quite expensive, because for dev packages it will actually start to compare timestamps of the source files with the installation time stamp. Simply memoizing the results for a given spec avoids having to check specs multiple times in different dependency graphs.For me the observable behavior is unchanged. I have timed a
spack installwith and without these changes, where all packages were up to date, i.e. only the "overhead" (figuring out which packages to build, recreating the view, etc..) but no actual build is measured. Times before:with memoizing: