|
57 | 57 | #define LSQUIC_LOG_CONN_ID lsquic_conn_log_cid(ctl->sc_conn_pub->lconn)
|
58 | 58 | #include "lsquic_logger.h"
|
59 | 59 |
|
| 60 | +#if __GNUC__ |
| 61 | +# define UNLIKELY(cond) __builtin_expect(cond, 0) |
| 62 | +#else |
| 63 | +# define UNLIKELY(cond) cond |
| 64 | +#endif |
| 65 | + |
60 | 66 | #define MAX_RESUBMITTED_ON_RTO 2
|
61 | 67 | #define MAX_RTO_BACKOFFS 10
|
62 | 68 | #define DEFAULT_RETX_DELAY 500000 /* Microseconds */
|
@@ -742,6 +748,12 @@ take_rtt_sample (lsquic_send_ctl_t *ctl,
|
742 | 748 | const lsquic_time_t measured_rtt = now - sent;
|
743 | 749 | if (packno > ctl->sc_max_rtt_packno && lack_delta < measured_rtt)
|
744 | 750 | {
|
| 751 | + if (UNLIKELY(ctl->sc_flags & SC_ROUGH_RTT)) |
| 752 | + { |
| 753 | + memset(&ctl->sc_conn_pub->rtt_stats, 0, |
| 754 | + sizeof(ctl->sc_conn_pub->rtt_stats)); |
| 755 | + ctl->sc_flags &= ~SC_ROUGH_RTT; |
| 756 | + } |
745 | 757 | ctl->sc_max_rtt_packno = packno;
|
746 | 758 | lsquic_rtt_stats_update(&ctl->sc_conn_pub->rtt_stats, measured_rtt, lack_delta);
|
747 | 759 | LSQ_DEBUG("packno %"PRIu64"; rtt: %"PRIu64"; delta: %"PRIu64"; "
|
@@ -1117,12 +1129,6 @@ lsquic_send_ctl_got_ack (lsquic_send_ctl_t *ctl,
|
1117 | 1129 | __builtin_prefetch(packet_out);
|
1118 | 1130 | #endif
|
1119 | 1131 |
|
1120 |
| -#if __GNUC__ |
1121 |
| -# define UNLIKELY(cond) __builtin_expect(cond, 0) |
1122 |
| -#else |
1123 |
| -# define UNLIKELY(cond) cond |
1124 |
| -#endif |
1125 |
| - |
1126 | 1132 | #if __GNUC__
|
1127 | 1133 | if (UNLIKELY(LSQ_LOG_ENABLED(LSQ_LOG_DEBUG)))
|
1128 | 1134 | #endif
|
@@ -1520,9 +1526,22 @@ send_ctl_all_bytes_out (const struct lsquic_send_ctl *ctl)
|
1520 | 1526 | int
|
1521 | 1527 | lsquic_send_ctl_pacer_blocked (struct lsquic_send_ctl *ctl)
|
1522 | 1528 | {
|
| 1529 | +#ifdef NDEBUG |
1523 | 1530 | return (ctl->sc_flags & SC_PACE)
|
1524 | 1531 | && !lsquic_pacer_can_schedule(&ctl->sc_pacer,
|
1525 | 1532 | ctl->sc_n_in_flight_all);
|
| 1533 | +#else |
| 1534 | + if (ctl->sc_flags & SC_PACE) |
| 1535 | + { |
| 1536 | + const int blocked = !lsquic_pacer_can_schedule(&ctl->sc_pacer, |
| 1537 | + ctl->sc_n_in_flight_all); |
| 1538 | + LSQ_DEBUG("pacer blocked: %d, in_flight_all: %u", blocked, |
| 1539 | + ctl->sc_n_in_flight_all); |
| 1540 | + return blocked; |
| 1541 | + } |
| 1542 | + else |
| 1543 | + return 0; |
| 1544 | +#endif |
1526 | 1545 | }
|
1527 | 1546 |
|
1528 | 1547 |
|
@@ -3214,6 +3233,42 @@ lsquic_send_ctl_set_token (struct lsquic_send_ctl *ctl,
|
3214 | 3233 | }
|
3215 | 3234 |
|
3216 | 3235 |
|
| 3236 | +void |
| 3237 | +lsquic_send_ctl_maybe_calc_rough_rtt (struct lsquic_send_ctl *ctl, |
| 3238 | + enum packnum_space pns) |
| 3239 | +{ |
| 3240 | + const struct lsquic_packet_out *packet_out; |
| 3241 | + lsquic_time_t min_sent, rtt; |
| 3242 | + struct lsquic_packets_tailq *const *q; |
| 3243 | + struct lsquic_packets_tailq *const queues[] = { |
| 3244 | + &ctl->sc_lost_packets, |
| 3245 | + &ctl->sc_unacked_packets[pns], |
| 3246 | + }; |
| 3247 | + |
| 3248 | + if ((ctl->sc_flags & SC_ROUGH_RTT) |
| 3249 | + || lsquic_rtt_stats_get_srtt(&ctl->sc_conn_pub->rtt_stats)) |
| 3250 | + return; |
| 3251 | + |
| 3252 | + min_sent = UINT64_MAX; |
| 3253 | + for (q = queues; q < queues + sizeof(queues) / sizeof(queues[0]); ++q) |
| 3254 | + TAILQ_FOREACH(packet_out, *q, po_next) |
| 3255 | + if (min_sent > packet_out->po_sent) |
| 3256 | + min_sent = packet_out->po_sent; |
| 3257 | + |
| 3258 | + /* If we do not have an RTT estimate yet, get a rough estimate of it, |
| 3259 | + * because now we will ignore packets that carry acknowledgements and |
| 3260 | + * RTT estimation may be delayed. |
| 3261 | + */ |
| 3262 | + if (min_sent < UINT64_MAX) |
| 3263 | + { |
| 3264 | + rtt = lsquic_time_now() - min_sent; |
| 3265 | + lsquic_rtt_stats_update(&ctl->sc_conn_pub->rtt_stats, rtt, 0); |
| 3266 | + ctl->sc_flags |= SC_ROUGH_RTT; |
| 3267 | + LSQ_DEBUG("set rough RTT to %"PRIu64" usec", rtt); |
| 3268 | + } |
| 3269 | +} |
| 3270 | + |
| 3271 | + |
3217 | 3272 | void
|
3218 | 3273 | lsquic_send_ctl_empty_pns (struct lsquic_send_ctl *ctl, enum packnum_space pns)
|
3219 | 3274 | {
|
|
0 commit comments