How about Threads and IOCP Efficient Design,other IOCP per thread?



i have developed a server to do I/O for video/audio from remote peers.
the server works based on IOCP(IO Completion Port) and Overlapped async for
all I/O s and TCP socket.

Recently I have a dead problem in my test.
the problem is followed on the last of this writtings.

First i would say about the design for my server application.
the server have five worker threads associated with each IOCPs(not global
single IOCP)
that threads are one for connections, one for I/O, one for processing packets,
one for I/O to Database, and last for report logs to Central Manager Server.
in this case, the important thing is that threads work on each other IOCPs.
that is, the server has five IOCPs.

What i worry is while a worker thread is busy how safe and fast the each
IOCP can control the own thread when a I/O Bound

Completion occurs?

I have known that IOCP manages good itself a thread pool for threads
associated and can handle N concurrent threads by

allowing the Application to pass number to NumberOfConcurrentThreads
parameter in CreateIoCompletionPort API call.
so worker threads more than one can be run then it can handle fast without
delaying for another waiting I/O.

I can see following from MS KB Q192800 allocated on
http://support.microsoft.com/kb/192800
"You can decide to have a maximum of 2 concurrent threads used by the IOCP
and a pool of 10 worker threads. You have a pool of

worker threads greater than or equal to the number of concurrent threads
used by the IOCP so that a worker thread handling a

dequeued completion packet can call one of the Win32 "wait" functions
without delaying the handling of other queued I/O

packets.

If there are completion packets waiting to be dequeued, the system will wake
up another worker thread. Eventually, the first

thread satisfies it's Wait and it can be run again. When this happens, the
number of the threads that can be run is higher

than the concurrency allowed on the IOCP (for example,
NumberOfConcurrentThreads). However, when next worker thread calls

GetQueueCompletionStatus and enters wait status, the system does not wake it
up. In other words, the system tries to keep your

requested number of concurrent worker threads. " --Q192800--

Now I say the first issue.
My server well works on almost I/O transaction in slack term.
But the server is shutdowned on a lot of video data in speed.
the socket to client on server side is closed.
a packet contains video data has size of 3500 ~ 5000 bytes several time.

the error codes i can get when returned are 64(ERROR_NETNAME_DELETED) by
GetQueuedCompletionStatus
then after 183(ERROR_ALREADY_EXISTS) by WSAGetLastError.
In the client application too, socket is closed with code 0 returned.
here is two doubt points, the one is why the TCP socket is closed? another
is why the application is shutdowned only after

socket is closed?

i would say simple that process flow.
A is Connection(accept call) thread.
it post a IOCP packet with the socket handle accepted to B by
PostQueueCompletionStatus call.

B is thread to associate the socket returned from A to IOCP and I/O
start(receive/send call)
it post a IOCP packet with a I/O buffer handler completed to C by
PostQueueCompletionStatus call.
if a socket is closed, it post a IOCP packet to A then A cleanup all
information for a socket.

C is thread to handle packets from I/O packets is completed from B
it post a IOCP packet with new a I/O buffer to B to start I/O by
PostQueueCompletionStatus call.
or post a IOCP packet with new Database work to D

D is thread to handle I/O to Database Server.
E is thread to report server status to Central Manager Server.

where is the cause from?


there seems to be some problem for me to get a IOCP and Thread Design.
i think there are the problem that worker threads can't be safe to wait and
resume by IOCP
because the each IOCP handle only a thread so it does not get a real thread
pool.

All of the woker threads share a single IOCP is good way to get a higher
performance from IOCP? and what is the great design?

Thanks in Anybody, Any answer

.



Relevant Pages

  • Re: condvar for win32?
    ... and I did not want to tie that up for anything but I/O. ... > an IOCP queue is limited my the amount of non-paged memory... ... I want to maximize the number of connections, and the number of pending I/O operations the server can handle. ... If you have 50,000 connections and each connection has multiple overlapped sends and recvs going, and perhaps multiple disk reads and writes, well, the non-paged memory becomes a major issue indeed. ...
    (comp.programming.threads)
  • Re: The rationale for IOCP
    ... > that doesn't perform I/O. ... Running the kernel out of kernel memory will affect everything. ... say that it would probably count IOCP memory against that same pool. ... OSes likely won't read it into the TCP stream buffer either. ...
    (comp.programming.threads)
  • Mysql Server Optimierung INNODB
    ... Der Server ist ein Intel DualCore mit 12GB Ram und das Filesystem ist ein ReiserFS mit angeschlossenenem RAID5. ... default-table-type = INNODB ... I/O thread 0 state: waiting for i/o request ... waiting for i/o request (log thread) ...
    (de.comp.datenbanken.mysql)
  • Re: Memory Manager Tests - using 512 Threads
    ... > non-blocking TCP server hits a limit of connections it can handle. ... I am handling the same number of connections with 16 as with 512 threads, ... with IOCP. ... compressed and encrypted before being sent to the Server. ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: R: GOBACK (was: Perform Thru/Go to vs. Perform - Compile Speed
    ... the simplest form of I/O multiplexing is unfortunately ... a server running on Unix or Windows. ... and they often use multithreading unwisely. ... it doesn't waste any CPU time - the server only uses CPU ...
    (comp.lang.cobol)