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

Launch tasks in from a shallow Python stack to avoid recursion errors #3478

Merged
merged 11 commits into from
Jun 10, 2024

Conversation

benclifford
Copy link
Collaborator

@benclifford benclifford commented Jun 7, 2024

Description

Prior to this PR, task dependencies were launched from fairly arbitrary places in the call stack: for example, wherever a particular Future callback happens, sometimes deep inside executor-specific threads and/or in launch code for earlier tasks. In situations described in #3472 this could result in a a Python call stack overflow, as long call chains accumulate.

This PR makes all task launches be queued to happen from a near-empty stack in a single thread (managed as a concurrent.futures.ThreadPoolExcutor) - with a "invoke this call soon" pattern.

The launch_if_ready method was already intended to be launched multiple times from multiple threads. this PR might make the invocation to launch_if_ready happen a bit later, but correctness-wise that should be fine: a task can only become more ready to run, not less ready.

This PR introduces a test test_dependency_deep, which simulates a situation where this #3472 failure happens (before this PR), and tests (for the future) that tasks are not launched beyond a fairly arbitrary stack depth.

Changed Behaviour

Performance of task launching is probably a bit different now. I have not quantified this.

Exceptions during task launch (from parsl, or from plugged in executors) will now appear in a different call stack, and so be reported differently.

Fixes

Fixes #3472

Type of change

  • Bug fix

... rather than recursively deep in a dependency processing chain

probably some change in performance?

launch_if_ready was already intended to be launched multiple times
from multiple threads. this PR might make the invocation to
launch_if_ready happen a bit later, but correctness-wise that should
be fine: a task can only become *more* ready to run, not less *ready*.
@benclifford benclifford changed the title fix 3472 recursion problems by launching new tasks with a fairly new Python call stack Launch tasks in from a shallow Python stack to avoid recursion errors Jun 7, 2024
@benclifford benclifford marked this pull request as ready for review June 7, 2024 11:20
@benclifford benclifford merged commit a18f0a7 into master Jun 10, 2024
6 checks passed
@benclifford benclifford deleted the benc-3472-recursion branch June 10, 2024 20: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.

RecursionError: maximum recursion depth exceeded on long chains of fast-completing tasks
2 participants