-
Notifications
You must be signed in to change notification settings - Fork 39
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
Use a single queue for message threads instead of round-robin #93
Comments
I'm thinking out loud, I hope you don't mind :) I may not do anything about this, but I write all this to share what I learned. Also I looked at the code of janus-conference, they went full async with the async_std crate. In the I looked at the code of async_std and the dependencies, behind the scene it creates In the end, the difference is between the channel type that is used to communicate with the threads, if it's a sync channel or not, if there is a mutex involved in the channel receiver in the case we use a single channel for all threads, and if there is a queue for each thread. |
Interesting article about a bottleneck with Arc: https://pkolaczk.github.io/server-slower-than-a-laptop/ Alternative to async_std is tokio that seems popular these days. If we want better perf (this needs to be measured) with little change of the code, we can maybe change the sync channel used by the threads, switch from std::sync::mpsc to crossbeam::channel. I found that while reading https://tokio.rs/tokio/tutorial/channels |
Another thing I noted some months ago in my todo list when I read the janus-conference code is they're using an alternate hash function for all the |
I finished reading the Rust book! While reading the book I read again the code in janus-plugin-sfu and in janus-plugin-rs where you handle all the Rust - C/C++ conversion and incr/decr refcount for session/jansson/libcstring, I understand it all now, wow, beautiful :)
The last chapter Final Project: Building a Multithreaded Web Server is really interesting.
In the janus-plugin-sfu current implementation for message threads, we use a simple round-robin and a sender/receiver channel for each thread, relevant code here
janus-plugin-sfu/src/lib.rs
Lines 274 to 282 in ef815ec
and here
janus-plugin-sfu/src/lib.rs
Lines 775 to 778 in ef815ec
While reading the chapter and the current janus-plugin-sfu code, I reached the same conclusion as
you wrote in #49 (comment)
If you're using the websocket transport in naf-janus-adapter you can indeed have lots of quick messages for
process_data
. Hubs didn't use this transport, so janus handled sdp offer/answer primarily.In the Rust book chapter they use a single sender/receiver, and use an
Arc<Mutex<receiver>>
to really have a single queue of messages, full code at the end of the chapterI may propose a PR to change the implementation to that, it will be a good exercise.
The text was updated successfully, but these errors were encountered: