-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests & more #34
Add tests & more #34
Conversation
Hi, Thank you for your contribution! I will review this ASAP. |
I think your code could cause race conditions in this part of the code because it does not clone the parked thread before changing its value. As
|
You're right. I'll revert that commit tomorrow.
Think about a high contention scenario, multiple threads are contending for one mutex. As the spin time increases, there's more chance that some thread else gets the lock before its next spin. Practically this rarely happens though, I suppose.
I know, but signal is also stored on the stack, isn't it? It's still a stack-to-stack copy. I'm experimenting with some of the ideas I mentioned above. If I get any progress, I'll send you a PR. :) |
Try changing and experimenting with it, but in my experience putting it outside of the signal helps the compiler generate a more optimized code as it doesn't need to extract the struct field from the signal structure. |
Sounds fair.
It's ready. |
It turns out that MCS lock isn't applicable here. Since senders/receivers are |
Thank you for your contribution |
I'm auditing Kanal. Till now I've looked through most of the blocking implementation except oneshot. Here's some feedback:
VecDeque
can cause high latency and memory peak when resizing. Some async tasks are sensitive to latency. Both tokio and monoio utilize block lists to implement their channels. In addition, this design might enable some lock-free operations.signal.rs
generally looks good to me. But auditing atomics is really hard. Maybe you can use https://github.com/tokio-rs/loom to do some tests.std::ptr::{read, write, copy_nonoverlapping}
.chan_state
branch. The code is a bit messy and the benchmark result doesn't seem good.send_option_timeout
&try_send_option
.KanalPointer
is entirely redundant. Why don't you directly store the final buffer inSignal
, i.e.,signal_terminator -> signal.buffer
rather thansignal_terminator -> signal.ptr -> buffer
?