Repository navigation
[fix,refactor] Remove SimpleStorageUnit ZMQ proxy hop and per-request thread resets - #228
Merged
Merged
Conversation
…ead resets - Poll the bound ROUTER socket directly from the single SimpleStorageUnit worker thread (preserving STORAGE_CLIENT_IDENTITY_PREFIXES filtering), removing proxy_thread, inproc worker_socket, and the 0.5s startup sleep - Configure PyTorch CPU parallelism once in SimpleStorageUnit.__init__ via set_pytorch_auto_parallel_threads rather than reading /proc/cpuinfo and mutating process-global torch.set_num_threads on every request - Populate GET reply wire_bytes in ZmqPayloadTransfer.request and unify heavy-operation logging for PUT, UPDATE, and GET on the client side in AsyncSimpleStorageManager._request_payload Signed-off-by: 0oshowero0 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…nd exit on poll faults - Replace empty-frame flushing on mid-reply errors with closing and rebinding the ROUTER socket so uncommitted multipart frames are rolled back rather than delivered incomplete - Validate decoded tensor and NumPy buffer byte lengths against shape * itemsize in serial_utils so truncated or empty frames never materialize uninitialized arrays - Propagate unrecoverable ZMQ poller errors (e.g. ENOTSOCK) to _abort_process instead of spinning in _worker_loop Signed-off-by: 0oshowero0 <[email protected]>
…read fallback - Remove _rebind_router_socket and pre-construct zmq.Frame buffers before sending so pre-send errors keep queued concurrent requests intact while mid-SNDMORE failures exit cleanly via _abort_process - Revert per-tensor serial_utils decode size check to restore baseline decode throughput - Fall back to logical/OS CPU count when psutil.cpu_count(logical=False) is None on ARM64/containers, set PyTorch threads inside _worker_routine, and clean up stale proxy comments Signed-off-by: 0oshowero0 <[email protected]>
Signed-off-by: 0oshowero0 <[email protected]>
SimpleStorageUnit ZMQ proxy hop and per-request thread resets
…n error Signed-off-by: 0oshowero0 <[email protected]>
0oshowero0
pushed a commit
that referenced
this pull request
Nov 26, 2026
After #228 moved SimpleStorage worker thread configuration to startup, the client still queries CPU topology on every async_put() and async_get_data() call through limit_pytorch_auto_parallel_threads(). Cache the CPU count once at module import to remove these repeated queries from the client-side data transfer paths. he cached count assumes CPU topology remains stable during runtime. Previously tested on a verl ref worker: tq.get() time 5.69s → 0.23s per step; tq.put() time 6.28s → 1.52s per step. @renjunying2 Signed-off-by: dodatboii <[email protected]>
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.
Summary
Simplify
SimpleStorageUnit's ZMQ serving path, eliminate per-request PyTorch thread-count resets, unifyGETheavy-operation logging on the client side, and harden worker fault isolation.Changes
ROUTERworker loop (transfer_queue/storage/simple_storage.py):ROUTERsocket directly fromSimpleStorageUnit's single worker thread (retainingSTORAGE_CLIENT_IDENTITY_PREFIXESfiltering), removingproxy_thread, theinproc://DEALERsocket, two redundant ZMQ forwarding hops per request, and the hardcoded0.5sstartup sleep.transfer_queue/utils/common.py,simple_storage.py):set_pytorch_auto_parallel_threads()and call it once at_worker_routinestartup instead of reading CPU topology (psutil.cpu_count(logical=False)) and togglingtorch.set_num_threads()on every storage request.zmq.py,simple_storage_manager.py,simple_storage.py):PayloadReply.wire_bytesforGETresponses inZmqPayloadTransfer.requestand invokelog_heavy_operation()uniformly forPUT,UPDATE, andGETinAsyncSimpleStorageManager._request_payload, removing theGET-specific server-side logging branch.Reliability Improvements
_proxy_routineeagerly drained incoming requests intoworker_socket'sinproc://pipe, so closing and recreatingworker_socket(linger=0)on any unhandled per-request error silently dropped sibling requests already buffered in that pipe (including single-attempt operations such asUPDATEandCLEAR_DATA). Materializing all replyzmq.Frameviews before touchingput_get_socketkeeps theROUTERsocket intact on pre-send errors so queued sibling requests continue to be served.SNDMOREfailures:_send_multipart_replyvalidates and wraps all frames before queuing the routing identity withzmq.SNDMORE. Ifsend()fails after a non-finalSNDMOREframe has already enteredput_get_socket,_router_taintedescalates to_abort_processso the next peer's reply can never be appended to an unfinished multipart envelope, while ZMTP's atomic multipart delivery discards uncommitted frames on the client.except Exception: continuearoundpoller.poll()in_worker_loopwithEINTR-only retry (and clean exit during shutdown) so fatalZMQErrors (e.g.ENOTSOCK) trigger_abort_processimmediately rather than spinning in a live-looking unresponsive actor.ROUTERsocket directly removes theinproc://connect ordering assumption previously papered over by a hardcoded0.5sstartup sleep.psutil.cpu_count(logical=True) or os.cpu_count() or 1whenpsutil.cpu_count(logical=False)returnsNone(avoidingTypeErroronmainand preventing silent clamping to1thread on ARM64/containerized hosts where physical core topology is unexposed), and configure ATen/OpenMP threads onworker_threaditself without mutating the caller's main thread during in-process instantiation.Performance
On the same CPU host with the Python controller, median
kv_batch_putlatency fell by 38% andkv_batch_getlatency by 28% from the pre-PR baseline. Each batch contained 128 rows with four fields of 1,024float32values per row.a90694277687f6a8c49e7The same-host batch results combine 48 measurements per operation and revision across two runs after warm-up. The storage round trips used one request at a time over loopback TCP. Each table entry for those tests is the median of three run medians.
CI medians use the final three of four iterations. Compared with
77687f6, CI recorded 10–20% higher latency ona8c49e7. In the same-host Python batch test, median PUT and GET latency fell by 4.8% and 3.2%, respectively. Baseline CI · Earlier revision CI · This revision CIValidation
test_zmq_payload_transfer.py,test_storage_request_retry.py,test_storage_key_race.py,test_accept_probe.py,test_storage_worker_death_exits.py,test_async_simple_storage_manager.py,test_simple_storage_unit.py, andtest_data_dump.py.ruff format --check,ruff check,mypy --no-site-packages transfer_queue,check_docstrings.py, andcheck_license.pypass.