Move Ascend P2P by keeping outbound P2P socket operations on the dedicated Ascend P2P event loop.#234
Merged
Merged
Conversation
Collaborator
Author
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements event loop marshaling for Ascend-specific LMCache components to ensure ZMQ socket operations are executed on their designated event loops, preventing thread-safety issues. Key updates include patching the LMCacheWorker to handle cross-loop requests, introducing a mechanism in the P2P backend to marshal operations to its internal loop, and adding per-peer handshake locks in the HCCL channel. Review feedback recommends enhancing robustness by handling asyncio.CancelledError to maintain ZMQ socket state, replacing a busy-wait polling loop with an asyncio.Event, and using an initialization helper instead of a potentially crashing assertion.
chloroethylene
approved these changes
May 18, 2026
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.

Changes
flowchart LR subgraph ownership["Socket / I/O ownership"] A["req_socket"] --> B["must run on worker.loop"] C["P2P peer + transfer ZMQ"] --> D["must run on AscendP2PBackend.loop"] E["prefetch orchestration"] --> F["runs on StorageManager.loop"] endsequenceDiagram participant SL as StorageManager.loop participant BE as Backend coroutine<br/>(e.g. AscendP2PBackend) participant PL as AscendP2PBackend.loop participant WL as worker.loop SL->>BE: await batched_async_contains / batched_get_non_blocking alt Ascend P2P needs P2P-only I/O BE->>PL: run_coroutine_threadsafe(_run_on_p2p_loop coro) PL-->>BE: result via Future → wrap_future end opt Needs controller via worker req_socket BE->>WL: async_put_and_wait_msg → run_coroutine_threadsafe(...) WL-->>BE: result via wrap_future + wait_for end BE-->>SL: return to prefetch taskWhy