Question about parallel (nimble) execution

73 views
Skip to first unread message

Kleyson Rios

unread,
Oct 1, 2014, 7:06:26 AM10/1/14
to nod...@googlegroups.com
I would like to know how exactly parallel execution works.

I'm using nimble module to execute some functions in parallel, and the result of those executions be used for a final calculation. When I run flow.parallel what exactly happens ? I mean, is it created a thread for each function ? those threads share the same CPU or the threads are spread over all CPU's ?

Regards

Aria Stewart

unread,
Oct 1, 2014, 11:02:49 AM10/1/14
to nod...@googlegroups.com

On Oct 1, 2014, at 7:06 AM, Kleyson Rios <kley...@gmail.com> wrote:

> I would like to know how exactly parallel execution works.
>
> I'm using nimble module to execute some functions in parallel, and the result of those executions be used for a final calculation. When I run flow.parallel what exactly happens ? I mean, is it created a thread for each function ? those threads share the same CPU or the threads are spread over all CPU's ?

Perhaps surprisingly, node doesn't execute any javascript functions in parallel. It's actually strictly a single-threaded process. Anything that would block on IO or a timer gets deferred until the resource is available, but those tools are for managing asynchronous, not actually concurrent functions.

Aria

Kleyson Rios

unread,
Oct 2, 2014, 8:03:08 AM10/2/14
to nod...@googlegroups.com
Thanks.

Oleg Verych

unread,
Oct 3, 2014, 7:01:07 AM10/3/14
to nod...@googlegroups.com
Perhaps surprisingly, node doesn't execute any javascript functions in parallel. It's actually strictly a single-threaded process.

Small correction about wording "single-threaded process" vs "single threaded engine":

The other critical component is the node event loop. The event loop is the “single thread” running your code. It is not exactly a single thread but as far as your application is concerned, it is a single threaded engine. Everything that happens in node is called from the event loop. It is a queue of I/O events and timers which trigger your callbacks – basically, your entire node application is nothing but a collection of callbacks.


-- 
sed 'sed && sh + olecom = love'  <<  ''
-o--=O`C
 #oo'L O
<___=E M

Reply all
Reply to author
Forward
0 new messages