Completion ports and sockets - scaling my app
- From: Natscha Heumann <HaNeu@xxxxxx>
- Date: Wed, 28 Dec 2005 15:16:06 +0100
Hi,
I got some serious problems understanding the behaviour of socket-related iocps driven by multiple threads.
I post some sends without waiting for their completion. Lets assume 2 chunks of data.
First chunk 1 is put on his way by WSASend(). The send could not be satisfied in one call so only a part of the data could be sent and the rest has to be sended again.
Thread 1 gets an IO-completion packet about the partial send and tries to send the rest. Right after receiving the completion packet for that send and before calling the WSASend for the rest of the data, the thread is preemted.
The second thread sends chunk 2, so the data will be corrupted, won't they?
So after considering this would it not be better to have only ONE outstanding send? Better wait for completion of one send before scheduling the next?
Using sync-objects wouldn't make things better, I have to wait anyway for copletion of the send.
There is the great article in MSDN
Windows Sockets 2.0: Write Scalable Winsock Apps Using Completion Ports by Anthony Jones and Amol Deshpande which states:
"
However, a high-performance server application can turn off the send buffering, yet not lose performance. Such an application must, however, take great care to ensure that it posts multiple overlapped sends, instead of waiting for one overlapped send to complete before posting another. If the application posts overlapped sends in a sequential manner, it wastes the time window between one send completion and the posting of the next send. If it had another buffer already posted, the transport would be able to use that buffer immediately and not wait for the application's next send operati"
How can I post multiple overlapped sends without corrupting my data? By implementing some kind of sequence numbering scheme?
.
- Follow-Ups:
- Re: Completion ports and sockets - scaling my app
- From: Roger Hunen
- Re: Completion ports and sockets - scaling my app
- From: Eugene Gershnik
- Re: Completion ports and sockets - scaling my app
- Prev by Date: Re: False indication of Firewall status by get_FirewallEnabled()
- Next by Date: Re: Completion ports and sockets - scaling my app
- Previous by thread: Re: False indication of Firewall status by get_FirewallEnabled()
- Next by thread: Re: Completion ports and sockets - scaling my app
- Index(es):
Relevant Pages
|