Skip to content

test(transport): assert maximum bandwidth on gbit link - #2203

Closed
mxinden wants to merge 1 commit into
mozilla:mainfrom
mxinden:1-gbit-s
Closed

mxinden wants to merge 1 commit into
mozilla:mainfrom
mxinden:1-gbit-s

Conversation

@mxinden

@mxinden mxinden commented Oct 26, 2024

Copy link
Copy Markdown
Member

This commit adds a basic smoke test using the test-fixture simulator, asserting the expected bandwidth on a 1 gbit link.

Given #733, the current expected bandwidth is limited by the fixed sized stream receive buffer (1MiB), not by the bandwidth of the link.

While a bit unconventional, I think it is worth having this smoke test, to make sure we don't regress. What do folks think?

This commit adds a basic smoke test using the `test-fixture` simulator,
asserting the expected bandwidth on a 1 gbit link.

Given mozilla#733, the current expected bandwidth
is limited by the fixed sized stream receive buffer (1MiB).
#[allow(clippy::cast_precision_loss)]
fn gbit_bandwidth() {
const MIB: usize = 1024 * 1024;
const TRANSFER_AMOUNT: usize = 100 * MIB;

@mxinden mxinden Oct 26, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Takes ~2s to run on my machine, 1s for up-, 1s for download. Using < 100 MIB doesn't give me consistent results.

Worth spending 2s of our unit-test runtime on this?

(Not to be confused with simulated time.)

//
// Tracked in https://github.com/mozilla/neqo/issues/733.
let maximum_bandwidth = MIB as f64 * 8.0 / 0.1; // bandwidth-delay-product / delay = bandwidth
let expected_utilization = 0.5;

@mxinden mxinden Oct 26, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Running this test in a loop, Neqo is not able to utilize more than ~50% of the maximum bandwidth of 80 Mbit/s. Intuitively, even with packet loss, I would expect a congestion controller to be able to saturate more than 50% of a link.

45.95196838717057
49.31818797697269
45.826026606578566
49.53933723888579
45.997472274917506
49.31788343565587
45.58981370339061
49.31818797697269
40.48485804428038
49.451830153095756
40.5585726298109
49.31793477754305
40.55224164532084
54.71429614593755
45.57110592947965
49.45192167242847
40.53596208031323
54.79092558021697
45.95144831798395

I will look for mistakes in my math with a fresh mind tomorrow.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this using Reno or Cubic? Pacing or not?

pub const fn gbit_link() -> Self {
let rate = 1_000_000_000 / 8;
let delay = Duration::from_millis(50);
let capacity = rate / 20; // rate * 0.05

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Simply the bandwidth-delay-product. Happy for more realistic suggestions.

@github-actions

Copy link
Copy Markdown
Contributor

Failed Interop Tests

QUIC Interop Runner, client vs. server

neqo-latest as client

neqo-latest as server

All results

Succeeded Interop Tests

QUIC Interop Runner, client vs. server

neqo-latest as client

neqo-latest as server

Unsupported Interop Tests

QUIC Interop Runner, client vs. server

neqo-latest as client

neqo-latest as server

mxinden added a commit to mxinden/neqo that referenced this pull request Dec 2, 2024
A `Node` (e.g. a `Client`, `Server` or `TailDrop` router) can be in 3 states:

``` rust
enum NodeState {
    /// The node just produced a datagram.  It should be activated again as soon as possible.
    Active,
    /// The node is waiting.
    Waiting(Instant),
    /// The node became idle.
    Idle,
}
```

`NodeHolder::ready()` determines whether a `Node` is ready to be processed
again. When `NodeState::Waiting`, it should only be ready when `t <= now`, i.e.
the waiting time has passed, not `t >= now`.

``` rust
impl NodeHolder {
    fn ready(&self, now: Instant) -> bool {
        match self.state {
            Active => true,
            Waiting(t) => t <= now, // not >=
            Idle => false,
        }
    }
}
```

The previous behavior lead to wastefull non-ready `Node`s being processed and
thus a large test runtime when e.g. simulating a gbit
connection (mozilla#2203).
mxinden added a commit to mxinden/neqo that referenced this pull request Dec 2, 2024
A `Node` (e.g. a `Client`, `Server` or `TailDrop` router) can be in 3 states:

``` rust
enum NodeState {
    /// The node just produced a datagram.  It should be activated again as soon as possible.
    Active,
    /// The node is waiting.
    Waiting(Instant),
    /// The node became idle.
    Idle,
}
```

`NodeHolder::ready()` determines whether a `Node` is ready to be processed
again. When `NodeState::Waiting`, it should only be ready when `t <= now`, i.e.
the waiting time has passed, not `t >= now`.

``` rust
impl NodeHolder {
    fn ready(&self, now: Instant) -> bool {
        match self.state {
            Active => true,
            Waiting(t) => t <= now, // not >=
            Idle => false,
        }
    }
}
```

The previous behavior lead to wastefull non-ready `Node`s being processed and
thus a large test runtime when e.g. simulating a gbit
connection (mozilla#2203).
mxinden added a commit to mxinden/neqo that referenced this pull request Dec 2, 2024
A `Node` (e.g. a `Client`, `Server` or `TailDrop` router) can be in 3 states:

``` rust
enum NodeState {
    /// The node just produced a datagram.  It should be activated again as soon as possible.
    Active,
    /// The node is waiting.
    Waiting(Instant),
    /// The node became idle.
    Idle,
}
```

`NodeHolder::ready()` determines whether a `Node` is ready to be processed
again. When `NodeState::Waiting`, it should only be ready when `t <= now`, i.e.
the waiting time has passed, not `t >= now`.

``` rust
impl NodeHolder {
    fn ready(&self, now: Instant) -> bool {
        match self.state {
            Active => true,
            Waiting(t) => t <= now, // not >=
            Idle => false,
        }
    }
}
```

The previous behavior lead to wastefull non-ready `Node`s being processed and
thus a large test runtime when e.g. simulating a gbit
connection (mozilla#2203).
github-merge-queue Bot pushed a commit that referenced this pull request Dec 8, 2024
…#2263)

A `Node` (e.g. a `Client`, `Server` or `TailDrop` router) can be in 3 states:

``` rust
enum NodeState {
    /// The node just produced a datagram.  It should be activated again as soon as possible.
    Active,
    /// The node is waiting.
    Waiting(Instant),
    /// The node became idle.
    Idle,
}
```

`NodeHolder::ready()` determines whether a `Node` is ready to be processed
again. When `NodeState::Waiting`, it should only be ready when `t <= now`, i.e.
the waiting time has passed, not `t >= now`.

``` rust
impl NodeHolder {
    fn ready(&self, now: Instant) -> bool {
        match self.state {
            Active => true,
            Waiting(t) => t <= now, // not >=
            Idle => false,
        }
    }
}
```

The previous behavior lead to wastefull non-ready `Node`s being processed and
thus a large test runtime when e.g. simulating a gbit
connection (#2203).
@mxinden

mxinden commented Jan 5, 2025

Copy link
Copy Markdown
Member Author

Closing here in favor of the benchmark added in #1868.

@mxinden mxinden closed this Jan 5, 2025
larseggert added a commit that referenced this pull request Mar 31, 2025
* test(transport): maximum throughput on unlimited bandwidth and 50ms

This commit adds a basic smoke test using the `test-ficture` simulator,
asserting that on a connection with unlimited bandwidth and 50ms round-trip-time
Neqo can eventually achieve > 1 Gbit/s throughput.

Showcases the potential a future stream flow-control auto-tuning algorithm can have.

See #733.

* feat: auto-tune stream receive window

Previously the stream send and receive window had a hard limit at 1MB. On high
latency and/or high bandwidth connections, 1 MB is not enough to exhaust the
available bandwidth.

Sample scenario:

```
delay_s = 0.05
window_bits = 1 * 1024 * 1024 * 8
bandwidth_bits_s = window_bits / delay_s
bandwidth_mbits_s = bandwidth_bits_s / 1024 / 1024 # 160.0
```

In other words, on a 50 ms connection a 1 MB window can at most achieve 160
Mbit/s.

This commit introduces an auto-tuning algorithm for the stream receive window,
increasing the window towards the bandwidth-delay product of the connection.

* clippy

* fix tests

* Don't increase on STREAM_DATA_BLOCKED

* enforce STREAM_MAX_ACTIVE_LIMIT

* add TODO starting below 1MiB

* Add NonRandomDelay

* Reduce transfer amount and throughput expectation

* test(transport): assert maximum bandwidth on gbit link

This commit adds a basic smoke test using the `test-fixture` simulator,
asserting the expected bandwidth on a 1 gbit link.

Given #733, the current expected bandwidth
is limited by the fixed sized stream receive buffer (1MiB).

* debugging

* deduplicate in fc.rs

* Google vs Thomson vs BDP

* More testing

* Adjust bench

* Move to benchmark

* fix(sim): correct `Waiting` state comparison in `NodeHolder::ready()`

A `Node` (e.g. a `Client`, `Server` or `TailDrop` router) can be in 3 states:

``` rust
enum NodeState {
    /// The node just produced a datagram.  It should be activated again as soon as possible.
    Active,
    /// The node is waiting.
    Waiting(Instant),
    /// The node became idle.
    Idle,
}
```

`NodeHolder::ready()` determines whether a `Node` is ready to be processed
again. When `NodeState::Waiting`, it should only be ready when `t <= now`, i.e.
the waiting time has passed, not `t >= now`.

``` rust
impl NodeHolder {
    fn ready(&self, now: Instant) -> bool {
        match self.state {
            Active => true,
            Waiting(t) => t <= now, // not >=
            Idle => false,
        }
    }
}
```

The previous behavior lead to wastefull non-ready `Node`s being processed and
thus a large test runtime when e.g. simulating a gbit
connection (#2203).

* Add TODO on sent rtt in receive auto-tuning

* update every rtt/4 and don't use floating point division

* Settle on Thomson algorithm

* More aggressive increase

* Limit send buffer

* restrict send buffer

* Obsolete note

* Introduce MAX_SEND_BUFFER_SIZE

* Renames

* Fix unit tests

* Write qlogs when QLOGDIR is set

* Add Mtu simulator Node

* cleanups

* Remove INITIAL_SEND_BUFFER_SIZE

* Fix import

* Cleanup bench

* Move bench

* Checkin min_bandwidth

* Add license header

* Use MBIT

* Update max_data test

* rename fraction const

* document correlation with DEFAULT_ACK_RATIO

* document max_allowed_sent_at

* remove bandwidth debug

* Document auto-tuning algorithm

* Rename Delay to RandomDelay

* Remove RX_STREAM_DATA_WINDOW

* Remove wrong comment

* Remove debugging assert

* Remove wrong comment

* Update *Delay Debug impl

* Remove comment

* Outdated comment

* Document Mtu node impl

* Refactor fc_state_recv_7

* Remove todo to shrink buffer

* Remove outdated todo

* Add max_send_buffer_size test

* Clippy

* Clippy

* Plan tests

* Add tests

* Fix min_bandwidth

* Add quick check style test

* Interleaving test

* Rational for MAX_RECV_WINDOW_SIZE

* Clippy

* Fix test

* Fix intra doc links

* Expose raw bandwidth

* Use LINK_BANDWIDTH const

* Fixes to get the bench to run

* Rename max_allowed_sent_at to last_update

* Fix changing_max_active unit test to not underflow

* Rename to should_send_update

* Implement Martin's _excess_ algorithm

* Apply clippy suggestions

* Increase minimum expected utilization

* More clippy

* fmt

* Update neqo-transport/src/fc.rs

Co-authored-by: Martin Thomson <mt@lowentropy.net>
Signed-off-by: Max Inden <mail@max-inden.de>

* Update neqo-transport/src/fc.rs

Co-authored-by: Martin Thomson <mt@lowentropy.net>
Signed-off-by: Max Inden <mail@max-inden.de>

* Improve auto_tuning_increase_no_decrease assert comments

* Update neqo-transport/src/fc.rs

Co-authored-by: Martin Thomson <mt@lowentropy.net>
Signed-off-by: Max Inden <mail@max-inden.de>

* Remove TODO on receive buffer shrinking

* Impl From<Option<Datagram>> for Output

* Improve MAX_SEND_BUFFER_SIZE doc comment

* Update neqo-transport/src/fc.rs

Co-authored-by: Lars Eggert <lars@eggert.org>
Signed-off-by: Max Inden <mail@max-inden.de>

* Update neqo-transport/src/recv_stream.rs

Co-authored-by: Lars Eggert <lars@eggert.org>
Signed-off-by: Max Inden <mail@max-inden.de>

* Document QLOGDIR environment variable

* fmt

---------

Signed-off-by: Lars Eggert <lars@eggert.org>
Signed-off-by: Max Inden <mail@max-inden.de>
Co-authored-by: Lars Eggert <lars@eggert.org>
Co-authored-by: Martin Thomson <mt@lowentropy.net>
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.

2 participants