Skip to content

Commit

Permalink
perf: Coalesce better (#1594)
Browse files Browse the repository at this point in the history
* benchmarks for coalesce/mark_range

* benchmarks for coalesce/mark_range

* Make the exposure conditional, fmt

* Try to get something better im place

* Refactor bench

* Working much better now

* That was tricky

* Fix benches

* Some debug assertions and better comments

* Even better comments and such

* Remove redundant variable

* There is always just one contiguous acked range now

* Better function comments.

* Merge main

* Test thoroughly, guided by coverage

* Commentary

* Tweak commentary.

* Update Cargo.toml

* Revert this bit

* Rebase with upstream

* Removing redundant use statements

---------

Signed-off-by: Lars Eggert <lars@eggert.org>
Co-authored-by: Randell Jesup <rjesup@jesup.org>
Co-authored-by: Lars Eggert <lars@eggert.org>
  • Loading branch information
3 people authored Feb 8, 2024
1 parent b547c6f commit 90b718f
Show file tree
Hide file tree
Showing 3 changed files with 574 additions and 191 deletions.
14 changes: 7 additions & 7 deletions neqo-transport/benches/range_tracker.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use criterion::{criterion_group, criterion_main, Criterion}; // black_box
use neqo_transport::send_stream::{RangeState, RangeTracker};
use neqo_transport::send_stream::RangeTracker;

const CHUNK: u64 = 1000;
const END: u64 = 100_000;
fn build_coalesce(len: u64) -> RangeTracker {
let mut used = RangeTracker::default();
used.mark_range(0, CHUNK as usize, RangeState::Acked);
used.mark_range(CHUNK, END as usize, RangeState::Sent);
used.mark_acked(0, CHUNK as usize);
used.mark_sent(CHUNK, END as usize);
// leave a gap or it will coalesce here
for i in 2..=len {
// These do not get immediately coalesced when marking since they're not at the end or start
used.mark_range(i * CHUNK, CHUNK as usize, RangeState::Acked);
used.mark_acked(i * CHUNK, CHUNK as usize);
}
used
}
Expand All @@ -22,10 +22,10 @@ fn coalesce(c: &mut Criterion, count: u64) {
b.iter_batched_ref(
|| build_coalesce(count),
|used| {
used.mark_range(CHUNK, CHUNK as usize, RangeState::Acked);
used.mark_acked(CHUNK, CHUNK as usize);
let tail = (count + 1) * CHUNK;
used.mark_range(tail, CHUNK as usize, RangeState::Sent);
used.mark_range(tail, CHUNK as usize, RangeState::Acked);
used.mark_sent(tail, CHUNK as usize);
used.mark_acked(tail, CHUNK as usize);
},
criterion::BatchSize::SmallInput,
)
Expand Down
2 changes: 2 additions & 0 deletions neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ use crate::{
version::{Version, WireVersion},
AppError, ConnectionError, Error, Res, StreamId,
};

mod dump;
mod idle;
pub mod params;
mod saved;
mod state;
#[cfg(test)]
pub mod test_internal;

use dump::dump_packet;
use idle::IdleTimeout;
pub use params::ConnectionParameters;
Expand Down
Loading

0 comments on commit 90b718f

Please sign in to comment.