Loading src/socket.h +19 −0 Changes for src/socket.h: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -601,6 +601,25 @@ namespace netplus { }; // Constructors/Destructor // // Scaling a listener beyond one core (`sockopts` incl. SO_REUSEPORT): // a single quic listener's incoming datagrams are serviced by only // one thread at a time, by design — see epoll.cpp's comment at the // QUIC listener's EPOLLONESHOT registration for why (a measured 10x // regression from letting multiple threads drain the same socket // concurrently). To use more than one core for ingress, construct N // independent listener instances bound to the same address/port // with SO_REUSEPORT in `sockopts` (the kernel load-balances // datagrams across them by 4-tuple hash), and drive each with its // own netplus::event instance whose `threads` field is set to 1 — // not N instances sharing one `event`/epoll fd, which would just // reproduce the single-socket contention this avoids. Pin each // driving thread to a distinct core (pthread_setaffinity_np, as // event/epoll.cpp's worker threads already do) so shard N's // connections don't bounce between cores. Note RFC 9000 §9 // Connection Migration is not shard-aware: a migrating connection's // datagrams can land on a different shard than the one holding its // registry entry. quic(); quic(SOCKET sock); quic(const std::string& addr, int port, int maxconnections, int sockopts); Loading Loading
src/socket.h +19 −0 Changes for src/socket.h: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -601,6 +601,25 @@ namespace netplus { }; // Constructors/Destructor // // Scaling a listener beyond one core (`sockopts` incl. SO_REUSEPORT): // a single quic listener's incoming datagrams are serviced by only // one thread at a time, by design — see epoll.cpp's comment at the // QUIC listener's EPOLLONESHOT registration for why (a measured 10x // regression from letting multiple threads drain the same socket // concurrently). To use more than one core for ingress, construct N // independent listener instances bound to the same address/port // with SO_REUSEPORT in `sockopts` (the kernel load-balances // datagrams across them by 4-tuple hash), and drive each with its // own netplus::event instance whose `threads` field is set to 1 — // not N instances sharing one `event`/epoll fd, which would just // reproduce the single-socket contention this avoids. Pin each // driving thread to a distinct core (pthread_setaffinity_np, as // event/epoll.cpp's worker threads already do) so shard N's // connections don't bounce between cores. Note RFC 9000 §9 // Connection Migration is not shard-aware: a migrating connection's // datagrams can land on a different shard than the one holding its // registry entry. quic(); quic(SOCKET sock); quic(const std::string& addr, int port, int maxconnections, int sockopts); Loading