by foota · 3y ago · 0 comments
My understanding is that there's some contention from the locking involved though which can make this not scale well, but maybe that could be avoided (e.g., maybe by trying to have per core buffers used by the kernel, although I'm not sure you'd have any control over the kernel threads).
You don't have control from the application, but if you're really trying to get the most performance from your networking heavy application, you want to set up your server where the NIC rx and tx queues are cpu pinned, and the application thread that processes any given socket is pinned to the same cpu that the kernel is using for that socket. Then there's no cross cpu traffic for that socket (if all else goes well).
Hopefully all the memory used is NUMA local for the CPU and the NIC as well. That gets trickier with multiple socket systems, although some NICs do have provisions to connect to two PCIe slots so they can be NUMA local to two sockets.
(I mean visible like a videoconferencing application as opposed to something like invisible multicast dns)
Well multicast is not possible on internet so I guess that's why you don't see it often.
In private network centric protocols though (e.g. finance), multicast is ubiquitous.
(That is, if you get my weird train analogy, and if I'm understanding your idea correctly.)
So instead of:
for each player:
for each block player needs:
# Write block to player's connection
You could do: for each player:
for each block player needs:
# Check if the block is already mapped in a kernel buffer. If it is, just append a write for it to the io ring.
# Otherwise, copy the block into a new buffer and send it.I was thinking of a situation where you want to also limit the system call overhead per send. (think maybe there's some number of 64k-ish chunks that you want to send to different clients, so each connection would involve multiple write per frame etc.,)
You could go the DPDK route but that has downsides of your application needing exclusive access to the network interface. AFAIK, any network stack that supports multiple simultaneous applications typically involves at least 1 copy but I could be off.
Having worked with sk_bufs a bit I hope a copy isn’t needed for a network send. All the tooling I worked with around those was zero copy.
Never did it, but I guess you could reroute traffic you don't care about to the Linux network stack for regular routing.
https://doc.dpdk.org/guides-16.07/howto/flow_bifurcation.htm...
Not sure that's a realistic scenario though. You rarely expose a DPDK app directly on a regular / open subnet. You often have a dedicated app, with a dedicated NIC, on a dedicated subnet, for a dedicated traffic.