Performance Improvements and Refactoring: Replace flume with crossbeam SegQueue - #376
Performance Improvements and Refactoring: Replace flume with crossbeam SegQueue#376fereidani wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR aims to improve performance by removing heap allocations in the iouring driver and replacing the flume channel with crossbeam_queue::SegQueue for better lock-free performance under high contention. However, there are critical memory safety issues that must be addressed before merging.
Key Changes:
- Replace
flumechannel withcrossbeam_queue::SegQueuefor cross-thread waker communication - Attempt to eliminate heap allocations in iouring driver by replacing
Box::leakwithUnsafeCellfields - Update naming from
waker_sendertowaker_queuethroughout the codebase
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| monoio/tests/tcp_connect.rs | Removes unused LazyLock import |
| monoio/src/utils/ctrlc.rs | Changes memory deallocation from Box::from_raw to drop_in_place (introduces memory leak) |
| monoio/src/runtime.rs | Replaces flume Sender with Arc in waker cache |
| monoio/src/driver/uring/mod.rs | Replaces Box::leak allocations with UnsafeCell fields and switches to SegQueue (introduces critical memory safety bug) |
| monoio/src/driver/thread.rs | Updates global registry functions to use SegQueue instead of flume Sender |
| monoio/src/driver/legacy/mod.rs | Updates legacy driver to use SegQueue instead of flume |
| monoio/Cargo.toml | Removes flume dependency and adds crossbeam-queue |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ling in legacy and uring drivers
|
Thanks for the improvement! |
Hi,
This PR improves performance in various parts of the code and includes some refactoring.
Main changes are:
In the iouring driver, I removed two heap allocations, which simplifies the implementation and should slightly improve performance.(will send it in separate PR with correct Pin usage)