Skip to content

LocalExecutor: add configurable worker reuse and match Executor API#52

Closed
tfpgh wants to merge 1 commit into
masterfrom
local_executor_reuse
Closed

LocalExecutor: add configurable worker reuse and match Executor API#52
tfpgh wants to merge 1 commit into
masterfrom
local_executor_reuse

Conversation

@tfpgh

@tfpgh tfpgh commented Jun 9, 2026

Copy link
Copy Markdown

LocalExecutor hardcodes max_tasks_per_child=1 to match the isolation of the distributed Executor. This launches a fresh process for each task. If tasks are cheap, spawning a new interpreter and re-importing everything can cost many times the task itself.

Separately, Executor replaces itself on instantiation with LocalExecutor when force_local=True. But LocalExecutor doesn't implement get_submit_queue_size() from Executor's interface, meaning any caller using it crashes with an AttributeError in local mode.

  • Add JobConfig.local_max_tasks_per_child: Optional[int] = 1, passed through to the ProcessPoolExecutor in local mode. LocalExecutor users can elect to run multiple tasks per launched process. This leaves the default behavior unchanged.
  • Add LocalExecutor.get_submit_queue_size(), making local mode closer to a drop-in swap.

@tfpgh tfpgh requested review from MarkNDeaconu and haraschax June 9, 2026 22:50
@haraschax

Copy link
Copy Markdown
Contributor

LocalExecutor was never really intended to be fast or used outside of some specific test use cases.

if you want to replace a distributed executor somewhere, just use process pool? If for any reason that isn’t an easy or good swap, let me know.

@tfpgh tfpgh closed this Jun 10, 2026
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.

2 participants