summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2024-04-23 10:52:15 -0700
committerGitHub <noreply@github.com>2024-04-23 10:52:15 -0700
commitaa0825d642cfa285f5f62761a0e23dc1e511d056 (patch)
treee08f25d73cf41bfd787c19977d087c736009df91 /etc
parent978c20f35ad7f1c071ee88dddd00f7a46ba13d61 (diff)
downloadspack-aa0825d642cfa285f5f62761a0e23dc1e511d056.tar.gz
spack-aa0825d642cfa285f5f62761a0e23dc1e511d056.tar.bz2
spack-aa0825d642cfa285f5f62761a0e23dc1e511d056.tar.xz
spack-aa0825d642cfa285f5f62761a0e23dc1e511d056.zip
Refactor to improve `spec format` speed (#43712)
When looking at where we spend our time in solver setup, I noticed a fair bit of time is spent in `Spec.format()`, and `Spec.format()` is a pretty old, slow, convoluted method. This PR does a number of things: - [x] Consolidate most of what was being done manually with a character loop and several regexes into a single regex. - [x] Precompile regexes where we keep them - [x] Remove the `transform=` argument to `Spec.format()` which was only used in one place in the code (modules) to uppercase env var names, but added a lot of complexity - [x] Avoid escaping and colorizing specs unless necessary - [x] Refactor a lot of the colorization logic to avoid unnecessary object construction - [x] Add type hints and remove some spots in the code where we were using nonexistent arguments to `format()`. - [x] Add trivial cases to `__str__` in `VariantMap` and `VersionList` to avoid sorting - [x] Avoid calling `isinstance()` in the main loop of `Spec.format()` - [x] Don't bother constructing a `string` representation for the result of `_prev_version` as it is only used for comparisons. In my timings (on all the specs formatted in a solve of `hdf5`), this is over 2.67x faster than the original `format()`, and it seems to reduce setup time by around a second (for `hdf5`).
Diffstat (limited to 'etc')
0 files changed, 0 insertions, 0 deletions