Skip to content
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

Merged
merged 2 commits into from
Mar 26, 2020
Merged

add optional qlogging to quiche #379

merged 2 commits into from
Mar 26, 2020

Conversation

LPardue
Copy link
Contributor

@LPardue LPardue commented Feb 26, 2020

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 as client-{scid}.qlog which can then be imported to the visualization tool https://qvis.edm.uhasselt.be.

@LPardue LPardue requested a review from a team as a code owner February 26, 2020 15:50
@LPardue LPardue force-pushed the quiche-qlog branch 8 times, most recently from b02d0de to 7b0fbb2 Compare March 11, 2020 12:16
Copy link
Member

@ghedo ghedo left a 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).

include/quiche.h Outdated Show resolved Hide resolved
include/quiche.h Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@@ -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>>(), &[]);
Copy link
Member

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?

Copy link
Contributor Author

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)

Copy link
Contributor Author

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

src/frame.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@LPardue LPardue force-pushed the quiche-qlog branch 3 times, most recently from cd271d0 to 4a87e28 Compare March 16, 2020 13:20
Copy link
Member

@ghedo ghedo left a 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.

// trace, which might be undesirable.
match serde_json::to_string(&self.qlog) {
Ok(mut out) => {
if let Some(index) = out.find("\"events\":[") {
Copy link
Member

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?

Copy link
Contributor Author

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.

tools/qlog/src/lib.rs Outdated Show resolved Hide resolved
tools/qlog/src/lib.rs Outdated Show resolved Hide resolved
@@ -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")]
Copy link
Member

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.

tools/apps/src/bin/quiche-server.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/recovery.rs Outdated Show resolved Hide resolved
tools/apps/Cargo.toml Outdated Show resolved Hide resolved
tools/qlog/src/lib.rs Outdated Show resolved Hide resolved
tools/qlog/src/lib.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
src/ffi.rs Show resolved Hide resolved
src/frame.rs Outdated Show resolved Hide resolved
src/frame.rs Outdated Show resolved Hide resolved
tools/apps/Cargo.toml Outdated Show resolved Hide resolved
tools/apps/src/lib.rs Outdated Show resolved Hide resolved
src/ffi.rs Outdated Show resolved Hide resolved
@LPardue LPardue force-pushed the quiche-qlog branch 2 times, most recently from 888ac84 to 26dc338 Compare March 20, 2020 18:58
@LPardue
Copy link
Contributor Author

LPardue commented Mar 20, 2020

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.

@LPardue LPardue changed the title WIP: add optional qlogging to quiche add optional qlogging to quiche Mar 24, 2020
@LPardue
Copy link
Contributor Author

LPardue commented Mar 24, 2020

Docs updated and comments addressed, PTAL

junhochoi
junhochoi previously approved these changes Mar 24, 2020
Copy link
Contributor

@junhochoi junhochoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@ghedo
Copy link
Member

ghedo commented Mar 26, 2020

@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 qlog crate to crates.io and squash the commits in the PR? So we can finally merge this.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants