Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WSASend or send performance, in overlapped manner or buffered?

268 views
Skip to first unread message

Bae, Hyun-jik

unread,
Jul 3, 2001, 6:34:09 AM7/3/01
to
Hi,

I recently found that WSASend and send takes a lot of CPU power.

These are the conditions what I've tested with my application:

200 concurrent clients connecting to server
one TCP and UDP socket endpoint between a client and server
server app runs on Windows 2000 Server + P-450, 256MB RAM.
clients sends 1 TCP messages and 4 UDP messages to server and receives 10
TCP messages and 40 UDP messages from server as reply.
server app does nothing except for receiving messages from client and sends
it to 5% of connected clients.
The server receives messages in overlapped I/O manner with Completion Port,
and sends messages in traditional blocked send with winsock-internal send
buffer.

The results are:
server consumes about 60% of its CPU work!!
It may seem to be a serious cost, considering I'd expected about 2000
simultaneous clients easily. However, when I let the server app reply the
messages to only one client rather than 5% of everyone, the server app
consumes only 1% of its CPU work.
I also did the source code level profiling and found that 90% of server work
is WSASend() or send().

Thus, WSASend and send() are very heavy methods, I concluded. However, I
should fix the problem. How can I solve it? I am just guessing sending
messages in overlapped I/O manner with completion port as it already works
on receiving will get better performance, but I'm not sure, as it is just a
guess.

Please reply, thanks in advance.

Bae, Hyun-jik

Sean Kelly

unread,
Jul 3, 2001, 12:55:15 PM7/3/01
to
"Bae, Hyun-jik" <ba...@oz.co.kr> wrote in message
news:Bch07.17$2k2....@news.bora.net...

> Hi,
>
> I recently found that WSASend and send takes a lot of CPU power.

No it doesn't.

> The server receives messages in overlapped I/O manner with Completion
Port,
> and sends messages in traditional blocked send with winsock-internal send
> buffer.

Why don't you just send via completion ports as well?

> The results are:
> server consumes about 60% of its CPU work!!
> It may seem to be a serious cost, considering I'd expected about 2000
> simultaneous clients easily. However, when I let the server app reply the
> messages to only one client rather than 5% of everyone, the server app
> consumes only 1% of its CPU work.
> I also did the source code level profiling and found that 90% of server
work
> is WSASend() or send().

Odd. How large are your buffers? Did yo turn off internal buffering?

> Thus, WSASend and send() are very heavy methods, I concluded. However, I
> should fix the problem. How can I solve it? I am just guessing sending
> messages in overlapped I/O manner with completion port as it already works
> on receiving will get better performance, but I'm not sure, as it is just
a
> guess.

What I do is maintain a send queue per socket. The completion method will
loop sending the current message until it's done, then pull the next one off
the queue and send that. So I have a 2 overlapped structures per socket
(one for send, one for recv). I haven't done the degree of testing that you
have, but my normal cpu load for a chat client I threw together for testing
is essentially zero. I'll have to hammer it and see how it scales.

Sean


Bae, Hyun-jik

unread,
Jul 3, 2001, 8:54:07 PM7/3/01
to
Thanks for your answer.
My server app already has send buffers, about 64KB per each socket, and sets
'send timeout' to 0, which guarantees blocked sending except for queueing
messages. (My server app is a kind of dedicated server so we can assume the
server machine has a lot of RAM, usually 512MB. so 64KB for each socket
doesn't matter.)
Of course, WSASend() and send() returns immediately, even if when more than
200 clients are accepted simultaneously. (Note that you cannot see this
result if you test with your own application, if you don't run it in windows
2000 server such as w2k pro or win9x.) However, the more clients are
accepted to server, the more CPU power is consumed exponentially! The server
works lightly until 200 clients are accepted and receives 40 messages from
server.

"Sean Kelly" <ken...@pacbell.net> wrote in message
news:DNm07.24$aO1....@news.pacbell.net...

0 new messages