in reply to Re: Threading and join/termination question
in thread Threading and join/termination question
That’s a very-terse example of a million-dollar idea. (Great example if you’re a serious Perl-head ... not-so-easy if you’re not.)
The idea is this: instead of defining “a thread” as corresponding to “a unit of work to be completed,” and then trying to “limit the number of” those threads, create a pool of threads, calling each one of them “workers.” Then, give those workers a production-line queue of things-to-do. Each worker grabs a request off of the production-line, does it, shoves the results downstream somewhere, and then grabs another one ad infinitum, surviving until the production-line finally runs dry. The number-of-workers (thread-pool size) should correspond to the maximum number of such units-of-work that you know this piece of hardware can predictably accomplish. So, whether the production-line queue might be short or long, you remain confident that the work is being carried-out as fast as possible ... no matter how short or long the queue might be, the “completed units-of-work per second” will remain steady. If you are gifted with faster hardware, you simply turn-up the number-of-workers knob a little bit more. (And if you are gifted with a cluster of units, spread the work out among all the CPUs you have, so-many workers apiece.)
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Threading and join/termination question
by SimonPratt (Friar) on Aug 01, 2014 at 10:27 UTC | |
|
Re^3: Threading and join/termination question
by cormanaz (Deacon) on Aug 01, 2014 at 12:54 UTC | |
by SuicideJunkie (Vicar) on Aug 01, 2014 at 15:16 UTC |