perf: spack find -p now does only one DB transaction
`spec.prefix` reads from Spack's database, and if you do this with multiple consecutive read transactions, it can take a long time. Or, at least, you can see the paths get written out one by one. This uses an outer read transaction to ensure that actual disk locks are acquired only once for the whole `spack find` operation, and that each transaction inside `spec.prefix` is an in-memory operation. This speeds up `spack find -p` a lot.
This commit is contained in:
parent
ae41ef9146
commit
d79f85d763
@ -357,15 +357,18 @@ def format_list(specs):
|
|||||||
max_width = max(len(f[0]) for f in formatted)
|
max_width = max(len(f[0]) for f in formatted)
|
||||||
path_fmt = "%%-%ds%%s" % (max_width + 2)
|
path_fmt = "%%-%ds%%s" % (max_width + 2)
|
||||||
|
|
||||||
for string, spec in formatted:
|
# getting lots of prefixes requires DB lookups. Ensure
|
||||||
if not string:
|
# all spec.prefix calls are in one transaction.
|
||||||
print() # print newline from above
|
with spack.store.db.read_transaction():
|
||||||
continue
|
for string, spec in formatted:
|
||||||
|
if not string:
|
||||||
|
print() # print newline from above
|
||||||
|
continue
|
||||||
|
|
||||||
if paths:
|
if paths:
|
||||||
print(path_fmt % (string, spec.prefix))
|
print(path_fmt % (string, spec.prefix))
|
||||||
else:
|
else:
|
||||||
print(string)
|
print(string)
|
||||||
|
|
||||||
if groups:
|
if groups:
|
||||||
for specs in iter_groups(specs, indent, all_headers):
|
for specs in iter_groups(specs, indent, all_headers):
|
||||||
|
Loading…
Reference in New Issue
Block a user