Re: What kind of harm are idle threads causing?



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
.



Relevant Pages

  • Re: What kind of harm are idle threads causing?
    ... decrease the number of worker threads rather than just always running ... the maximum amount of worker threads? ... and, in the case of Windows, thread handles? ... forcing the scheduler to schedule each thread just so it can see ...
    (comp.programming.threads)
  • Re: Jobs dont run and are stuck with request pending
    ... > SQL Agent log when you run out of job worker threads. ... > - sometimes it's on emailing results and mail gets hung up. ... If the scheduler gets ... >>The job history does not show anything out of the ordinary. ...
    (microsoft.public.sqlserver.server)
  • Re: What kind of harm are idle threads causing?
    ... decrease the number of worker threads rather than just always running ... the maximum amount of worker threads? ... XP built in thread pools aren't adequate for my application and I'm ... Virtual address space usage is one of the biggest issues. ...
    (comp.programming.threads)
  • Re: Forcing a thread to use a specific processor?
    ... allowable set, the scheduler is free to run any thread on any processor, and that thread ... but the worker threads to run on any processor ... but not make the GUI ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • [patch] CFS scheduler, -v7
    ... i'm pleased to announce release -v7 of the CFS scheduler patchset. ... interactivity fix: ... waiting to get on the CPU, the maximum amount of time it was blocked ...
    (Linux-Kernel)