Loading src/quic.cpp +14 −8 Changes for src/quic.cpp: 14 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -1700,14 +1700,20 @@ void quic::accept(std::unique_ptr<socket>& csock, bool nonblock) { // Initial packet (new connection) exits the loop so the caller can // register it. // // Multiple threads can run this drain loop concurrently now (the QUIC // listener fd is no longer EPOLLONESHOT'd, see epoll.cpp): // recvBatchAddr()/recvmmsg on the same fd from separate threads is // safe — the kernel hands out disjoint datagrams, never duplicates — // and every connection this function touches is reached through // _registry_mutex (briefly, for lookup/insert/erase only) plus that // connection's own quic_mtx() (for everything else), so different // connections are processed by different threads without contention. // Note on concurrency: today the QUIC listener fd is still // EPOLLONESHOT'd (EV_ONESHOT'd on kqueue) — see epoll.cpp/kqueue.cpp's // listener registration — so in practice only one thread runs this // drain loop for a given listener at a time; an EPOLLEXCLUSIVE/no- // ONESHOT variant was tried and reverted after a measured 10x // regression (see epoll.cpp). The loop is nonetheless written to be // safe if that ever changes (e.g. a future per-thread listener socket // via SO_REUSEPORT sharding): recvBatchAddr()/recvmmsg on the same fd // from separate threads is safe — the kernel hands out disjoint // datagrams, never duplicates — and every connection this function // touches is reached through _registry_mutex (briefly, for // lookup/insert/erase only) plus that connection's own quic_mtx() (for // everything else), so different connections could be processed by // different threads without contention. static constexpr int MAX_DRAIN = 512; // Batch-receive datagrams via udp::recvBatchAddr (recvmmsg on Linux). Loading Loading
src/quic.cpp +14 −8 Changes for src/quic.cpp: 14 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -1700,14 +1700,20 @@ void quic::accept(std::unique_ptr<socket>& csock, bool nonblock) { // Initial packet (new connection) exits the loop so the caller can // register it. // // Multiple threads can run this drain loop concurrently now (the QUIC // listener fd is no longer EPOLLONESHOT'd, see epoll.cpp): // recvBatchAddr()/recvmmsg on the same fd from separate threads is // safe — the kernel hands out disjoint datagrams, never duplicates — // and every connection this function touches is reached through // _registry_mutex (briefly, for lookup/insert/erase only) plus that // connection's own quic_mtx() (for everything else), so different // connections are processed by different threads without contention. // Note on concurrency: today the QUIC listener fd is still // EPOLLONESHOT'd (EV_ONESHOT'd on kqueue) — see epoll.cpp/kqueue.cpp's // listener registration — so in practice only one thread runs this // drain loop for a given listener at a time; an EPOLLEXCLUSIVE/no- // ONESHOT variant was tried and reverted after a measured 10x // regression (see epoll.cpp). The loop is nonetheless written to be // safe if that ever changes (e.g. a future per-thread listener socket // via SO_REUSEPORT sharding): recvBatchAddr()/recvmmsg on the same fd // from separate threads is safe — the kernel hands out disjoint // datagrams, never duplicates — and every connection this function // touches is reached through _registry_mutex (briefly, for // lookup/insert/erase only) plus that connection's own quic_mtx() (for // everything else), so different connections could be processed by // different threads without contention. static constexpr int MAX_DRAIN = 512; // Batch-receive datagrams via udp::recvBatchAddr (recvmmsg on Linux). Loading