Skip to content

Commit

Permalink
Use a set for the contains check in topo order path for invalidation
Browse files Browse the repository at this point in the history
I was doing some profiling of noop runs and noticed this linear search showing up fairly high when building targets with a closure of around 7k targets.

This creates a set and uses that as a look up table rather than retraversing the list for each target.

Testing Done:
CI passed at https://travis-ci.org/pantsbuild/pants/builds/126737381

Bugs closed: 3302

Reviewed at https://rbcommons.com/s/twitter/r/3786/

closes #3302
  • Loading branch information
baroquebobcat committed Apr 29, 2016
1 parent 52bdf4e commit c5a2e6d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/python/pants/invalidation/cache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ def wrap_targets(self, targets, topological_order=False):
"""
def vt_iter():
if topological_order:
sorted_targets = [t for t in reversed(sort_targets(targets)) if t in targets]
target_set = set(targets)
sorted_targets = [t for t in reversed(sort_targets(targets)) if t in target_set]
else:
sorted_targets = sorted(targets)
for target in sorted_targets:
Expand Down

0 comments on commit c5a2e6d

Please sign in to comment.