Skip to content

Conversation

@zuston
Copy link
Contributor

@zuston zuston commented Oct 17, 2025

No description provided.

@zuston zuston marked this pull request as draft October 17, 2025 09:42
@zuston
Copy link
Contributor Author

zuston commented Oct 17, 2025

Still in a early stage, could you help take a look? @bigbigxu

@bigbigxu
Copy link
Contributor

bigbigxu commented Nov 19, 2025

This solution has the following two issues:

  1. Async Runtime Deadlock Risk
    Using block_on in the code is unsafe and may cause deadlocks:
    if let Some(write_pipeline) = self.write_pipeline.as_mut() { tokio::runtime::Handle::current() .block_on(async { write_pipeline.write(msg.data.clone()).await })?;}
    Problem Analysis:
    Calling block_on within a Tokio async context blocks the current thread
    If the current thread is a Tokio worker thread, this will cause runtime deadlock
    Violates Tokio's async execution model
    Recommended Solutions:
    Use tokio::spawn to create independent tasks
    Or use async channels (e.g., tokio::sync::mpsc) to send write tasks to a dedicated thread
  2. Synchronous Writes Cause Performance Bottleneck
    The current writer uses synchronous blocking mode, where each write operation blocks until completion, severely impacting throughput.
    Recommended Optimization:
    Implement a Buffering + ACK Mechanism:
    Buffering: Allow multiple write requests to proceed concurrently without waiting for previous ones to complete (non-blocking mode)
    ACK Mechanism: Asynchronously acknowledge write results to detect and handle errors promptly
    Performance Gain: Dramatically improve write throughput through pipelining

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