Re: CAsyncSocket and performance issues
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Thu, 31 Mar 2005 13:11:25 -0500
The Nagel Algorithm is one reason the OP can't depend on reading 8 bytes and getting all
the data. Other reasons include basic packetizing, network packet delays, flow control in
the lower-level TCP stack.
I had a 100-Base-T network (now I have 1G) but with that network and three machines
feeding data in to me, I saturated at 1300 packets/min, with an average packet size of 80.
I believe this was due to the fairly heavy-duty processing time each packet required, but
our benchmark was a customer required a minimum of 400/min, so we were within the required
performance with lots of headroom, so I never investigated beyond that.
The suggestion of updating the progress bar based on a timer is a good one, and you should
look into that as well, if it turns out the progress bar update is the performance
bottleneck.
joe
On Wed, 30 Mar 2005 21:46:45 -0700, Jerry Coffin <jcoffin@xxxxxxxxx> wrote:
>In article <1112239522.811192.171640@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
>danceswithbikers@xxxxxxxxxxx says...
>
>[ ... ]
>
>> Well, I thought about this, but from my perspective, it seemed as
>> though I was just adding another layer of bufferage that would only add
>> to the overhead. After all, ever call to Receive() draws on a buffer.
>> What good does it do to draw from one buffer and write to another? You
>> see what I'm saying? Are you quite sure that this principle is
>> irrelevant to tcp/ip subsystems?
>
>There's extra overhead in making extra copies. There's also, however,
>overhead when you make a call to Windows to read data. Copying more
>data at a time adds overhead in one place but reduces it in the
>other.
>
>The question is whether the reduction is greater than the increase or
>vice versa. My guess is that it'll reduce the overhead (a lot) in
>this case.
>
>> Similarly, even though out-going CChunks are usually only 15 bytes
>> or so long, I assumed that the CPU would be sending them out so fast,
>> that overtime, a large collection of them would form one large packet.
>> Perhaps I was wrong. Perhaps each successful, or partially successful,
>> write to a socket produces exactly one packet.
>
>This is what the Nagel algorithm does. It's also "smart" enough to be
>fairly smart about how long it waits accumulating data before it
>sends out a packet.
>
>Sending tiny amounts at a time still has overhead though, much like
>above: even though it's accumulating enough data to send out packets
>of reasonable size (saving overhead in what's transmitted over the
>wire) switches from user mode to kernel mode and back still have
>overhead in CPU usage, and it sounds like you're probably doing them
>pretty frequently.
>
>> I suppose that is something I could buffer. Rather than increasing
>> the progress bar every 20 bytes, I could accumulate an offset value and
>> update the bar every 15k or so.
>
>I wouldn't do either one. No matter what amount you pick, it's going
>to be ridiculous in some situation -- if you pick large enough chunks
>to make sense on 10 Gigabit Ethernet, it'll only update every few
>hours if somebody runs the program over a dial-up connection. If you
>go the other direction, and update often enough to make sense over a
>dial-up connection, it'll end up trying to update thousands of times
>per second over a fast network.
>
>Instead, I'd consider simply setting a timer for somewhere between
>100 and 1000 milliseconds, and update the progress control when it
>fires, regardless of how much data that happens to represent. This
>automatically updates the display at a reasonable rate regardless of
>connection speed. Exactly how fast you decide to update in that range
>is mostly a matter of taste -- 100 ms is really faster than most
>people can read the updates, so it gives an impression of things
>really "moving", even if they're not. Updating once a second gives a
>more "relaxed" feel to things, even though it reduces CPU usage, so
>the transfer itself might be moving a tiny bit faster.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: CAsyncSocket and performance issues
- From: Jerry Coffin
- Re: CAsyncSocket and performance issues
- References:
- CAsyncSocket and performance issues
- From: danceswithbikers@xxxxxxxxxxx
- Re: CAsyncSocket and performance issues
- From: Michael K. O'Neill
- Re: CAsyncSocket and performance issues
- From: danceswithbikers@xxxxxxxxxxx
- Re: CAsyncSocket and performance issues
- From: Jerry Coffin
- CAsyncSocket and performance issues
- Prev by Date: Re: CAsyncSocket and performance issues
- Next by Date: Re: How to copy a CString to const char*
- Previous by thread: Re: CAsyncSocket and performance issues
- Next by thread: Re: CAsyncSocket and performance issues
- Index(es):
Relevant Pages
|