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

chore(networking): Rework internal auto concurrency tests #3802

Merged
merged 10 commits into from
Sep 11, 2020
586 changes: 233 additions & 353 deletions src/sinks/util/auto_concurrency/tests.rs

Large diffs are not rendered by default.

62 changes: 0 additions & 62 deletions src/test_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,68 +50,6 @@ macro_rules! assert_downcast_matches {
}};
}

#[macro_export]
macro_rules! assert_within {
// Adapted from std::assert_eq
($expr:expr, $low:expr, $high:expr) => ({
match (&$expr, &$low, &$high) {
(expr, low, high) => {
if *expr < *low {
panic!(
r#"assertion failed: `(expr < low)`
expr: {} = `{:?}`,
low: `{:?}`"#,
stringify!($expr),
&*expr,
&*low
);
}
if *expr > *high {
panic!(
r#"assertion failed: `(expr > high)`
expr: {} = `{:?}`,
high: `{:?}`"#,
stringify!($expr),
&*expr,
&*high
);
}
}
}
});
($expr:expr, $low:expr, $high:expr, $($arg:tt)+) => ({
match (&$expr, &$low, &$high) {
(expr, low, high) => {
if *expr < *low {
panic!(
r#"assertion failed: `(expr < low)`
expr: {} = `{:?}`,
low: `{:?}`
{}"#,
stringify!($expr),
&*expr,
&*low,
format_args!($($arg)+)
);
}
if *expr > *high {
panic!(
r#"assertion failed: `(expr > high)`
expr: {} = `{:?}`,
high: `{:?}`
{}"#,
stringify!($expr),
&*expr,
&*high,
format_args!($($arg)+)
);
}
}
}
});

}

pub fn next_addr() -> SocketAddr {
let port = pick_unused_port().unwrap();
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), port)
Expand Down
35 changes: 35 additions & 0 deletions tests/data/auto-concurrency-template.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[params]
bruceg marked this conversation as resolved.
Show resolved Hide resolved
requests = 000
delay = 0.050
# Delete any of these that are not needed
interval =
jitter = 0
concurrency_scale = 0
concurrency_defer = 0
in_flight_limit = "auto"
concurrency_drop = 0

[stats.in_flight]
max = [,]
mean = [,]
mode = [,]

[controller.concurrency_limit]
max = [,]
mean = [,]
mode = [,]

[controller.in_flight]
max = [,]
mean = [,]
mode = [,]

[controller.observed_rtt]
min = [,]
max = [,]
mean = [,]

[controller.averaged_rtt]
min = [,]
max = [,]
mean = [,]
29 changes: 29 additions & 0 deletions tests/data/auto-concurrency/constant-link.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# With a constant response time link and enough responses, the limiter
# will ramp up towards the maximum concurrency.

[params]
requests = 500
delay = 0.100

[stats.in_flight]
max = [22, 29]
mean = [10.0, 13.0]

[controller.in_flight]
max = [22, 29]
mean = [10.0, 13.0]

[controller.concurrency_limit]
max = [22, 30]
mode = [10, 25]
mean = [10.0, 15.0]

[controller.observed_rtt]
min = [0.100, 0.102]
max = [0.100, 0.102]
mean = [0.100, 0.102]

[controller.averaged_rtt]
min = [0.100, 0.102]
max = [0.100, 0.102]
mean = [0.100, 0.102]
36 changes: 36 additions & 0 deletions tests/data/auto-concurrency/defers-at-high-concurrency.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[params]
requests = 500
delay = 0.100
concurrency_defer = 5

# With a constant time link that gives deferrals over a certain
# concurrency, the limiter will ramp up to that concurrency and then
# drop down repeatedly. Note that, due to the timing of the adjustment,
# this may actually occasionally go over the error limit above, but it
# will be rare.
[stats.in_flight]
max = [4, 6]
# Since the concurrency will drop down by half each time, the average
# will be below this maximum.
mode = [4, 4]
mean = [4.0, 5.0]

[controller.in_flight]
max = [5, 6]
mode = [4, 4]
mean = [4.0, 5.0]

[controller.concurrency_limit]
max = [5, 6]
mode = [2, 5]
mean = [4.0, 5.0]

[controller.observed_rtt]
min = [0.100, 0.102]
max = [0.100, 0.102]
mean = [0.100, 0.102]

[controller.averaged_rtt]
min = [0.100, 0.102]
max = [0.100, 0.102]
mean = [0.100, 0.102]
33 changes: 33 additions & 0 deletions tests/data/auto-concurrency/drops-at-high-concurrency.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[params]
requests = 500
delay = 0.100
concurrency_drop = 5

[stats.in_flight]
max = [4, 5]
mean = [2.5, 3.0]
mode = [3, 5]

# Since our internal framework doesn't track the dropped requests, the
# values won't be representative of the actual number of requests in
# flight.

[controller.in_flight]
max = [13, 15]
mean = [6.0, 7.0]
mode = [3, 10]

[controller.concurrency_limit]
max = [10, 15]
mean = [7.0, 8.0]
mode = [4, 6]

[controller.observed_rtt]
min = [0.100, 0.102]
max = [0.100, 0.102]
mean = [0.100, 0.102]

[controller.averaged_rtt]
min = [0.100, 0.102]
max = [0.100, 0.102]
mean = [0.100, 0.102]
22 changes: 22 additions & 0 deletions tests/data/auto-concurrency/fixed-concurrency.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Simulate a very jittery link, but with a fixed concurrency. Even with
# jitter, the concurrency limit should never vary.
[params]
requests = 200
delay = 0.100
jitter = 0.5
in_flight_limit = 10

[stats.in_flight]
max = [10, 10]
mode = [10, 10]
mean = [8.5, 10.0]

[controller.in_flight]
max = [10, 10]
mode = [10, 10]
mean = [8.5, 10.0]

[controller.concurrency_limit]
min = [10, 10]
max = [10, 10]
mode = [10, 10]
25 changes: 25 additions & 0 deletions tests/data/auto-concurrency/jittery-link-small.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[params]
requests = 1000
delay = 0.100
jitter = 0.1

# Jitter can cause concurrency management to vary widely, though it
# will typically reach high values of requests in flight.

[stats.in_flight]
max = [20, 35]
mean = [10.0, 20.0]

[controller.in_flight]
max = [20, 35]
mean = [10.0, 20.0]

[controller.concurrency_limit]
max = [20, 35]
mean = [10.0, 20.0]

[controller.observed_rtt]
mean = [0.100, 0.130]

[controller.averaged_rtt]
mean = [0.100, 0.130]
29 changes: 29 additions & 0 deletions tests/data/auto-concurrency/medium-send.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[params]
requests = 500
interval = 0.025
delay = 0.100

# With a generator running at four times the speed as the link RTT,
# the limiter will keep around 4-5 requests in flight depending on
# timing jitter.

[stats.in_flight]
max = [8, 8]
mode = [4, 5]
mean = [4.0, 4.5]

[controller.in_flight]
max = [8, 8]
mode = [4, 5]
mean = [4.0, 4.5]

[controller.concurrency_limit]
max = [8, 8]

[controller.observed_rtt]
min = [0.100, 0.102]
max = [0.100, 0.102]

[controller.averaged_rtt]
min = [0.100, 0.102]
max = [0.100, 0.102]
30 changes: 30 additions & 0 deletions tests/data/auto-concurrency/slow-link.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[params]
requests = 200
delay = 0.100
concurrency_scale = 1.0

# With a link that slows down heavily as concurrency increases, the
# limiter will keep the concurrency low (timing skews occasionally
# has it reaching 3, but usually just 2),
[stats.in_flight]
max = [2, 3]
# and it will spend most of its time between 1 and 2.
mode = [2, 2]
mean = [1.5, 2.0]

[controller.in_flight]
max = [2, 3]
mode = [2, 2]
mean = [1.5, 2.0]

[controller.concurrency_limit]
mode = [2, 3]
mean = [1.7, 2.0]

[controller.observed_rtt]
min = [0.100, 0.102]
mean = [0.100, 0.310]

[controller.averaged_rtt]
min = [0.100, 0.102]
mean = [0.100, 0.310]
29 changes: 29 additions & 0 deletions tests/data/auto-concurrency/slow-send-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[params]
requests = 100
interval = 0.100
delay = 0.050

# With a generator running slower than the link can process, the
# limiter will never raise the concurrency above 1.

[stats.in_flight]
max = [1, 1]
mode = [1, 1]
mean = [0.5, 0.55]

[controller.in_flight]
max = [1, 1]
mode = [1, 1]
mean = [0.5, 0.55]

[controller.concurrency_limit]
mode = [1, 1]
mean = [1.0, 1.0]

[controller.observed_rtt]
min = [0.050, 0.052]
mean = [0.050, 0.052]

[controller.averaged_rtt]
min = [0.050, 0.052]
mean = [0.050, 0.052]
29 changes: 29 additions & 0 deletions tests/data/auto-concurrency/slow-send-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# With a generator running at the same speed as the link RTT, the
# limiter will keep the limit around 2.

[params]
requests = 100
interval = 0.050
delay = 0.050

[stats.in_flight]
max = [1, 2]
mode = [1, 1]
mean = [1.0, 1.2]

[controller.in_flight]
max = [1, 2]
mode = [1, 1]
mean = [1.0, 2.0]

[controller.concurrency_limit]
mode = [2, 2]
mean = [1.9, 2.0]

[controller.observed_rtt]
min = [0.050, 0.052]
mean = [0.050, 0.052]

[controller.averaged_rtt]
min = [0.050, 0.052]
mean = [0.050, 0.052]