-
Notifications
You must be signed in to change notification settings - Fork 451
Fix CPU spike caused by hanging connection after socket closure (#8806) #8810
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thanks for opening this pull request.
Because this is your first time contributing to this repository, make sure you've read our Contributor Guide and Code of Conduct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the contribution! However, I don't think that's the correct fix: Instead of making broadcast_thread_func
a "slow busyloop", stop_listener
should wakeup the broadcast thread by hanging up the ReceiveSet
after setting the shutdown flag. ReceiveSet::recv
method is documented to return if the set is empty, so calling clear
on it after setting the shutdown flag should hopefully do it.
Edit: clear
won't work, that just gets stuck in a lock. Needs some more prodding on how a ReceiveSet
can be woken up, might be that we need to send a poisoned message of sort
That actually also sounds a bug in |
Makes sense, I checked the EDIT: On second look, that might not be the desired behavior |
The issue was due to these lines; if let Ok(msg) = oper.recv(&rx[index].rx) {
return Ok(msg);
} It starts returning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch, thank you so much. I agree, that makes more sense now
After the `RerunServer` shuts down, the `broadcast_thread_func` in `crates/store/re_ws_comms/src/server.rs#342` could not terminate due to the `log_rx.recv` (ReceiveSet) function entering an infinite loop while attempting to receive data.
Hmm strange, not seeing a report from the Rust CI. Maybe something is slightly broken in the gh workflows for non-maintainer contributions. Ah well, |
After the
RerunServer
shuts down, thebroadcast_thread_func
incrates/store/re_ws_comms/src/server.rs
could not terminate due to thelog_rx.recv
function entering an infinite loop while attempting to receive data.To resolve this,
recv
has been replaced withrecv_timeout
, allowing the thread to properly shut down and preventing excessive CPU usage.Related
serve_web
followed bydisconnect
outside of main thread causes 100% CPU usage #8806