-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Expand qlog support #181
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
base: protocol-simplification
Are you sure you want to change the base?
Conversation
feat: add ConnectionStarted to qlog feat: track received packets in qlog fix: cid groups, padding size, cleanups fixup vantage_point method signature chore: clippy
70cd464 to
b9e83dc
Compare
flub
left a comment
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.
Generally looks great, but let's add good doc comments. Even for internal APIs.
The other main comment is that the qlog module is cfg-disabling all the bodies of functions so that the callsites don't have to have cfg everywhere. I think you should continue that style for the newly added methods. That would get rid of a lot of cfg lines.
| use std::net::{IpAddr, SocketAddr}; | ||
| #[cfg(feature = "qlog")] | ||
| use std::sync::{Arc, 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.
stdlib imports should be before 3rd party crates, no?
| #[cfg(feature = "qlog")] | ||
| impl QlogStream { | ||
| fn emit_event(&self, orig_rem_cid: ConnectionId, event: EventData, now: Instant) { | ||
| fn emit_event(&self, initial_dst_cid: ConnectionId, event: EventData, now: Instant) { |
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.
that is so much a better variable name for this
| ) { | ||
| #[cfg(feature = "qlog")] | ||
| { | ||
| use qlog::events::connectivity::ConnectionStarted; |
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.
Why is this not in the import block at the top of the file?
| let Some(stream) = self.stream.as_ref() else { | ||
| return; | ||
| }; | ||
| // TODO: Review fields. The standard has changed since. |
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.
Is it possible to say which draft the fields used here are in the comment? That would probably help the future.
| ..Default::default() | ||
| }; | ||
| #[derive(Default)] | ||
| pub(crate) struct QlogSentPacket { |
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.
Maybe add a doc comment that this is intentionally a noop struct if the cfg is disabled, and that the expectation is that the compiler completely removes it from function call parameters. Preferably somehow all on the first line so that IDEs show it nicely :)
| stream.emit_event(orig_rem_cid, EventData::PacketReceived(event), now); | ||
| #[cfg(feature = "qlog")] | ||
| impl QlogSentPacket { | ||
| pub(crate) fn header( |
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.
I know these are all internal APIs. But I love doc comments for internal stuff too.
| } | ||
|
|
||
| stream.emit_event(orig_rem_cid, EventData::PacketReceived(event), now); | ||
| #[cfg(feature = "qlog")] |
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.
I think the philosophy of this module is to keep all/most the cfgs inside the function bodies. That way the call sites are not littered with cfgs. And the compiler is expected to optimise out the noop function calls. So you probably should follow the same pattern for these new impls?
Expand qlog support:
Based on #177 because iroh feat-multipath is now based on that. Failures/lints are on
protocol-simplications- will rebase as soon as that branch becomes green.