W
William Stacey [MVP]
I gotta tell ya Chad, you made me see a new light on this. I went and put
together a virtual socket class that "creates" packets for reading and
created two tests. First test is creating X number of threads and one
socket per thread that reads N number of packets. Second test was creating
same number of sockets in a object that manages the sockets in a collection
and posts an event that a worker thread(s) waits on. Results vary based on
syncing threads with a shared object (i.e. a fake write queue for example)
that you can set to sleep and/or spinWait. I could get ~20,000 threads
running pretty well. Trying to start 30,000 locked up my app each time, but
could just stop it in TaskManager without a crash. I never saw TaskManager
Threads go over ~571, so not sure if that is just showing running threads or
if CLR only releases so many OS threads and does some other management in
the background. Very suprising results. It's not a clear winner in all
cases and not sure of effects of running 1000+ threads for long time in a
server app, but these results are interesting. If anyone wants to play with
this test harness, I can post it to web. It fun to play with different
options to see time effects of injecting sleeps or waits, etc. Cheers!
together a virtual socket class that "creates" packets for reading and
created two tests. First test is creating X number of threads and one
socket per thread that reads N number of packets. Second test was creating
same number of sockets in a object that manages the sockets in a collection
and posts an event that a worker thread(s) waits on. Results vary based on
syncing threads with a shared object (i.e. a fake write queue for example)
that you can set to sleep and/or spinWait. I could get ~20,000 threads
running pretty well. Trying to start 30,000 locked up my app each time, but
could just stop it in TaskManager without a crash. I never saw TaskManager
Threads go over ~571, so not sure if that is just showing running threads or
if CLR only releases so many OS threads and does some other management in
the background. Very suprising results. It's not a clear winner in all
cases and not sure of effects of running 1000+ threads for long time in a
server app, but these results are interesting. If anyone wants to play with
this test harness, I can post it to web. It fun to play with different
options to see time effects of injecting sleeps or waits, etc. Cheers!