OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: TCP_NODELAY, TCP_CORK, TCP_NOPUSH, etc (was: dkim-milter signing terribly slow...)

From: Wietse Venema (wietseporcupine.org)
Date: Sat Jul 28 2007 - 21:05:24 CDT


Victor Duchovni:
> Another possibility is (after ensuring vstream buffer size > TCP MSS)
> to simply disable Nagle during bulk data transfer. Given the above, for

No, doing so would FORCE the kernel to send segments smaller than
the MSS:

write 4096
        send 1460
        send 1460
        send 1176
write 4096
        send 1460
        send 1460
        send 1176
write 4096
        send 1460
        send 1460
        send 1176
etc.

This is clearly sub-optimal. Making this change would be a mistake.

Currently (Nagle enabled), this is what happens instead (FreeBSD),
provided that the application is able to keep the pipe full (if
the application can't keep up with the network stack, then network
performance loses relevance):

write 4096
        send 1460
        send 1460
        send 1176
write 4096
        send 1460
        send 1460
        keep 1176
write 4096
        send 1460 (1176 + 284)
        send 1460
        send 1460
        keep 892
write 4096
        send 1460
        send 1460

and so on, all "send 1460" until we reach the end of the file.

We already have near optimal behavior for MSS < 4096.

My conclusion: don't change anything when buffer size > MSS. Adjust
the buffer if it's smaller. The amount of code that needs changing
is amazingly small.

        Wietse