Threadpool

Topics: Developer Forum
Jan 23, 2007 at 5:53 AM
I noticed that you use .NET thread pool. In some cases, especially with poor written handlers, which block a thread, it may cause thread pool exhaustion. Do you plan to add support for custom thread pools, like CCR has?

Thanks for the great work
Jan 24, 2007 at 11:51 AM
I'd vote for this too, because it allows you to isolate some thread pools from each other, i.e. you might want a small thread pool to service blocking calls you can't refactor e.g. remote DCOM calls. A separate thread-pool allows you to avoid the starvation issues.

You can address this in other ways, perhaps by having a throttling dispatcher queue, which allows only n max items to be active at any one time. I believe the CCR has something like this, but I've never used at it.

Coordinator
Jan 24, 2007 at 8:36 PM
"I noticed that you use .NET thread pool. In some cases, especially with poor written handlers, which block a thread, it may cause thread pool exhaustion. Do you plan to add support for custom thread pools, like CCR has?"

This is in reply to both. The answer is yes. I wanted to work out the kinks before injecting another variant in the mix. I am currently does some re-arch on the core that will hopefully make it cleaner and maybe a bit faster.

As you point out, unless your doing blocking operations in the handler(s), this should never be an issue as work just queues up and it handled as cpu's become available. The TP does a pretty good job here.

A custom TP is a nice option to have, when you have a special need. The one down side is, we can't currently do as good a job as the TP because, TMK, you can't get to that low level to know when to kick off another thread because a running thread blocked. It can probably be done, but I don't know how. I have a pretty good implementation somewhere that I spent some time on somewhere. I will add this as a work item.
Coordinator
Jan 24, 2007 at 9:37 PM
This discussion has been copied to Work Item 7605. You may wish to continue further discussion there.