<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Making things go fast on a network, part 2</title><link>http://blogs.msdn.com/b/larryosterman/archive/2006/05/15/598181.aspx</link><description>Sorry about the delay - I got nailed by a nasty sinus infection on Tuesday night last week that took me out until today. 
 
 In my last post I started discussing some of the aspects of networking that need to be understood before you can make things</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title> Larry Osterman s WebLog Making things go fast on a network part 2 | storage bench</title><link>http://blogs.msdn.com/b/larryosterman/archive/2006/05/15/598181.aspx#9782543</link><pubDate>Fri, 19 Jun 2009 11:00:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9782543</guid><dc:creator> Larry Osterman s WebLog Making things go fast on a network part 2 | storage bench</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://thestoragebench.info/story.php?id=62"&gt;http://thestoragebench.info/story.php?id=62&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9782543" width="1" height="1"&gt;</description></item><item><title> Larry Osterman s WebLog Making things go fast on a network part 2 | Weak Bladder</title><link>http://blogs.msdn.com/b/larryosterman/archive/2006/05/15/598181.aspx#9717218</link><pubDate>Tue, 09 Jun 2009 21:45:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9717218</guid><dc:creator> Larry Osterman s WebLog Making things go fast on a network part 2 | Weak Bladder</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://weakbladder.info/story.php?id=5204"&gt;http://weakbladder.info/story.php?id=5204&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9717218" width="1" height="1"&gt;</description></item><item><title>I wish Larry hadn't written that...</title><link>http://blogs.msdn.com/b/larryosterman/archive/2006/05/15/598181.aspx#648107</link><pubDate>Tue, 27 Jun 2006 07:13:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:648107</guid><dc:creator>Tales from the Crypto</dc:creator><description>Oh, Larry, Larry, Larry...&lt;br&gt;Articles 1 and 2 were great - really necessary reading to a lot of would-be...&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=648107" width="1" height="1"&gt;</description></item><item><title>re: Making things go fast on a network, part 2</title><link>http://blogs.msdn.com/b/larryosterman/archive/2006/05/15/598181.aspx#629572</link><pubDate>Tue, 13 Jun 2006 18:19:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:629572</guid><dc:creator>Tom H</dc:creator><description>Larry, the axioms you've stated are all true, but then I guess I didn't understand the rule:&lt;br&gt;&lt;br&gt;&amp;quot;Always make sure that you have a receive request down BEFORE someone tries to send you data.&amp;quot;&lt;br&gt;&lt;br&gt;From what Dave's said above, and your agreement with him, I interpret this as being that you should have let the OS know what buffer to put the data in before the network delivers the data. That makes perfect sense in a high-performance application, but I didn't have a clue what &amp;quot;hav[ing] a receive request down&amp;quot; meant, and even after your explanation I wonder if that is NetBEUI terminology?&lt;br&gt;&lt;br&gt;I remember lots of research at UCSD in the early 1990s about reducing buffer copies and boundary crossings when you receive network packets. Good to know that some of it seems to have seen light. This kind of optimization sounds much easier to do with transport protocols that expose the frame explicitly, like UDP and (according to Google?) NetBEUI, but I suppose you could do it in TCP too, even though the application can't see frame boundaries.&lt;br&gt;&lt;br&gt;But in TCP, the implementation is really expected to have buffer space in the OS, and the flow control protocol lets the client know how much buffer space there is, so you should never see the &amp;quot;No Memory&amp;quot; kind of response. The drawback is that the protocol had some trouble with high bandwidth-delay connections (standard flow control only allows 64kB of buffer space), but I think they've extended around that by now.&lt;br&gt;&lt;br&gt;(You refer to corrolaries and rules, but I see only the one rule bolded or otherwise picked out between this and the previous post - am I missing something?)&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=629572" width="1" height="1"&gt;</description></item><item><title>re: Making things go fast on a network, part 2</title><link>http://blogs.msdn.com/b/larryosterman/archive/2006/05/15/598181.aspx#629072</link><pubDate>Tue, 13 Jun 2006 06:59:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:629072</guid><dc:creator>Larry Osterman [MSFT]</dc:creator><description>Dave's absolutely right - you don't have to have the receive down, unless you care about perf. &amp;nbsp;If you care about perf, then the additional data copy can kill your perf. &amp;nbsp;After all, what would you rather your CPU be doing - copying data from an in-kernel buffer or doing work in your application? &amp;nbsp;If you want the CPU to be doing your work, get the receive down before the sender sends it.&lt;br&gt;&lt;br&gt;&lt;br&gt;Tom, you're right, my knowledge IS NetBEUI-centric, but I think you'll discover that the principles involved apply on TCP. &amp;nbsp;The details are absolutely different (TCP's sliding windows are based on offsets, not packet sequence numbers, etc) but at a high enough level it doesn't matter.&lt;br&gt;&lt;br&gt;In particular, the axioms, corrolaries and rules I've mentioned apply pretty-much universally.&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=629072" width="1" height="1"&gt;</description></item><item><title>re: Making things go fast on a network, part 2</title><link>http://blogs.msdn.com/b/larryosterman/archive/2006/05/15/598181.aspx#621215</link><pubDate>Thu, 08 Jun 2006 00:51:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:621215</guid><dc:creator>Dave Beaver</dc:creator><description>Reply to nick about recv:&lt;br&gt;&lt;br&gt;Yes, it's not necessary to get the receive down before the data arrives at the node. But the focus of these articles is speed, and if you're interested in speed, you want to have that receive in place. Why? Because the OS will go out of it's way to land the data into the buffer you provide as it's received. It does this for the obvious efficiency reasons; if it doesn't, a data copy is required to get the data from the transport buffer to the application buffer. And that copy is relatively expensive.&lt;br&gt; Note that this apparently even more true in Vista/Longhorn, from my (admittedly brief) looks at it so far.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=621215" width="1" height="1"&gt;</description></item><item><title>re: Making things go fast on a network, part 2</title><link>http://blogs.msdn.com/b/larryosterman/archive/2006/05/15/598181.aspx#606642</link><pubDate>Thu, 25 May 2006 04:14:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:606642</guid><dc:creator>Andreas Johansson</dc:creator><description>I don't think there are many developers today that actually get this. They are using abstractions that hide all this. Really nice to get it mentioned.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=606642" width="1" height="1"&gt;</description></item><item><title>re: Making things go fast on a network, part 2</title><link>http://blogs.msdn.com/b/larryosterman/archive/2006/05/15/598181.aspx#600961</link><pubDate>Thu, 18 May 2006 16:59:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:600961</guid><dc:creator>Tom H</dc:creator><description>Here again, Larry, I think your presentation may be NetBEUI-centric (or some other protocol that I'm not familiar with). TCP handshaking establishes a receive window size; the sender can't send until it knows there's a nonzero receive window. Stevens has a basic discussion of this in Chapter 20 of Volume 1 of TCP/IP Illustrated and spends some time talking about bandwidth-delay product and determining the optimum window size.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=600961" width="1" height="1"&gt;</description></item><item><title>re: Making things go fast on a network, part 2</title><link>http://blogs.msdn.com/b/larryosterman/archive/2006/05/15/598181.aspx#600072</link><pubDate>Wed, 17 May 2006 20:02:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:600072</guid><dc:creator>mjb</dc:creator><description>maybe I'm being obtuse, but shouldnt the last Send Request of A.1 (of 3) have gotten an ACK?&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=600072" width="1" height="1"&gt;</description></item><item><title>re: Making things go fast on a network, part 2</title><link>http://blogs.msdn.com/b/larryosterman/archive/2006/05/15/598181.aspx#599681</link><pubDate>Wed, 17 May 2006 10:22:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:599681</guid><dc:creator>nick</dc:creator><description>&amp;quot;Always make sure that you have a receive request down BEFORE someone tries to send you data.&amp;quot;&lt;br&gt;&lt;br&gt;Thats why you have per-connection receive buffers in OS-es, unless you turn them off (set the buffer size to 0 for a connection). For instance, on Windows, Winsock sets up an initial buffer for both receives and sends....I believe the default buffer sizes are ~ 32 KB, I might be mistaken (easy to check with getsockopt).&lt;br&gt;&lt;br&gt;So there's no desperate need to race to use a recv on a TCP client application for example. Just make sure you always have a recv posted *before* the recv buffer fills up. &lt;br&gt;&lt;br&gt;As you said, servers and clients are symmetrical in this respect (i.e. once the initial handshake is done) so the above observations apply equally to them.&lt;br&gt;&lt;br&gt;From an MSDN article on writing Scalable apps&lt;br&gt;[ &lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/msdnmag/issues/1000/Winsock/"&gt;http://msdn.microsoft.com/msdnmag/issues/1000/Winsock/&lt;/a&gt; ]&lt;br&gt;&amp;quot;As just mentioned, AFD.SYS handles buffer management for applications that use Winsock to talk to the transport protocol drivers. This means that when an application calls the send or WSASend function to send data, the data gets copied by AFD.SYS to its internal buffers (up to the SO_SNDBUF setting) and the send or WSASend function returns immediately. The data is then sent by AFD.SYS behind the application's back, so to speak. Of course, if the application wants to issue a send for a buffer larger than the SO_SNDBUF setting, the WSASend call blocks until all the data is sent.&lt;br&gt;Similarly, on receiving data from the remote client, AFD.SYS will copy the data to its own buffers as long as there is no outstanding data to receive from the application, and as long as the SO_RCVBUF setting is not exceeded. When the application calls recv or WSARecv, the data is copied from AFD.SYS's buffers to the application-provided buffer.&amp;quot;&lt;br&gt;&lt;br&gt;and&lt;br&gt;&lt;br&gt;&amp;quot;Turning off receive buffering in AFD.SYS by setting SO_RCVBUF to 0 offers no real performance gains. Setting the receive buffer to 0 forces received data to be buffered at a lower layer than Winsock. Again, this leads to buffer copying when you actually post a receive, which defeats your purpose in turning off AFD's buffering.&amp;quot; &lt;br&gt;NOTE: You also can get major perf loss if you do this and then fail to post recvs in a timely fashion.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=599681" width="1" height="1"&gt;</description></item></channel></rss>