Skip to content

Commit 93d28cf

Browse files
committed
[jumpstart] use packets as the unit for consistency with IW
1 parent 9ba8b41 commit 93d28cf

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

include/quicly.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,12 @@ struct st_quicly_context_t {
330330
* Jumpstart CWND to be used when there is no previous information. If set to zero, slow start is used. Note jumpstart is
331331
* possible only when the use_pacing flag is set.
332332
*/
333-
uint32_t default_jumpstart_cwnd_bytes;
333+
uint32_t default_jumpstart_cwnd_packets;
334334
/**
335335
* Maximum jumpstart CWND to be used for connections with previous delivery rate information (i.e., resuming connections). If
336336
* set to zero, slow start is used.
337337
*/
338-
uint32_t max_jumpstart_cwnd_bytes;
338+
uint32_t max_jumpstart_cwnd_packets;
339339
/**
340340
* expand client hello so that it does not fit into one datagram
341341
*/

lib/cc-reno.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,6 @@ uint32_t quicly_cc_calc_initial_cwnd(uint32_t max_packets, uint16_t max_udp_payl
162162
if (max_udp_payload_size > mtu_max)
163163
max_udp_payload_size = mtu_max;
164164

165-
return max_packets * max_udp_payload_size;
165+
uint64_t cwnd_bytes = (uint64_t)max_packets * max_udp_payload_size;
166+
return cwnd_bytes <= UINT32_MAX ? (uint32_t)cwnd_bytes : UINT32_MAX;
166167
}

lib/quicly.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -2276,7 +2276,7 @@ static quicly_conn_t *create_connection(quicly_context_t *ctx, uint32_t protocol
22762276
quicly_linklist_init(&conn->egress.pending_streams.control);
22772277
quicly_ratemeter_init(&conn->egress.ratemeter);
22782278
if (server_name == NULL && conn->super.ctx->use_pacing && conn->egress.cc.type->cc_jumpstart != NULL &&
2279-
(conn->super.ctx->default_jumpstart_cwnd_bytes != 0 || conn->super.ctx->max_jumpstart_cwnd_bytes != 0))
2279+
(conn->super.ctx->default_jumpstart_cwnd_packets != 0 || conn->super.ctx->max_jumpstart_cwnd_packets != 0))
22802280
conn->egress.try_jumpstart = 1;
22812281
conn->crypto.tls = tls;
22822282
if (handshake_properties != NULL) {
@@ -4201,8 +4201,10 @@ static uint32_t derive_jumpstart_cwnd(quicly_context_t *ctx, uint32_t new_rtt, u
42014201
cwnd = cwnd * new_rtt / prev_rtt;
42024202

42034203
/* cap to the configured value */
4204-
if (cwnd > ctx->max_jumpstart_cwnd_bytes)
4205-
cwnd = ctx->max_jumpstart_cwnd_bytes;
4204+
size_t jumpstart_cwnd =
4205+
quicly_cc_calc_initial_cwnd(ctx->max_jumpstart_cwnd_packets, ctx->transport_params.max_udp_payload_size);
4206+
if (cwnd > jumpstart_cwnd)
4207+
cwnd = jumpstart_cwnd;
42064208

42074209
return (uint32_t)cwnd;
42084210
}
@@ -5017,14 +5019,15 @@ static int do_send(quicly_conn_t *conn, quicly_send_context_t *s)
50175019
conn->egress.try_jumpstart = 0;
50185020
uint32_t jumpstart_cwnd = 0;
50195021
conn->super.stats.jumpstart.new_rtt = conn->egress.loss.rtt.minimum;
5020-
if (conn->super.ctx->max_jumpstart_cwnd_bytes != 0 && conn->super.stats.jumpstart.prev_rate != 0 &&
5022+
if (conn->super.ctx->max_jumpstart_cwnd_packets != 0 && conn->super.stats.jumpstart.prev_rate != 0 &&
50215023
conn->super.stats.jumpstart.prev_rtt != 0) {
50225024
/* Careful Resume */
50235025
jumpstart_cwnd = derive_jumpstart_cwnd(conn->super.ctx, conn->super.stats.jumpstart.new_rtt,
50245026
conn->super.stats.jumpstart.prev_rate, conn->super.stats.jumpstart.prev_rtt);
5025-
} else if (conn->super.ctx->default_jumpstart_cwnd_bytes != 0) {
5027+
} else if (conn->super.ctx->default_jumpstart_cwnd_packets != 0) {
50265028
/* jumpstart without previous information */
5027-
jumpstart_cwnd = conn->super.ctx->default_jumpstart_cwnd_bytes;
5029+
jumpstart_cwnd = quicly_cc_calc_initial_cwnd(conn->super.ctx->default_jumpstart_cwnd_packets,
5030+
conn->super.ctx->transport_params.max_udp_payload_size);
50285031
}
50295032
/* Jumpstart if the flow rate would be higher. Comparison target is CWND + inflight bytes in 1/2 RTT, as that is the
50305033
* amount that can be sent at most, with pacer controlling the send rate. */

src/cli.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ static void usage(const char *cmd)
11261126
" fraction of CWND (default: 0)\n"
11271127
" -G enable UDP generic segmentation offload\n"
11281128
" -i interval interval to reissue requests (in milliseconds)\n"
1129-
" --jumpstart-default <wnd> jumpstart CWND size for new connections, in bytes\n"
1129+
" --jumpstart-default <wnd> jumpstart CWND size for new connections, in packets\n"
11301130
" --jumpstart-max <wnd> maximum jumpstart CWND size for resuming connections\n"
11311131
" -I timeout idle timeout (in milliseconds; default: 600,000)\n"
11321132
" -K num-packets perform key update every num-packets packets\n"
@@ -1228,12 +1228,12 @@ int main(int argc, char **argv)
12281228
} else if (strcmp(longopts[opt_index].name, "disregard-app-limited") == 0) {
12291229
ctx.cc_recognize_app_limited = 0;
12301230
} else if (strcmp(longopts[opt_index].name, "jumpstart-default") == 0) {
1231-
if (sscanf(optarg, "%" SCNu32, &ctx.default_jumpstart_cwnd_bytes) != 1) {
1231+
if (sscanf(optarg, "%" SCNu32, &ctx.default_jumpstart_cwnd_packets) != 1) {
12321232
fprintf(stderr, "failed to parse default jumpstart size: %s\n", optarg);
12331233
exit(1);
12341234
}
12351235
} else if (strcmp(longopts[opt_index].name, "jumpstart-max") == 0) {
1236-
if (sscanf(optarg, "%" SCNu32, &ctx.max_jumpstart_cwnd_bytes) != 1) {
1236+
if (sscanf(optarg, "%" SCNu32, &ctx.max_jumpstart_cwnd_packets) != 1) {
12371237
fprintf(stderr, "failed to parse max jumpstart size: %s\n", optarg);
12381238
exit(1);
12391239
}

t/test.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -726,12 +726,18 @@ void test_ecn_index_from_bits(void)
726726
/* at the moment only derivation is tested */
727727
static void test_jumpstart(void)
728728
{
729-
quicly_context_t unbounded_max = {.max_jumpstart_cwnd_bytes = UINT32_MAX};
729+
quicly_context_t unbounded_max = {
730+
.max_jumpstart_cwnd_packets = UINT32_MAX,
731+
.transport_params.max_udp_payload_size = 1200,
732+
};
730733
ok(derive_jumpstart_cwnd(&unbounded_max, 250, 1000000, 250) == 250000);
731734
ok(derive_jumpstart_cwnd(&unbounded_max, 250, 1000000, 400) == 250000); /* if RTT increases, CWND stays same */
732735
ok(derive_jumpstart_cwnd(&unbounded_max, 250, 1000000, 125) == 125000); /* if RTT decreses, CWND is reduced proportionally */
733736

734-
quicly_context_t bounded_max = {.max_jumpstart_cwnd_bytes = 80000};
737+
quicly_context_t bounded_max = {
738+
.max_jumpstart_cwnd_packets = 64,
739+
.transport_params.max_udp_payload_size = 1250,
740+
};
735741
ok(derive_jumpstart_cwnd(&bounded_max, 250, 1000000, 250) == 80000);
736742
}
737743

0 commit comments

Comments
 (0)