Skip to content
This repository has been archived by the owner on Jul 8, 2021. It is now read-only.

Commit

Permalink
Replace O(N) lookup with O(1) for task outputs.
Browse files Browse the repository at this point in the history
This speeds up suite validation significantly for tasks with
large numbers of outputs.  The list used required an O(N)
check for membership which, when combined with being run for
each output resulted in O(N**2) complexity.

Using the builtin set should bypass any deprecated libraries in
Python 2.

Closes cylc#3255
  • Loading branch information
Tim Whitcomb authored and matthewrmshin committed Sep 6, 2019
1 parent 7a4b495 commit 5a1aaf4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,8 +1590,7 @@ def generate_taskdefs(self, orig_expr, left_nodes, right, seq):

# Record custom message outputs.
for item in self.cfg['runtime'][name]['outputs'].items():
if item not in taskdef.outputs:
taskdef.outputs.append(item)
taskdef.outputs.add(item)

def generate_triggers(self, lexpression, left_nodes, right, seq,
suicide, task_triggers):
Expand Down
2 changes: 1 addition & 1 deletion cylc/flow/taskdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, name, rtcfg, run_mode, start_point, spawn_ahead):
self.expiration_offset = None
self.namespace_hierarchy = []
self.dependencies = {}
self.outputs = []
self.outputs = set()
self.param_var = {}
self.external_triggers = []
self.xtrig_labels = {} # {sequence: [labels]}
Expand Down

0 comments on commit 5a1aaf4

Please sign in to comment.