From 07645d1308b0a3b4eee4ba2e854d98256e7eae79 Mon Sep 17 00:00:00 2001 From: huitema <huitema@huitema.net> Date: Sun, 2 Dec 2018 21:05:45 -0800 Subject: [PATCH] Tune pacing algorithm to remove all regressions. --- picoquic/sender.c | 28 ++++++++++++++++++++-------- picoquictest/tls_api_test.c | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/picoquic/sender.c b/picoquic/sender.c index a0722ef0..e168076e 100644 --- a/picoquic/sender.c +++ b/picoquic/sender.c @@ -531,19 +531,31 @@ int picoquic_is_sending_authorized_by_pacing(picoquic_path_t * path_x, uint64_t void picoquic_update_pacing_data(picoquic_path_t * path_x) { - uint64_t bucket_1024 = (((uint64_t)path_x->cwin)<<10)/ (8 * path_x->send_mtu); - uint64_t bucket = 2 + ((bucket_1024 + 1023) >> 10); + uint64_t rtt_nanosec = (path_x->smoothed_rtt << 10); - path_x->pacing_bucket_max = bucket; - - path_x->pacing_packet_time_nanosec = ((path_x->smoothed_rtt << 10) * path_x->send_mtu) / path_x->cwin; - - if (path_x->pacing_packet_time_nanosec <= 0) { + if (path_x->cwin < 8 * path_x->send_mtu) { + /* Small windows, should only relie on ACK clocking */ + path_x->pacing_bucket_max = rtt_nanosec; path_x->pacing_packet_time_nanosec = 1; path_x->pacing_packet_time_microsec = 1; + } else { - path_x->pacing_packet_time_microsec = (path_x->pacing_packet_time_nanosec + 1023) >> 10; + + path_x->pacing_packet_time_nanosec = (rtt_nanosec * path_x->send_mtu) / path_x->cwin; + + if (path_x->pacing_packet_time_nanosec <= 0) { + path_x->pacing_packet_time_nanosec = 1; + path_x->pacing_packet_time_microsec = 1; + } + else { + path_x->pacing_packet_time_microsec = (path_x->pacing_packet_time_nanosec + 1023) >> 10; + } + + path_x->pacing_bucket_max = (rtt_nanosec / 4); + if (path_x->pacing_bucket_max < 2 * path_x->pacing_packet_time_nanosec) { + path_x->pacing_bucket_max = 2 * path_x->pacing_packet_time_nanosec; + } } } diff --git a/picoquictest/tls_api_test.c b/picoquictest/tls_api_test.c index ea3d1534..ba8b0bb6 100644 --- a/picoquictest/tls_api_test.c +++ b/picoquictest/tls_api_test.c @@ -1391,7 +1391,7 @@ int tls_api_one_scenario_test(test_api_stream_desc_t* scenario, int tls_api_oneway_stream_test() { - return tls_api_one_scenario_test(test_scenario_oneway, sizeof(test_scenario_oneway), 0, 0, 0, 0, 75000, NULL, NULL); + return tls_api_one_scenario_test(test_scenario_oneway, sizeof(test_scenario_oneway), 0, 0, 0, 0, 70000, NULL, NULL); } int tls_api_q_and_r_stream_test() -- GitLab