Commit 4bdcfdf6 authored by Mike Perry's avatar Mike Perry
Browse files

Fix for RTT calculation hang during congestion control.

This should allow RTT calculation to resume as soon as one circuit gets a sane
RTT, post clock jump.
parent dc7902ed
Pipeline #41399 skipped
......@@ -742,12 +742,10 @@ time_delta_stalled_or_jumped(const congestion_control_t *cc,
return is_monotime_clock_broken;
}
/* If the old_delta is 0, we have no previous values on this circuit.
*
* So, return the global monotime status from other circuits, and
* do not update.
/* If we have no previous values on this circuit, return the
* global monotime status from other circuits, and do not update.
*/
if (old_delta == 0) {
if (!cc->got_first_rtt) {
return is_monotime_clock_broken;
}
......@@ -776,8 +774,13 @@ time_delta_stalled_or_jumped(const congestion_control_t *cc,
}
/* If new_delta is significantly larger than old_delta, then
* this means that the monotime clock suddenly jumped forward. */
if (new_delta > old_delta * DELTA_DISCREPENCY_RATIO_MAX) {
* this means that the monotime clock suddenly jumped forward.
*
* The old_delta+1 here is because if RTT gets wedged, old_delta
* will be stuck at 0 on new circuits, causing this check to always
* return cached value and never update.
*/
if (new_delta > (old_delta+1) * DELTA_DISCREPENCY_RATIO_MAX) {
static ratelim_t dec_notice_limit = RATELIM_INIT(300);
log_fn_ratelim(&dec_notice_limit, LOG_NOTICE, LD_CIRC,
"Sudden increase in circuit RTT (%"PRIu64" vs %"PRIu64
......@@ -831,9 +834,12 @@ congestion_control_update_circuit_rtt(congestion_control_t *cc,
/* Do not update RTT at all if it looks fishy */
if (time_delta_stalled_or_jumped(cc, cc->ewma_rtt_usec, rtt)) {
cc->got_first_rtt = 1;
return 0;
}
cc->got_first_rtt = 1;
ewma_cnt = n_ewma_count(cc);
cc->ewma_rtt_usec = n_count_ewma(rtt, cc->ewma_rtt_usec, ewma_cnt);
......
......@@ -159,6 +159,9 @@ struct congestion_control_t {
/** Are we in slow start? */
bool in_slow_start;
/** Did we get at least 1 RTT measurement? */
bool got_first_rtt;
/** Is the local channel blocked on us? That's a congestion signal */
bool blocked_chan;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment