Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: improve job selection performance in case of potential ambiguity that is resolved by comprehensive ruleorder statements. #1147

Merged
merged 3 commits into from Sep 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions snakemake/dag.py
Expand Up @@ -735,7 +735,18 @@ def update(
exceptions = list()
cycles = list()

for job in jobs:
# check if all potential producers are strictly ordered
jobs = sorted(jobs, reverse=True)
discarded_jobs = set()

def is_strictly_higher_ordered(pivot_job):
return all(
pivot_job > job
for job in jobs
if job is not pivot_job and job not in discarded_jobs
)

for i, job in enumerate(jobs):
logger.dag_debug(dict(status="candidate", job=job))
if file in job.input:
cycles.append(job)
Expand All @@ -753,16 +764,19 @@ def update(
progress=progress,
create_inventory=create_inventory,
)
# TODO this might fail if a rule discarded here is needed
# elsewhere
producers.append(job)
if is_strictly_higher_ordered(job):
# All other jobs are either discarded or strictly less given
# any defined ruleorder.
break
except (
MissingInputException,
CyclicGraphException,
PeriodicWildcardError,
WorkflowError,
) as ex:
exceptions.append(ex)
discarded_jobs.add(job)
except RecursionError as e:
raise WorkflowError(
e,
Expand Down