[codex] Avoid retaining Prefect tasks in Dask scheduler#21703
Draft
[codex] Avoid retaining Prefect tasks in Dask scheduler#21703
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #21697
this PR avoids retaining heavyweight Prefect task objects in Dask scheduler task specs when
prefect-dasksubmits Prefect tasks to an existing Dask scheduler.Details
The repro showed Dask scheduler RSS growing roughly linearly across repeated flow runs. Scheduler introspection showed no active Dask tasks or task groups after completion, but historical Dask task specs/messages still referenced Prefect
Taskobjects through the submitted task payloads.This changes Prefect Dask submission so that:
_run_prefect_taskfunction instead of a per-submit wrapper closure.Taskobjects are scattered once per client and passed to Dask tasks by future instead of embedded directly in each task spec.In the issue repro, the patched wheel changed scheduler RSS from repeatedly growing by about 80MiB per run to mostly flattening after the first run. Scheduler introspection after the patched runs still showed retained lightweight Dask task specs, but no retained Prefect
Taskobjects reachable from those specs.Added a regression test that runs a mapped Prefect task on an existing Dask cluster, then inspects retained
dask._task_spec.Taskobjects on the scheduler to assert they do not reference PrefectTaskobjects.Validation: