Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance boost: reduce instantiations of re.Scanner
- Lexer is the same for every Spec parser in spack, so don't build it every time. - This improves time to import package.py files a lot, as a Lexer doesn't have to be constructed for every spc in the packages. - To concretize dealii: - Before: ~20 sec - After: ~6 sec
- Loading branch information
e8b4d5f
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.
@davydden: see if this helps some more with concretization time. I cherypicked this from a branch with some other optimizations that aren't ready yet, so the times above may be a little fast, but this should result in a speedup nonetheless.
e8b4d5f
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.
@tgamblin : from my unscientific measurements (on iPhone), the time of
spack spec deali@dev
went down from~14sec
to~8sec
on the current master. So it does help 👍e8b4d5f
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.
@davydden: if you go into the
openssl
package and changeurl_for_version
to_url_for_version
, how much does that affect your concretization time? I noticed that includingopenssl
adds ~3sec to concretization for me. I'd like to figure out a better way to handle the version check in there, maybe by a separate command.e8b4d5f
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: any thoughts on
openssl
?e8b4d5f
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.
@tgamblin I didn't profile the package yet, but I assume that most of the time is spent in :
in particular in the
urllib.urlopen
call. We may try to move tourllib2
and fine tune some of the defaults (like timeout or similar), but this will help only in those cases where we don't have a connection available.On the other hand this unique behavior in
url_for_version
was explicitly requested in an issue some time ago and I believe that it has some points : now anybody using a spack builtopenssl
gets a clear warning as long as the openssl version gets deprecated, so I am not sure I am in favor of removing it.Just out of curiosity, would setting something like :
help with concretization time ? If so we may just provide a sensible default for
openssl
in theetc
directory.e8b4d5f
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: Yep 😄. That's exactly where the three seconds go. And I remember the issue. People are concerned about installing outdated (and insecure) openssl versions.
I think the issue here is that
url_for_version
isn't really the right place for this. It gets called in a few different places, including inPackage.__init__
, which is called during concretization. That means commands likespack spec
will make URL connections, which is clunky, andurl_for_version
has to record that it was called to avoid making lots of connections. So,url_for_version
doesn't really have enough information to figure out whether/when it needs to do a check. It would be nice, for example, if the check could figure out that we're on a machine without a network connection (like LLNL's closed network).I was thinking that it would be better to add some better control points for checks like this. What do you think of adding a few overridable methods to
Package
to give package authors some more control? e.g., I was thinking of adding these:Package.pre_install_dag(self, spec)
: executes after concretization of the spec to be installed, so the DAG is complete, but nothing has been fetched/staged yet, and no deps have been installed.Package.pre_install(self, spec)
: executes right before this package is installed. Its dependencies will have already been installed, and it will have been fetched and staged.Package.post_install(self, spec)
: executes right after this package is installed. Package is installed and build stage is still present.Package.post_install_dag(self, spec)
: executes after all packages in a DAG have been installed.By default they would do nothing, but packages that want them could implement them (the way they currently implement
patch()
). Theopenssl
check could easily go inpre_install_dag
, which would be guaranteed to be invoked once, right before a package that depends onopenssl
is installed. The_dag
routines should probably be called in postorder for each DAG.