Skip to content

Don't recompute runahead unnecessarily in main loop - #7435

Merged
oliver-sanders merged 2 commits into
cylc:8.6.xfrom
MetRonnie:main-loop-runahead
Sep 8, 2026
Merged

Don't recompute runahead unnecessarily in main loop#7435
oliver-sanders merged 2 commits into
cylc:8.6.xfrom
MetRonnie:main-loop-runahead

Conversation

@MetRonnie

@MetRonnie MetRonnie commented Sep 1, 2026

Copy link
Copy Markdown
Member

Partially supersedes #7400 - contains minimal set of changes that I'm happy with

Don't recompute runahead in the main loop if nothing is changing.

Follow-up #7237 (see last paragraph of #7237 (comment) )

Check List

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • No dependency changes
  • Tests are updated
  • Changelog entry not needed
  • Docs not needed
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

@MetRonnie MetRonnie added this to the 8.6.6 milestone Sep 1, 2026
@MetRonnie MetRonnie self-assigned this Sep 1, 2026
# the parentless task "a" should be spawned out to the runahead limit
assert schd.pool.get_task_ids() == {'2/a', '3/a'}
# the parentless task "a" should be spawned out to the next cycle
assert schd.pool.get_task_ids() == {'2/a'}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change in behaviour - but not one that will affect real running of workflows. After the cylc set operation, tasks are not spawned out to runahead limit until the main loop gets round to it.

This test goes on to check that we continue to spawn out to the runeahead limit below.

<span style="color:#000000;background:#e5e5e5"> </span><span style="color:#000000;background:#e5e5e5">-</span><span style="color:#000000;background:#e5e5e5"> </span><span style="color:#000000;background:#e5e5e5">̿○</span><span style="color:#000000;background:#e5e5e5"> 2 </span>
<span style="color:#000000;background:#e5e5e5"> </span><span style="color:#000000;background:#e5e5e5">-</span><span style="color:#000000;background:#e5e5e5"> </span><span style="color:#000000;background:#e5e5e5">̿○</span><span style="color:#000000;background:#e5e5e5"> A </span>
<span style="color:#000000;background:#e5e5e5"> </span><span style="color:#000000;background:#e5e5e5"> </span><span style="color:#000000;background:#e5e5e5"> </span><span style="color:#000000;background:#e5e5e5">̿○</span><span style="color:#000000;background:#e5e5e5"> </span><span style="color:#000000;background:#e5e5e5">a</span><span style="color:#000000;background:#e5e5e5"> </span>
<span style="color:#000000;background:#e5e5e5"> </span><span style="color:#000000;background:#e5e5e5">-</span><span style="color:#000000;background:#e5e5e5"> </span><span style="color:#000000;background:#e5e5e5">○</span><span style="color:#000000;background:#e5e5e5"> 2 </span>

@MetRonnie MetRonnie Sep 1, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor difference in these TUI tests:

-̿ ○
+

The waiting task is no longer queued immediately after the cylc set operation, but will be queued in the next main loop iteration.

This does not matter for the purposes of the two tests:

  • /tests/integration/tui/test_app.py::test_auto_expansion
  • /tests/integration/tui/test_mutations.py::test_set_mutation

'5/foo',
'6/foo',
'7/foo',
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another minor change in behaviour - the task pool immediately after removing the other tasks does not spawn out to the runahead limit. Again this is OK because we test below that the workflow continues out to the runahead limit naturally anyway.

@MetRonnie
MetRonnie marked this pull request as ready for review September 1, 2026 16:15
Comment thread cylc/flow/scheduler.py
Comment on lines +528 to +541
# BACK COMPAT: spawn the task pool out to RH limit on startup.
# Not strictly necessary, it will spawn ahead per main loop iteration,
# but useful back-compat for tests that expect this prior to
# https://github.com/cylc/cylc-flow/pull/7237
# FROM: 8.6.x
# TO: 8.7.0
# REMOVE AT: 8.7.0
self.pool.compute_runahead()
for _ in range(10):
# (Arbitrary limit to avoid infinite loop if something goes wrong)
if not self.pool.release_runahead_tasks():
for itask in self.pool.get_tasks():
self.pool.queue_if_ready(itask)
break

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted the shim out into the scheduler and deliberately not in its own method, to stem any temptation to call it anywhere else in future on 8.6.x

Co-authored-by: Hilary Oliver <hilary.j.oliver@gmail.com>

@hjoliver hjoliver left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. #7400 minus shim removal and test adaptation to that.

IF we were removing the shim on 8.6.x (as I was trying to do) this needs to be done together with that to avoid having to pointlessly adapt the tests twice, but fine to delay the shim removal in current circumstances.

@hjoliver hjoliver mentioned this pull request Sep 7, 2026
8 tasks
Comment thread cylc/flow/scheduler.py
or self.pool.tasks_removed
)

if has_updated:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😕 ⛔ 🦭

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do those emoji suggest you don't like the pool.tasks_removed bit? (It's there because removing a task can change the runahead base point) or the has_updated bit? (which isn't this PR).

@oliver-sanders
oliver-sanders merged commit a155b6b into cylc:8.6.x Sep 8, 2026
22 of 23 checks passed
@MetRonnie
MetRonnie deleted the main-loop-runahead branch September 8, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants