From 3f091fb6db627e3e780b27757dc8edfec117cb38 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Fri, 13 Oct 2017 17:14:42 -0700 Subject: [PATCH] Use list instead of OrderedDict to find virtual/external candidates - This reduces concretization time for r-rminer from over 1 minute to only 16 seconds. - OrderedDict ends up taking a *lot* of time to compare larger specs. - An OrderedDict isn't actually needed here. It's actually not possible to find duplicates, and we end up sorting the contents of the OrderedDict anyway. --- lib/spack/spack/concretize.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py index 10a37050834..af3f3a3b18b 100644 --- a/lib/spack/spack/concretize.py +++ b/lib/spack/spack/concretize.py @@ -37,7 +37,6 @@ from six import iteritems from spack.version import * from itertools import chain -from ordereddict_backport import OrderedDict from functools_backport import reverse_order import spack @@ -80,17 +79,15 @@ def _valid_virtuals_and_externals(self, spec): # For each candidate package, if it has externals, add those # to the usable list. if it's not buildable, then *only* add # the externals. - # - # Use an OrderedDict to avoid duplicates (use it like a set) - usable = OrderedDict() + usable = [] for cspec in candidates: if is_spec_buildable(cspec): - usable[cspec] = True + usable.append(cspec) externals = spec_externals(cspec) for ext in externals: if ext.satisfies(spec): - usable[ext] = True + usable.append(ext) # If nothing is in the usable list now, it's because we aren't # allowed to build anything.