Skip to content

Support continuous pipeline in run_pipeline_in_subprocess#1369

Merged
mthrok merged 1 commit into
mainfrom
continuous2
Apr 20, 2026
Merged

Support continuous pipeline in run_pipeline_in_subprocess#1369
mthrok merged 1 commit into
mainfrom
continuous2

Conversation

@mthrok
Copy link
Copy Markdown
Collaborator

@mthrok mthrok commented Apr 20, 2026

When the pipeline config has continuous=True on its source, the internal _Wrapper used by run_pipeline_in_subprocess and run_pipeline_in_subinterpreter now builds the pipeline once and reuses it across iter() calls via get_iterator(). This avoids rebuilding the thread pool and event loop each epoch, keeping threads alive across epoch boundaries inside the subprocess.

Previously, every iter() call on the wrapper rebuilt the pipeline from scratch, creating a new ThreadPoolExecutor and asyncio event loop.
For continuous sources with epoch boundary markers (_EPOCH_END), this was wasteful — the pipeline should stay alive and simply yield items until the next epoch boundary.

The _has_continuous_source() helper inspects the PipelineConfig tree (including MergeConfig sub-pipelines) to detect whether the source is continuous, and the check is performed once in __init__.

When the pipeline config has `continuous=True` on its source, the
internal `_Wrapper` used by `run_pipeline_in_subprocess` and
`run_pipeline_in_subinterpreter` now builds the pipeline once and
reuses it across `iter()` calls via `get_iterator()`.
This avoids rebuilding the thread pool and event loop each epoch,
keeping threads alive across epoch boundaries inside the subprocess.

Previously, every `iter()` call on the wrapper rebuilt the pipeline
from scratch, creating a new `ThreadPoolExecutor` and asyncio event
loop.
For continuous sources with epoch boundary markers (`_EPOCH_END`),
this was wasteful — the pipeline should stay alive and simply yield
items until the next epoch boundary.

The `_has_continuous_source()` helper inspects the `PipelineConfig`
tree (including `MergeConfig` sub-pipelines) to detect whether the
source is continuous, and the check is performed once in `__init__`.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 20, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Apr 20, 2026

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D101687499. (Because this pull request was imported automatically, there will not be any future comments.)

@mthrok mthrok marked this pull request as ready for review April 20, 2026 21:12
@mthrok mthrok merged commit d655937 into main Apr 20, 2026
305 of 309 checks passed
@mthrok mthrok deleted the continuous2 branch April 20, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant