ocaml / ocaml

The core OCaml system: compilers, runtime system, base libraries
https://ocaml.org
Other
5.19k stars 1.06k forks source link

Add Unix.TCP_QUICKACK #13133

Open rbjorklin opened 2 weeks ago

rbjorklin commented 2 weeks ago

If accepted this PR adds the TCP_QUICKACK socket option.

TCP_QUICKACK can be of use on low latency networks where a socket buffer may not fill up in the hard coded 200ms window. Setting TCP_QUICKACK will cause acknowledgements to be sent immediately.

Short version: set TCP_QUICKACK. If you find a case where that makes things worse, let me know.

John Nagle

PS. This PR was heavily inspired by #9869 and I'm not convinced I did everything correctly. For example it is not clear to me why the TCP_NODELAY macro exists in sockopt_unix.c but not in sockopt_win32.c and because I don't understand I opted to not add the macro to sockopt_win32.c.

EDIT: The build failed without the macro in sockopt_win32.c so I ended up adding it after all.

MisterDA commented 2 weeks ago

I went looking around and found a discussion on the dotnet runtime about adding this feature Socket support for TCP_QUICKACK. They decided against it, because there was no good cross-platform support, and couldn't settle on a portable way to expose the feature to their users.

rbjorklin commented 2 weeks ago

For what it's worth this is available at the system level when using systemd >= 253.

It is also possible to modify existing routes to force quickack for any connection using said route.

ip -4 route show scope link | while read route ; do 
    ip route change ${route} quickack 1
done
gasche commented 18 hours ago

I wonder who would want to make a decision on this question. Maybe @xavierleroy or @damiendoligez?

rbjorklin commented 1 hour ago

Given that workarounds exist I would be fine with this being closed as “won’t do”.