On Mon, Jul 30, 2012 at 1:41 PM, Sonny Karlsson <[email protected]> wrote:
> Here's the patch.
>
> On Jul 30, 2012, at 9:39PM, Sonny Karlsson wrote:
>
>> Hi
>>
>> Setting TCP_NODELAY for all connections is not needed, TCP_CORK
>> overrides this option according to man page tcp section 7. I've seen no
>> change in performance while benchmarking.
>>
>> This patch will remove an unnecessary system call and fix some warnings
>> generated during high load when connections are closed before the system
>> call completes. The warnings are rare (takes 10+ min to replicate, but
>> then I get a few at the same time) and only occur in a fastcgi module
>> I'm currently working on, not while serving static files.
>>
>> There is however an issue that may arise when serving static files
>> without the TCP_NODELAY flag. I'll submit a patch and description of
>> the issue.
>>
>> --
>> Sonny Karlsson
>
This looks an interesting topic, according tcp(7):
TCP_CORK (since Linux 2.2)
If set, don't send out partial frames. All queued
partial frames are sent when the option is cleared again. This is
useful for
prepending headers before calling sendfile(2), or for
throughput optimization. As currently implemented, there is a 200
millisec‐
ond ceiling on the time for which output is corked
by TCP_CORK. If this ceiling is reached, then queued data is
automatically
transmitted. This option can be combined with
TCP_NODELAY only since Linux 2.5.71. This option should not be
used in code
intended to be portable.
TCP_NODELAY
If set, disable the Nagle algorithm. This means that
segments are always sent as soon as possible, even if there is only a
small
amount of data. When not set, data is buffered until
there is a sufficient amount to send out, thereby avoiding the
frequent send‐
ing of small packets, which results in poor
utilization of the network. This option is overridden by TCP_CORK;
however, setting
this option forces an explicit flush of pending output,
even if TCP_CORK is currently set.
In monkey TCP_CORK is used when sending out the response headers plus
a fraction of the static file, when the response headers are finally
sent, TCP_CORK is disabled. But what happens with the next calls who
send the data to the client ?, imagine a file of 1MB, it will need a
few calls to sendfile(2) and on that moment the Nagle algorithm is
still enable, so removing the TCP_NODELAY code flag will hurt.
Those system calls could be reduced, what about when TCP_CORK is
disabled, make sure to enable TCP_NODELAY on that moment ?, that could
be an improvement.
comments ?
--
Eduardo Silva
http://edsiper.linuxchile.cl
http://www.monkey-project.com
_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey