-
Notifications
You must be signed in to change notification settings - Fork 2
Presist logging across reconnect [CPP-383] #215
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
we were just storing the name here but that's redundent because we store the connection itself
console_backend/src/shared_state.rs
Outdated
use indexmap::IndexMap; | ||
use lazy_static::lazy_static; | ||
use log::error; | ||
use parking_lot::{MappedMutexGuard, Mutex, MutexGuard}; |
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.
A lot of the changes are switching the mutex to a parking lot mutex. I needed to use MappedMutexGuard
and there is no equivalent for the std mutex.
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.
Wow MappedMutexGuard
is a pretty cool idea and beyond perfect for what we are doing. We might want to eventually move all use of shared_state to this approach. Possibly improve performance especially for things that touch shared_state on every new sbp message.
} | ||
} | ||
|
||
#[derive(Debug)] |
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.
We already store the the current connection in shared_state, so to get the name you just get it and call .name()
on it
console_backend/src/shared_state.rs
Outdated
LoggingBarState { | ||
sbp_logging: false, | ||
sbp_logging_format: SbpLogging::SBP_JSON, | ||
sbp_logger: None, |
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.
Moves the logger into shared_state so it sticks around even when Tabs
is dropped
|
||
pub trait ClientSender: ClientSenderClone { | ||
fn send_data(&mut self, msg_bytes: Vec<u8>); | ||
fn send_data(&self, msg_bytes: Vec<u8>); |
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.
The main ClientSender
we use (the channel based one) doesn't actually need a mutable receiver. Immutable receivers are a bit more ergonomic, and allows us to avoid a few clones.
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.
In the future, I think it would be cool if we added storage to the clientsender similar to how the TestSender is a vec and then have a function for just grabbing the last vec sent. Could be a way to make more thorough integration tests. I created a ticket for it:
https://swift-nav.atlassian.net/browse/CPP-412
578e768
to
2817139
Compare
console_backend/src/shared_state.rs
Outdated
use indexmap::IndexMap; | ||
use lazy_static::lazy_static; | ||
use log::error; | ||
use parking_lot::{MappedMutexGuard, Mutex, MutexGuard}; |
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.
Wow MappedMutexGuard
is a pretty cool idea and beyond perfect for what we are doing. We might want to eventually move all use of shared_state to this approach. Possibly improve performance especially for things that touch shared_state on every new sbp message.
Yeah definitely super cool. I think I nice way to refactor everything would be to make all the fields of R.e. performance, I think there could be a pretty big/easy win by using finer grained locks with pub struct SharedState(Arc<SharedStateInner>);
struct SharedStateInner {
logging_bar: Mutex<LoggingBarState>,
log_panel: Mutex<LogPanelState>,
tracking_tab: Mutex<TrackingTabState>,
...
} That way when we have multiple threads accessing different parts of |
Sounds good to me. I could definitely see a gain from that. I created a ticket for this suggestion: https://swift-nav.atlassian.net/browse/CPP-413 |
Initial plan was to persist the
Tabs
across reconnections. That ended up being really hard to do and I burned a bunch of time on that. Found an easier way to solve to problem though. I included a few changes that I made to try and get theTabs
to stick around between reconnections, because I think they are still generally usefulCurrently the timer that tracks how long the log has been going for will still increment during a disconnect (size doesn't obviously because there are no messages). I assume this is ok, but probably could figure out a way around that if need be