-
Notifications
You must be signed in to change notification settings - Fork 758
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 optional qlogging to quiche #379
Conversation
b02d0de
to
7b0fbb2
Compare
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.
Haven't really finished reviewing the whole thing, but I think there are enough comments for now (mostly about code structure, though we might need to tweak the public API a bit).
@@ -244,7 +244,8 @@ mod tests { | |||
fn insert_non_overlapping() { | |||
let mut r = RangeSet::default(); | |||
assert_eq!(r.inner.len(), 0); | |||
assert_eq!(&r.flatten().collect::<Vec<u64>>(), &[]); |
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.
These changes look pretty suspicious TBH. Like, why are they needed in this branch but not master given that there are no other changes to this file?
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 don't know!!! (but in seriousness I agree, so let's see if I can bisect the root cause)
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.
caused by serde_json. Even though only qlog imports that crate, it seems to leak into the quiche library
cd271d0
to
4a87e28
Compare
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 didn't quite look at the qlog
code before, which I just did and added a few comments.
The quiche code itself looks mostly good now though. just a few small things remaining.
tools/qlog/src/lib.rs
Outdated
// trace, which might be undesirable. | ||
match serde_json::to_string(&self.qlog) { | ||
Ok(mut out) => { | ||
if let Some(index) = out.find("\"events\":[") { |
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 there no better way to do this? Maybe defining the Serialize
trait manually for these types rather than deriving one automatically?
At the very least we should probably avoid scanning the whole string for the specific substring. If I understand it correctly this string would always be at the end of the output, so maybe we can just match the suffix itself directly?
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.
So far with these changes, they allow both a buffered and a streaming mode of using the qlog crate. Modifying Serialize risks breaking that. Furthermore, the generated serialization code for Trace
is 150 lines of code, maintaining a manual equivalent code is a bit brittle.
Reverse-scanning is going to be an improvement. Additionally, if it scans for end of the array, it can avoid blatting over any existing events, which is a problem highlighted in the TODO.
@@ -139,6 +139,21 @@ fn main() { | |||
let mut conn = | |||
quiche::connect(connect_url.domain(), &scid, &mut config).unwrap(); | |||
|
|||
// Only bother with qlog if the user specified it. | |||
#[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.
FTR, rust-lang/rust#69201 will be in Rust 1.43, so we can probably simplify this a bit in the future.
888ac84
to
26dc338
Compare
Okay... I've addressed a lot of the feedback comments, thanks! This is now ready for another review. In the meantime I'll start on updating the qlog documentation ready to publish the new v0.2 of the crate before this PR lands. |
Docs updated and comments addressed, PTAL |
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.
🚢
@LPardue looks like this needs to be rebased on master as there is a conflict. While you are at it, can you also submit the new |
Previously, qlog API was designed to operate in a buffered mode. This required users to create a trace and hold it in memory, append events to it, and at the end serialize the whole thing. This change adds a streaming mode API that serializes qlog events immediately to a `Write` trait. A few quality-of-life changes have also been made.
This change introduces qlog support into the quiche library as a new optional feature that is disabled by default. qlog occurs in addition to conventional Rust logging. To build quiche with qlog support do: cargo build --features qlog Rust applications can enable qlog on a per-connection basis via the `set_qlog()` method. C applications can use `quiche_conn_set_qlog_fd()`. Once qlog is enabled, qlog events are seralized in a streaming fashion to the target Write trait or file descriptor.
This is still WIP but ready for review. I need to add tests for the new capability but will await design feedback.
The PR contains 2 commits, the older one uses a buffered serialization approach, the newer one replaces this with a streaming serialized approach. I left these so that we could compare the two, but we'd definitely squash this down before any merge.
To test this out, you can run quiche-client or quiche-server with the
QLOGDIR
environment pointing at a folder. The resulting trace will be written to a file such asclient-{scid}.qlog
which can then be imported to the visualization tool https://qvis.edm.uhasselt.be.