comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: asynchronous task communication
Date: Mon, 31 Dec 2012 16:15:49 -0600
Date: 2012-12-31T16:15:49-06:00	[thread overview]
Message-ID: <kbt2qq$9es$1@munin.nbi.dk> (raw)
In-Reply-To: aked87Fpfc1U1@mid.individual.net

"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message 
news:aked87Fpfc1U1@mid.individual.net...
> On 12-12-31 20:52 , Charles Hixson wrote:
>> Thank you for your answer.
>>
>> The problem with that solution is that I've been advised that I
>> shouldn't have many more tasks than available cores,
>
> IMO that advice is useful only if your application logically needs fewer
> tasks than you have cores, but you want to increase the number of tasks
> in order to have more cores running in parallel. It can then make sense
> to replicate some of your tasks (the "pool of worker tasks" idea), so
> that several identical tasks work in parallel on the same kind of jobs,
> or to split some of your tasks into smaller tasks that work in parallel
> on different consecutive steps of a job (the "task pipeline" idea).
>
> As you increase the number of tasks in this way, performance increases
> because more tasks can be run in parallel, until you reach one of two
> bounds:
>
> 1. new tasks have nothing to do, and just wait for input or for some
> other task to do something, or
>
> 2. all cores are already busy, on average, so new tasks must wait for a
> core to become free.
>
> Case (1) means that your application is somehow "I/O bound" or
> "communication bound", while case (2) means that your application is
> "computation bound". The advice you got applies to case (2).
>
> But if your application logically needs more tasks than there are cores,
> because of the way tasks communicate and interact, there is absolutely
> no reason to limit the number of tasks to the number of cores, or
> anything related to the number of cores. There are applications on
> single-core processors with hundreds of tasks.
>
> So if you need an extra task, or ten extra tasks, in order to decouple
> the timing of some other tasks from each other, go ahead.

Right, I touched on this last week. The issue is the amount of CPU load for 
each task, not the raw numbers of tasks.

Most tasks spend most of their time blocked (the mailbox tasks surely are in 
this category). Such tasks don't contribute much to the CPU usage and surely 
shouldn't be counted as "using up a core". Tasks that are intended to be 
running most of the time do "use up a core", but even then, you may be 
better off structuring your program with more tasks.

Someone else touched on it, but premature optimization is a very common 
evil. And that extends just as much to the use of tasks as it does with 
anything else.

                                        Randy.





  reply	other threads:[~2012-12-31 22:15 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-31  0:16 asynchronous task communication Charles Hixson
2012-12-31  9:04 ` Simon Wright
2012-12-31 11:49   ` Simon Wright
2012-12-31 10:50 ` J-P. Rosen
2012-12-31 12:09 ` Georg Bauhaus
2012-12-31 18:52   ` Charles Hixson
2012-12-31 20:18     ` Shark8
2012-12-31 21:09     ` Niklas Holsti
2012-12-31 22:15       ` Randy Brukardt [this message]
2013-01-01  3:58         ` Charles Hixson
2013-01-01  4:48           ` tmoran
2013-01-01 17:59             ` Charles Hixson
2013-01-01  3:51       ` Charles Hixson
2013-01-01  9:59         ` Dmitry A. Kazakov
2013-01-01 10:38         ` Brian Drummond
2013-01-01 12:32         ` Jeffrey Carter
2013-01-01 18:21           ` Charles Hixson
2013-01-01 18:54             ` Robert A Duff
2013-01-02  7:36               ` Charles Hixson
2013-01-02  9:55                 ` Dmitry A. Kazakov
2013-01-02 19:02                   ` Charles Hixson
2013-01-02 20:35                     ` Dmitry A. Kazakov
2013-01-03  0:20                       ` Charles Hixson
2013-01-03  6:34                         ` Charles Hixson
2013-01-03  8:50                         ` Dmitry A. Kazakov
2013-01-03 19:01                           ` Charles Hixson
2013-01-03 10:01                         ` J-P. Rosen
2013-01-03 19:29                           ` Charles Hixson
2013-01-04  8:17                             ` J-P. Rosen
2013-01-05  4:31                               ` Charles Hixson
2013-01-09  8:34                                 ` Stephen Leake
2013-01-03 22:27                         ` Randy Brukardt
2013-01-05  5:18                           ` Charles Hixson
2013-01-05  8:48                             ` Niklas Holsti
2013-01-06 22:55                               ` Charles Hixson
2013-01-07  0:38                                 ` tmoran
2013-01-07  6:07                                 ` Shark8
2013-01-07 10:49                                 ` Brian Drummond
2013-01-07 18:27                                   ` Jeffrey Carter
2013-01-08 12:02                                     ` Brian Drummond
2013-01-08 17:12                                       ` Jeffrey Carter
2013-01-08 18:18                                         ` Simon Wright
2013-01-08 20:29                                           ` Dmitry A. Kazakov
2013-01-08 21:01                                           ` Jeffrey Carter
2013-01-08 21:14                                             ` Simon Wright
2013-01-08 22:11                                               ` Randy Brukardt
2013-01-08 22:52                                               ` Jeffrey Carter
2013-01-08 22:26                                         ` Brian Drummond
2013-01-08  2:41                             ` Randy Brukardt
2013-01-02 22:43         ` Niklas Holsti
2013-01-03  1:30           ` Charles Hixson
2013-01-03 12:11             ` Georg Bauhaus
2013-01-03 13:17               ` Dmitry A. Kazakov
2013-01-05 20:19               ` Charles Hixson
2013-01-07  4:01                 ` Shark8
2013-01-01 19:59     ` J-P. Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox