lsalzman / enet

ENet reliable UDP networking library
MIT License
2.72k stars 670 forks source link

sendmmsg & Generic Segmentation Offloading? #220

Open CreativePSofficial opened 1 year ago

CreativePSofficial commented 1 year ago

Hello,

I wanted to ask you @lsalzman, whether ENet could see an optimization with GSO and sendmmsg (instead of the plain 'sendmsg') in order to optimize throughput? ( see: https://blog.cloudflare.com/accelerating-udp-packet-transmission-for-quic/ ) I have heard QUIC already leverages these, so I am asking how much sense it would make to implement them in ENet at least on the unix/linux side of things...

Thank you!

CreativePSofficial commented 1 year ago

@lsalzman Hello,

are there any updates on this?

dimage1 commented 6 months ago

Hi, sendmmsg optimizes CPU by reducing system calls. It should be relatively easy to implement by accumulating mmsghdr inside enet_socket_send and flushing it on buffers' limit reach or by direct calls of enet_socket_send_flush. ENetSocket can be extended to a structure to store intermediate buffers. BTW, a similar technique can be used for receiving, with recvmmsg.

CreativePSofficial commented 6 months ago

Hello sir, thanks for your reply.

Yes... We have sendmmsg in already, but now I am asking about GSO, how could this be possibly done?

I am looking forward to hearing from you. Thank you.

dimage1 commented 6 months ago

Sorry, I don't know a good way to benefit from GSO on enet. Enet already tries to split data close to the MTU size. All enet packets are below MTU, but have various sizes. So pushing them to the kernel as one big buffer (e.g. 64K) with predefined segment size might break enet.  A complete OS kernel bypassing can be another way to go. Technologies like DPDK will help there.