Re: What kind of harm are idle threads causing?
- From: JC <jason.cipriani@xxxxxxxxx>
- Date: Wed, 24 Dec 2008 19:17:57 -0800 (PST)
On Dec 22, 3:35 pm, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:
On Dec 22, 3:03 am, JC <jason.cipri...@xxxxxxxxx> wrote:
If I have a thread pool, why do I want to dynamically increase /
decrease the number of worker threads rather than just always running
the maximum amount of worker threads?
This is on Windows, and unused worker threads are just blocking in
WaitForSingleObject calls. Are they really causing any harm? Usually
the rationale I see for not having so many idle threads sitting around
is "they take up system resources"... what does that actually mean?
Are they taking up any resources aside from trivial amounts of memory
and, in the case of Windows, thread handles?
Right, memory and thread handles. On Windows, it's not that big a
deal.
I am trying to write a thread pool implementation because the Windows
XP built in thread pools aren't adequate for my application and I'm
mostly wondering if there's any compelling reason to implement logic
that grows and shrinks the thread pool.
Just make sure you can avoid a thundering herd problem. When an event
occurs that one thread can handle, you don't want 35 threads waking
up, forcing the scheduler to schedule each thread just so it can see
that the event was already handled and it needs to go back to sleep.
Idle threads are not a big deal if you can avoid thundering herds.
DS
Good advice, thanks!
JC
.
- References:
- What kind of harm are idle threads causing?
- From: JC
- Re: What kind of harm are idle threads causing?
- From: David Schwartz
- What kind of harm are idle threads causing?
- Prev by Date: Re: What kind of harm are idle threads causing?
- Next by Date: Re: Why are Boost thread mutexes so slow compared to Pthreads?
- Previous by thread: Re: What kind of harm are idle threads causing?
- Next by thread: Re: What kind of harm are idle threads causing?
- Index(es):
Relevant Pages
|