windows - How to set up a thread pool for an IOCP server with connections that may perform blocking operations -


i'm working on server application that's written in proactor style, using select() + dynamically sized thread pool (there's simple mechanism based on keeping track of idle worker threads).

i need modify use iocp instead of select() on windows, , i'm wondering best way utilize threads is.

for background information, server has stateful, long-lived connections, , request may require significant processing, , block. in fact, requests call customer-written code, may block @ will.

i've read os can tell when iocp thread blocks, , unblock one, doesn't there's support creating additional threads under heavy load, or if many of threads blocked.

i've read 1 site suggested have small, fixed-size thread pool uses iocp deal i/o only, sends requests can block another, dynamically-sized thread pool. seems non-optimal due additional thread synchronization required (although can use iocp tasks second thread pool), , larger number of threads needed (extra context switching).

is best way?

it sounds you've read 1 of articles on iocp (most this one). that's bit out of date whole problem sort avoid (that of i/o being cancelled if thread issued exits before i/o completes) no longer problem of microsoft's supported os's (it's issue on xp , before).

you're correct in noticing design 2000/2002 sub optimal context switching point of view; worked pretty @ time, given constraints of underlying api.

on modern os there's no real advantage in having separate thread pools i/o , blocking work. more modern solution involve dynamically expanding , reducing number of i/o threads servicing iocp required.

you'd need track number of iocp threads active (i.e. not waiting on getqueuedcompletionstatus() ) , spawn more when there "too few". likewise thread go , wait on gqcs check see if have "too many" , if so, let die instead.

i should update articles.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -