From 71f8971dde0954df1b2837d9239a001373891420 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 22 Jun 2022 19:46:33 +0900 Subject: [PATCH] h2load: Send more packets without GSO per event loop --- src/h2load_quic.cc | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/h2load_quic.cc b/src/h2load_quic.cc index 0c4a8dfd..88e2daa9 100644 --- a/src/h2load_quic.cc +++ b/src/h2load_quic.cc @@ -593,17 +593,13 @@ int Client::write_quic() { std::array vec; size_t pktcnt = 0; auto max_udp_payload_size = ngtcp2_conn_get_max_udp_payload_size(quic.conn); +#ifdef UDP_SEGMENT auto path_max_udp_payload_size = ngtcp2_conn_get_path_max_udp_payload_size(quic.conn); +#endif // UDP_SEGMENT size_t max_pktcnt = -#ifdef UDP_SEGMENT - worker->config->no_udp_gso - ? 1 - : std::min(static_cast(10), - static_cast(64_k / max_udp_payload_size)); -#else // !UDP_SEGMENT - 1; -#endif // !UDP_SEGMENT + std::min(static_cast(10), + static_cast(64_k / max_udp_payload_size)); uint8_t *bufpos = quic.tx.data.get(); ngtcp2_path_storage ps; size_t gso_size = 0; @@ -685,6 +681,32 @@ int Client::write_quic() { bufpos += nwrite; +#ifdef UDP_SEGMENT + if (worker->config->no_udp_gso) { +#endif // UDP_SEGMENT + auto data = quic.tx.data.get(); + auto datalen = bufpos - quic.tx.data.get(); + rv = write_udp(ps.path.remote.addr, ps.path.remote.addrlen, data, datalen, + 0); + if (rv == 1) { + on_send_blocked(ps.path.remote, data, datalen, 0); + signal_write(); + return 0; + } + + if (++pktcnt == max_pktcnt) { + signal_write(); + return 0; + } + + bufpos = quic.tx.data.get(); + +#ifdef UDP_SEGMENT + continue; + } +#endif // UDP_SEGMENT + +#ifdef UDP_SEGMENT if (pktcnt == 0) { gso_size = nwrite; } else if (static_cast(nwrite) > gso_size || @@ -722,6 +744,7 @@ int Client::write_quic() { signal_write(); return 0; } +#endif // UDP_SEGMENT } }