Skip to content

Commit

Permalink
chore: Cleanups for write_appdata_frames (#1440)
Browse files Browse the repository at this point in the history
* Change priority of datagrams to be below critical & high, but ahead of Normal streams

* lint

* Fix runtime borrow issue, add builder check

* Add support for configuring greasing

* push datagrams below normal

* Remove accidental code from greasing

* remove accidental added file

* undo test changes

* Minimze diff and add comment

* Address code review

---------

Co-authored-by: Lars Eggert <[email protected]>
  • Loading branch information
jesup and larseggert authored Apr 16, 2024
1 parent 3012f72 commit f88b862
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1938,42 +1938,34 @@ impl Connection {
}
}

self.streams
.write_frames(TransmissionPriority::Critical, builder, tokens, frame_stats);
if builder.is_full() {
return;
}

self.streams.write_frames(
for prio in [
TransmissionPriority::Critical,
TransmissionPriority::Important,
builder,
tokens,
frame_stats,
);
if builder.is_full() {
return;
] {
self.streams
.write_frames(prio, builder, tokens, frame_stats);
if builder.is_full() {
return;
}
}

// NEW_CONNECTION_ID, RETIRE_CONNECTION_ID, and ACK_FREQUENCY.
self.cid_manager.write_frames(builder, tokens, frame_stats);
if builder.is_full() {
return;
}
self.paths.write_frames(builder, tokens, frame_stats);
if builder.is_full() {
return;
}

self.streams
.write_frames(TransmissionPriority::High, builder, tokens, frame_stats);
self.paths.write_frames(builder, tokens, frame_stats);
if builder.is_full() {
return;
}

self.streams
.write_frames(TransmissionPriority::Normal, builder, tokens, frame_stats);
if builder.is_full() {
return;
for prio in [TransmissionPriority::High, TransmissionPriority::Normal] {
self.streams
.write_frames(prio, builder, tokens, &mut stats.frame_tx);
if builder.is_full() {
return;
}
}

// Datagrams are best-effort and unreliable. Let streams starve them for now.
Expand All @@ -1982,9 +1974,9 @@ impl Connection {
return;
}

let frame_stats = &mut stats.frame_tx;
// CRYPTO here only includes NewSessionTicket, plus NEW_TOKEN.
// Both of these are only used for resumption and so can be relatively low priority.
let frame_stats = &mut stats.frame_tx;
self.crypto.write_frame(
PacketNumberSpace::ApplicationData,
builder,
Expand All @@ -1994,6 +1986,7 @@ impl Connection {
if builder.is_full() {
return;
}

self.new_token.write_frames(builder, tokens, frame_stats);
if builder.is_full() {
return;
Expand All @@ -2003,10 +1996,8 @@ impl Connection {
.write_frames(TransmissionPriority::Low, builder, tokens, frame_stats);

#[cfg(test)]
{
if let Some(w) = &mut self.test_frame_writer {
w.write_frames(builder);
}
if let Some(w) = &mut self.test_frame_writer {
w.write_frames(builder);
}
}

Expand Down

0 comments on commit f88b862

Please sign in to comment.