[prototype] asyncio control plane for BlockAllocationTaskScheduler - #1073
Draft
jan-janssen wants to merge 4 commits into
Draft
jan-janssen wants to merge 4 commits into
jan-janssen wants to merge 4 commits into
Conversation
Experimental, opt-in via EXECUTORLIB_ASYNCIO=1. Replaces the one thread per worker of the BlockAllocationTaskScheduler with worker coroutines on a single private asyncio event loop (one background thread owned by the executor) plus one dispatcher thread reading the existing queue.Queue. ZMQ communication uses zmq.asyncio with one shared context per executor. The public API, concurrent.futures.Future objects, the worker-side protocol and the threaded default path are unchanged. The calling thread's event loop (e.g. Jupyter) is never used or modified. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: jan-janssen <3854739+jan-janssen@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1073 +/- ##
==========================================
- Coverage 94.29% 92.65% -1.65%
==========================================
Files 39 40 +1
Lines 2192 2423 +231
==========================================
+ Hits 2067 2245 +178
- Misses 125 178 +53 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Experimental prototype to evaluate whether
zmq.asynciocan cut the administrative thread overhead of the interactive block-allocation backend. Opt-in only viaEXECUTORLIB_ASYNCIO=1; the default threaded path is unchanged.Motivation
BlockAllocationTaskSchedulerstarts one Python thread per worker. Each thread spends its life blocked, either infuture_queue.get()while idle or inSocketInterface.receive_dict()while a task runs. N workers therefore cost N administrative threads.Approach
queue.Queueand hands an item to a worker coroutine only once that worker is idle. Tasks therefore stay in the queue until picked up, socancel_futures, the shutdown sentinels andmax_workersresizing keep their current behaviour.AsyncSocketInterfaceis azmq.asynciosubclass ofSocketInterfacewith the same wire protocol, so the worker side is unchanged. All interfaces of one executor share one ZMQ context.asyncio.run, norun_until_completeon the caller's loop, nonest_asyncio. The caller's event loop is never touched.concurrent.futures.Futureobjects.Expected: 2 administrative threads per executor, independent of
max_workers.Changes
standalone/interactive/communication.py:AsyncSocketInterface, plus an optionalcontextargument forinterface_bootup.task_scheduler/interactive/shared.py:execute_task_dict_async, with the same caching and error semantics asexecute_task_dict.task_scheduler/interactive/blockallocation_async.py(new):AsyncWorkerPool, a thread-likeAsyncWorkerhandle, and the worker coroutine.task_scheduler/interactive/blockallocation.py: switches between threads and async workers based on the opt-in flag, and closes the pool on shutdown.tests/unit/task_scheduler/interactive/test_blockallocation_async.py(new): basic use, concurrent tasks, exceptions, shutdown modes, repeated creation, resizing, use inside a running event loop, and thread-count scaling.Status: not yet verified
EXECUTORLIB_ASYNCIO=1set globally.OneProcessTaskScheduler.Known limitations
bootup()andshutdown(wait=True)are still synchronous and run on the event loop. That's fine forMpiExecSpawner, but the pysqa spawner's pollingsleepwould block all workers while one boots.Futuredone-callbacks now run on the event-loop thread rather than on per-worker threads.queue_join_on_shutdown=Trueisn't supported in async mode. The scheduler always sets it toFalse.🤖 Generated with Claude Code