Thread View: news.software.nntp
6 messages
6 total messages
Started by Matt Dillon
Sat, 14 Feb 1998 00:00
Found out why diablo's dnewslink had non-optimal performance
Author: Matt Dillon
Date: Sat, 14 Feb 1998 00:00
Date: Sat, 14 Feb 1998 00:00
30 lines
1724 bytes
1724 bytes
I just figured out why diablo's dnewslink doesn't seem to have the
same performance as other outgoing feeders, even though I do fully
pipelined streaming.
I do something VERY stupid... Every time I send a command out, I
write() it. One line at a time.
So, for example, if I am sending four 'check' commands, I do four
write()'s.
This causes TCP's congestion control to kick in and allow only one
in-transit tcp fragment at a time. The first write gets pushed out
the network, but the other writes don't until the first one is ack'd.
The result is decidedly non-optimal performance.
Doh! the 1.15 release next week will fix the problem. I'll add output
buffering to the code and low/high water marks so I don't feed commands
out piecemeal.
-Matt
--
Matthew Dillon Engineering, BEST Internet Communications, Inc.
<dillon@best.net>, include original article w/ any response.
do not under any circumstances send email to joeblow@bigspender.idiom.com
and, for gods sake, don't email bucktram@popserver.idiom.com
Re: Found out why diablo's dnewslink had non-optimal performance
Author: Matt Dillon
Date: Sat, 14 Feb 1998 00:00
Date: Sat, 14 Feb 1998 00:00
36 lines
2304 bytes
2304 bytes
:In article <6c598n$q6o$1@scanner.worldgate.com>,
:Marc Slemko <marcs@znep.com> wrote:
:>In <6c4t4e$o8j$1@flea.best.net> dillon@best.net (Matt Dillon) writes:
:..
:>Erm... this isn't exactly true in the typical situation. Any stack
:>that only allows one unacked packet isn't going to work for many
:>useful things.
no, no... one unacked SHORT packet.... it's part of the congestion
control that most tcp stacks have. It gets turned off if I set
TCP_NODELAY, but TCP_NODELAY is a very dangerous option to set and
may result in the remote end setting it as well.
The reason you don't usually want to use TCP_NODELAY is because it
basically allows hundreds of unacked short packets to be in transit all
at once, even with nagle enabled.
Here's a typical situation that actually happened: Apache sets this
option, and if you run a CGI which does tiny write()'s back through
the pipe, apache will do tiny writes out the network. An ISP running
Apache had a user running a CGI that did this. Even with a reasonable
TCP window size of, say, 16K, the network got blown away by several
*thousand* 41 byte (1 stream byte) packets per second. Nagle didn't
kick in because there wasn't any packet loss, just a massively delayed
network.
-Matt
--
Matthew Dillon Engineering, BEST Internet Communications, Inc.
<dillon@best.net>, include original article w/ any response.
do not under any circumstances send email to joeblow@bigspender.idiom.com
and, for gods sake, don't email bucktram@popserver.idiom.com
Re: Found out why diablo's dnewslink had non-optimal performance
Author: Marc Slemko
Date: Sat, 14 Feb 1998 00:00
Date: Sat, 14 Feb 1998 00:00
36 lines
1935 bytes
1935 bytes
In <6c4t4e$o8j$1@flea.best.net> dillon@best.net (Matt Dillon) writes: > I just figured out why diablo's dnewslink doesn't seem to have the > same performance as other outgoing feeders, even though I do fully > pipelined streaming. > I do something VERY stupid... Every time I send a command out, I > write() it. One line at a time. > So, for example, if I am sending four 'check' commands, I do four > write()'s. > This causes TCP's congestion control to kick in and allow only one > in-transit tcp fragment at a time. The first write gets pushed out > the network, but the other writes don't until the first one is ack'd. Erm... this isn't exactly true in the typical situation. Any stack that only allows one unacked packet isn't going to work for many useful things. Are you sure you aren't running into a combination of Nagle + delayed acks? Try disabling Nagle and seeing if you get the same thing. Now, that isn't the right solution obviously, but... If you modify your code to be as efficient as possible when sending data to avoid multiple write()s, you may still want to disable Nagle. Making this decision, however, requires more careful analysis of how things are working. (no, I haven't looked to see if you already do disable Nagle... if so, ignore me0
Re: Found out why diablo's dnewslink had non-optimal performance
Author: Marc Slemko
Date: Sun, 15 Feb 1998 00:00
Date: Sun, 15 Feb 1998 00:00
63 lines
3700 bytes
3700 bytes
In <6c63vf$pq8$1@flea.best.net> dillon@best.net (Matt Dillon) writes: >:In article <6c598n$q6o$1@scanner.worldgate.com>, >:Marc Slemko <marcs@znep.com> wrote: >:>In <6c4t4e$o8j$1@flea.best.net> dillon@best.net (Matt Dillon) writes: >:.. >:>Erm... this isn't exactly true in the typical situation. Any stack >:>that only allows one unacked packet isn't going to work for many >:>useful things. > no, no... one unacked SHORT packet.... it's part of the congestion > control that most tcp stacks have. It gets turned off if I set > TCP_NODELAY, but TCP_NODELAY is a very dangerous option to set and > may result in the remote end setting it as well. That is a different matter. > The reason you don't usually want to use TCP_NODELAY is because it > basically allows hundreds of unacked short packets to be in transit all > at once, even with nagle enabled. TCP_NODELAY == Nagle. The point is that _IF_ your application is written so you know that you are going to shove as much in a packet as you can already, and if it happens to be small then "oh well", and sending it is better than delaying then sending it, then you need to be able to disable Nagle. You can have very serious performance implications by not disabling it in time-critical situations because of the interaction with delayed ack. If you can't or don't want to code your application so it behaves that way, or your situation isn't time-critical in the required sense, then yes you should not disable Nagle. > Here's a typical situation that actually happened: Apache sets this > option, and if you run a CGI which does tiny write()'s back through > the pipe, apache will do tiny writes out the network. An ISP running > Apache had a user running a CGI that did this. Even with a reasonable > TCP window size of, say, 16K, the network got blown away by several > *thousand* 41 byte (1 stream byte) packets per second. Nagle didn't > kick in because there wasn't any packet loss, just a massively delayed > network. Nagle needs to be disabled by Apache because you can have some significant performance problems otherwise, especially when combined with delayed ack. There have been several papers done on this, in addition to common sense experience. I am not sure what version of Apache you are talking about, but I find this difficult to see in 1.2.x because all CGI is buffered unless they deliberately avoid that with a nph- script. In 1.3, it isn't buffered but that is a design decision made on purpose. The CGI needs to deal with being sure it doesn't do silly things, eg. use stdio to avoid it. Apache is quite good at ensuring that it gathers stuff into one write (well, writev) where possible. In fact, it goes so far that it exposes bugs in Navigator where it breaks when the response headers are the wrong length and are in the same packet as the body of the response. Disabling Nagle wasn't the problem here, the problem was the CGI.
Re: Found out why diablo's dnewslink had non-optimal performance
Author: Garrett Wollman
Date: Mon, 16 Feb 1998 00:00
Date: Mon, 16 Feb 1998 00:00
38 lines
2467 bytes
2467 bytes
In article <34E8D894.8FB0ACFD@spinne.com>, Jeff Garzik <jeff.garzik@spinne.com> wrote: >If your OS is smart, write() and writev() will dump into the TCP >buffer. If your feeder is fast (and the TCP buffer large), you can keep >the buffer full enough so that a packet contains more than a single >CHECK. Traditional TCP implementations (read: 4BSD) send one packet with the PSH bit set for every write when congestion-control allows it to send at least that much data. If you have an operating system which implements Transaction TCP along the lines of the Reference Implementation (e.g., FreeBSD), you can set TCP_NOPUSH to disable this behavior. I have not tried it to see what sort of effect, if any, this has on dnewslink. (My hacked dnewslink uses FreeBSD-current's poll(2) option POLLEXTEND to watch the queue files; it's quite impressive to see the ``thundering herd'' awaken immediately in systat whenever an article comes in. It also uses setproctitle() to set the process title to something useful, and I am currently trying out TCP_NODELAY to see what effect, if any, it has. My previous experience was that, when dnewslink is talking to my fast peers, little streaming happens---I send at most four or five CHECKs, and they all reply ``no thanks'' to all of them immediately, returning the connection to idle state. My modification is a little too aggressive in that it sets TCP_NODELAY even for non-realtime feeds, which is a waste.) -GAWollman -- Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same wollman@lcs.mit.edu | O Siem / The fires of freedom Opinions not those of| Dance in the burning flame MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick
Re: Found out why diablo's dnewslink had non-optimal performance
Author: Jeff Garzik
Date: Tue, 17 Feb 1998 00:00
Date: Tue, 17 Feb 1998 00:00
29 lines
2025 bytes
2025 bytes
Olaf Titz wrote: > Matt Dillon <dillon@best.net> wrote: > > The reason you don't usually want to use TCP_NODELAY is because it > > basically allows hundreds of unacked short packets to be in transit all > > at once, even with nagle enabled. > > TCP_NODELAY does mean "disable Nagle". [...] > No; this exactly happened because Nagle was disabled. > Still the proper way to deal with this situation is buffering writes > on the application level. (For the CGI example, if the program is > written in perl, it should use perl's internal buffers and leave $| to > 0, but unfortunately this can collide with e.g. output from "system" > (I had this problem once) or collide with fork, since perl lacks an > fflush(stdout) operation.) Should not disable Nagle. Especially if your router has congestion control based on packet counts. If your OS is smart, write() and writev() will dump into the TCP buffer. If your feeder is fast (and the TCP buffer large), you can keep the buffer full enough so that a packet contains more than a single CHECK. -- Jeff Garzik Typhoon, Cyclone, Diablo, and INN http://www.spinne.com/usenet/ News tuning and consulting
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads