Domino on Linux/Unix, Troubleshooting, Best Practices, Tips and more ...

alt

Daniel Nashed

My old friend Nagle hit me again when writing a Milter client

Daniel Nashed – 10 August 2025 09:56:30
I have not looked into Nagle for a very long time. In many environments, the default is off.
So I was really surprised when I did a simple loopback TCP connection that my communication was much slower than a UNIX socket.
I asked ChatGPT, and it came up with Nagle as a possible reason. I would not have thought about Nagle immediately, because I haven’t hit Nagle for a long time.

In my use case it really makes a difference. I am writing a Milter client to communicate with ClamAV and other Sendmail-compatible milters.
A milter sends commands step by step (like the sender, recipients, headers, and finally the body).

This conversation is much slower with Nagle enabled, and when sending the sender, recipients, some headers, and the EICAR test virus, the difference was 30 ms vs. 300 ms between using a UNIX socket and a TCP connection on the loopback interface.
The documentation says that UNIX sockets are much cheaper from a resource point of view. They don’t need a handshake—just opening a file descriptor.

But with Nagle disabled, the performance difference wasn’t noticeable anymore.
After setting TCP_NODELAY, the performance was almost the same.

It’s still a good idea to use a UNIX socket where possible, because it does reduce the load on the local TCP/IP stack—especially when opening and closing connections often.
I added the same syntax Milters use to distinct between TCP and Unix sockets.

The calls are almost the same, beside opening the connection. All communication uses the same system calls like read() and write().

Here is what helped to add to the C:

setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));

Links

    Archives


    • [HCL Domino]
    • [Domino on Linux]
    • [Nash!Com]
    • [Daniel Nashed]