Repository navigation
[refactor, transfer] Introduce PayloadTransfer abstraction for SimpleStorage - #214
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d394bf99bd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| raise TransferTimeout("NIXL storage request timed out", wire_bytes=wire_bytes) | ||
| await asyncio.sleep(0.001) | ||
| response = reply.result() | ||
| except Exception as exc: |
There was a problem hiding this comment.
Treat cancelled writes as outcome-unknown after sending
When a PUT/UPDATE task is cancelled after send_notification but before the reply, asyncio.CancelledError inherits BaseException and therefore bypasses this except Exception; the storage unit may still apply the write while the caller sees only cancellation. A caller using asyncio.wait_for and retrying can consequently apply a non-idempotent UPDATE twice, so this post-send cancellation path needs to finish determining the outcome or surface WriteOutcomeUnknown just like the timeout path.
Useful? React with 👍 / 👎.
| logger.exception("NIXL storage request %s failed", request_id) | ||
| reply["error"] = str(exc)[:4096] | ||
| try: | ||
| packed = self._pack_control(reply) |
There was a problem hiding this comment.
Prevent oversized update acknowledgements after committing
When an UPDATE produces enough per-sample stored_shapes to make its reply exceed MAX_CONTROL_BYTES (1 MiB), _handle has already called apply_update before this packing attempt. _pack_control then falls into the outcome-unknown reply, so AsyncSimpleStorageManager.update_data raises before notify_data_update; for a newly added or shape-changing field, storage is committed while controller metadata remains stale. Large valid updates therefore deterministically leave the planes inconsistent; reject or preflight before applying, or carry the acknowledgement body outside the capped notification.
Useful? React with 👍 / 👎.
|
cc @Ginray |
PayloadTransfer abstraction for SimpleStorage
Signed-off-by: lanzeshun <[email protected]>
Signed-off-by: lanzeshun <[email protected]>
Signed-off-by: lanzeshun <[email protected]>
Signed-off-by: lanzeshun <[email protected]>
Signed-off-by: lanzeshun <[email protected]>
Signed-off-by: lanzeshun <[email protected]>
Signed-off-by: 0oshowero0 <[email protected]>
- Simplify PayloadTransfer.request recv to Spans | None = None, add FieldData/HeaderBody aliases, separate server/client roles, and export core symbols from payload_transfer.__init__. - Synchronize SimpleStorageUnit state and counter access with _storage_lock while keeping PUT/GET data_parser execution outside the lock, and retry transient TransferError failures on fresh connections. - Replace KEY_NOT_FOUND_MARKER string prefixing with structured missing_key metadata, condense ZMQ wire-type mappings, and streamline tests around end-to-end payload contracts. Signed-off-by: 0oshowero0 <[email protected]>
…queued put memory - Extract PayloadClient to encapsulate per-loop peer handshakes, connection caching/eviction, and shutdown outside AsyncSimpleStorageManager, and move StorageKeyNotFoundError to transfer_queue.storage.exceptions. - Replace body/data tuple returns and alias indirections with RequestHeader.params and PayloadReply(meta, payload, wire_bytes), and clarify write vs read semantics on PayloadTransfer.request. - Defer ZMQ request serialization inside pool.alease so queued writers retain zero-copy views, restore [TQKeyNotFound] wire compatibility across rolling upgrades, and add dual copyright headers. Signed-off-by: 0oshowero0 <[email protected]>
…ispatch - Keep StorageKeyNotFoundError.__module__ on transfer_queue.storage.simple_storage so rolling-upgrade Ray peers unpickle and catch missing-key errors cleanly. - Remove top-level is_zmq_payload_request export in favor of ZmqPayloadTransfer.can_handle. - Make the concurrent parser metrics check deterministic by awaiting PUT and CLEAR before sampling active_keys while the GET parser remains blocked. Signed-off-by: 0oshowero0 <[email protected]>
- Remove PayloadClient and PayloadTransfer.connect() so each backend owns peer connection reuse, single-request cancellation isolation, and teardown in one layer; revert orphaned handshake drain in TransferQueueClient._start_loop - Introduce opaque PayloadPeerInfo so OmegaConf stores peer descriptors as atomic AnyNode objects without interpolation errors or verbose binary logs - Normalize _payload_peers once in AsyncSimpleStorageManager.__init__ and keep shared storage_rpc_pool teardown in AsyncSimpleStorageManager.close() Signed-off-by: 0oshowero0 <[email protected]>
…tries - Add DeliveryState (UNSENT, REJECTED, IN_DOUBT) and transient flag to TransferError so deterministic protocol/decode/config errors never retry large payloads or trigger misleading unit diagnostics - Prevent PUT retries once delivery enters IN_DOUBT so a committed write with a lost or corrupt ACK cannot overwrite a concurrent update - Decouple StorageUnitTimeout diagnosis from retry eligibility so non-retried PUT/UPDATE/parser timeouts still report TCP and probe verdicts Signed-off-by: 0oshowero0 <[email protected]>
- Add optional count_error predicate to TQMetricsExporter.measure (and IntervalPerfMonitor.measure) - Exempt StorageRejected(missing_key=True) from tq_storage_request_errors while keeping request count, latency histogram, and real storage error accounting intact Signed-off-by: 0oshowero0 <[email protected]>
…QError errnos - Align PayloadTransfer.shutdown() contract with AsyncTransferQueueClient.close() and re-check _closed after acquiring a pooled socket so queued PUTs never send after shutdown() - Replace ETERM blacklist with an explicit _TRANSIENT_ZMQ_ERRNOS whitelist so deterministic ZMQ errors such as EINVAL fail once without retries, and restrict _diagnose_storage_unit to StorageUnitTimeout Signed-off-by: 0oshowero0 <[email protected]>
- Extract TransferError, TransferTimeout, and StorageRejected into payload_transfer/errors.py, drop DeliveryState, and restore plain PUT timeout retries (PR Ascend#171) while keeping deterministic protocol/decode/config errors non-retryable - Flatten retry and error translation into AsyncSimpleStorageManager._request_payload, removing _request_with_retry, __cause__ unwrapping, _payload_closed, and unimplemented recv parameters - Fetch ZMQ and payload peer descriptors in a single batched get_bootstrap_info() RPC, initialize ZmqPayloadTransfer._handle, remove defensive getattr wrappers, and keep measure() signature pure Signed-off-by: 0oshowero0 <[email protected]>
…d inline storage callback - Exit ZMQSocketPool.alease cleanly when closed while queued (and on decoded unexpected responses) so queued PUT rejections do not churn healthy pooled sockets - Default _request_payload to Fail-Closed max_attempts=1 and merge TransferTimeout and TransferError into a single retry/logging flow - Fold handle_storage_request into SimpleStorageUnit._handle_payload with explicit _measure_payload_op accounting, and clarify listen()/shutdown() resource ownership Signed-off-by: 0oshowero0 <[email protected]>
…payload Signed-off-by: 0oshowero0 <[email protected]>
…porter.measure Signed-off-by: 0oshowero0 <[email protected]>
Summary
Introduce a pluggable
PayloadTransferdata-plane interface (listen,request,shutdown) forSimpleStorageand adapt the existing ZMQ backend (ZmqPayloadTransfer) to it, following the direction proposed in RFC #208.PUT,GET, andUPDATEnow shareawait transfer.request(peer_info, header, *, send=None) -> PayloadReply. Write requests pass unencoded field values insend, andGET(send=None) returns decoded field values inreply.payload. This preserves the existing zero-copy multipart codec path without introducing an extra encode/decode round trip.Each backend manages its own peer connection reuse, single-request cancellation isolation, and teardown in one layer (
ZMQSocketPoolfor ZMQ), while peer discovery descriptors are wrapped in an opaquePayloadPeerInfoobject (fetched alongside control-plane ZMQ info in a single batchedget_bootstrap_info()RPC at startup) so OmegaConf stores them without${...}interpolation or verbose binary descriptor logs.Changes
transfer_queue/storage/payload_transfer/):Operation(PUT,GET,UPDATE),PayloadPeerInfo,RequestHeader,PayloadReply, and the 3-methodPayloadTransferinterface inbase.py, clarifying owned vs. host-shared listener and pool lifecycles.errors.py:TransferError(message, *, transient=False),TransferTimeout(transient=True, wire_bytes=...), andStorageRejected(missing_key=...).ZmqPayloadTransferinzmq.py: deferZMQMessage.serialize()until after acquiring aZMQSocketPool.aleasepermit so queuedPUTcallers keep zero-copy views rather than materializing contiguous copies early; exit the lease cleanly when closed while queued so rejected queued writes do not churn healthy pooled sockets; and whitelist transient resource/syscallZMQErrorerrnos (_TRANSIENT_ZMQ_ERRNOS) so deterministic protocol, decode (ZMQMessageDecodeError), or endpoint configuration (EINVAL) errors fail immediately without retries.AsyncSimpleStorageManager):_payload_peersonce in__init__and consolidate retry handling and public exception translation into_request_payload(defaultingmax_attempts=1Fail-Closed forUPDATEand parser-backed operations, preservingTQ_SIMPLE_STORAGE_MAX_ATTEMPTStimeout recovery for plainGETandPUT, and running_diagnose_storage_unitonly onStorageUnitTimeout).SimpleStorageUnit,TQMetricsExporter,IntervalPerfMonitor):PUT,GET, andUPDATEexecution intoSimpleStorageUnit._handle_payloadwith fine-grained_storage_locksynchronization (PUT/GETdata_parsercallbacks run outside_storage_lock, whileUPDATEread-merge-write runs atomically under_storage_lock), thread-safeIntervalPerfMonitorlocking, and empty-frameZMQMessage.deserialize([])validation.count_errorpredicate support toTQMetricsExporter.measure()so expected concurrentclearvs.GETmissing-key races record request count and latency without inflatingtq_storage_request_errors, while genuine storage rejections increment error counters.transfer_queue/storage/exceptions.py):StorageKeyNotFoundErrortotransfer_queue.storage.exceptionswhile preservingStorageKeyNotFoundError.__module__ = "transfer_queue.storage.simple_storage"(for Ray worker/driver pickle compatibility) and[TQKeyNotFound]ZMQ wire-message compatibility in both directions.Validation
Automated unit, type, and sanity checks
test_zmq_payload_transfer.py,test_storage_request_retry.py,test_storage_key_race.py,test_async_simple_storage_manager.py,test_simple_storage_unit.py,test_simple_storage_scheduling.py,test_accept_probe.py,test_storage_worker_death_exits.py,test_metrics.py, andtest_data_dump.py, alongsidemypy,ruff, docstring, and license checks.maxsize=1pool;PUTwith a corrupt ACK failing once without replaying over a newer concurrent write;PUTs aborted aftershutdown()with zero extra writes and zero healthy-socket churn;port=-1,EINVAL) failing on the first attempt without retries or unit probing;PUT,CLEAR_DATA, andGET_METRICScompleting while a slowGETdata_parserruns unlocked;PayloadPeerInfopreserving unclosed${...}strings and summarizing binary descriptors in OmegaConf;[TQKeyNotFound]wire compatibility andStorageKeyNotFoundErrorpickle module path preservation.Cross-host fault injection
Cross-host fault injection passed in both directions between two Linux hosts, covering:
UPDATEapplied successfully with its reply deliberately dropped.GETrequests after faults with a pool capacity of one.The checks confirmed that failed sockets were discarded, late replies were isolated from subsequent requests, and the pool remained usable. The lost-reply
UPDATEwas applied once, reported a timeout, and its result was verified by subsequentGETrequests.Performance comparison
The dual-node comparison used identical benchmark code and configuration for
mainand this implementation.Positive values indicate higher latency. Median changes remained within −0.98% to +1.19% across the tested operations and workloads. The largest mean latency increase was 3.09% for mixed-field PUT.
No material end-to-end performance regression was observed in the tested dual-node configuration. These measurements describe the current network and workloads; large transfers are constrained by the 1 Gb/s link.