threads is something of a misnomer, isn't it? It's the old prefork model.
I think the node edge version has a .fork() with messaging that seem
pretty good.
BTW: On the project before this one I used a home-brew architecture
that was almost identical. My original motivation was to protect
executing processes from crashing each other but it performed well
also. Having processes sitting there waiting to be used pretty much
nullified the Node argument that firing off a process was too
expensive.
My only performance issue was the cost of serializing the IO. I
didn't have the new fork.
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
The child_process.fork doesn't create a new thread. It creates a
full-fledged OS child process, complete with its own pid and memory
and everything. You can send send it signals, renice it, etc. It
can't share memory directly with its parent. It's not a thread.
Not to say this isn't a useful lib. Seems like a nice little sugar
layer over child_process.fork, which is probably very useful. But
it's absolutely not in any way "multithreaded".
Speaking of .fork, is there any plans to add .signal(), .renice() to
the forked processes using child_process? It would simplify a lot :)
---
Diogo R.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
---
Diogo R.
Yeah, -1 on the name. That's very confusing, on a point which is
already confusing enough.
The child_process.fork doesn't create a new thread. It creates a
full-fledged OS child process, complete with its own pid and memory
and everything. You can send send it signals, renice it, etc. It
can't share memory directly with its parent. It's not a thread.
Not to say this isn't a useful lib. Seems like a nice little sugar
layer over child_process.fork, which is probably very useful. But
it's absolutely not in any way "multithreaded".
Indeed. I recommended not calling it fork for that very reason.
Whatever, it's done :)
child_process.fork is a wrapper around child_process.spawn, with an
additional channel open to send and receive messages in a somewhat
webworker-like manner.
child_process.spawn uses vfork(2), which is quite similar to fork(2),
but uses virtual memory much more efficiently. Also, it is not safe
or advisable to use vfork(2) for any purpose other than an immediate
call to some form of exec(2).
Using fork+exec is not quite the same as merely forking and then
running some more code. Yes, it does create a thread, but in that
thread, it splits off a whole other child process, and that's all it
does.
So, yes, it *does* use fork, it just doesn't *only* use fork. The
thread itself is not exposed to JavaScript, and you never have two
bits of JavaScript code running in parallel in the same process. This
is the guarantee that Node makes which makes reentry not an issue we
have to even think about.
If you're writing C++ addons and using eio_custom or something, then
you do have to be aware of these issues.
>> it's absolutely not in any way "multithreaded".
>
> Computer scientists would probably disagree with you.
Well, I mean, of course it's using threads. You can't write software
on a CPU without "using threads", but it's not as if
child_process.fork results in a new thread in the same process that
can communicate with its parent by use of a shared memory space.
When *I* start complaining that you're being too hyperliteral and
robotic, you might have a problem. ;P
--Josh
This sounds fun! Maybe we (you?) can collect a short list of possible
names, and then have an online poll to decide which wins. Maybe
running it from threads' issues page
(https://github.com/robtweed/threads/issues) would be the way to go.
--Josh
I like the "ropes" moniker.
On Wed, Aug 31, 2011 at 2:33 PM, rtweed <rob....@gmail.com> wrote:
How about spoon? It's not a fork..
---
Diogo R.
Or maybe spork, as a play on spawn/fork.
--
Zach Carter
Live long and prosper,
Rasmus
It's gonna need a logo, too :-P
--
Jorge.
> Also joining the "why is it called 'threads' crew".
>
> I had gotten excited considering you could totally implement a worker paradigm in v8+Node with Isolates.. it's just no one has done it yet.
Launching a new plain vanilla v8 JS context in a new thread in the node process would be quite easy (thanks to isolates), the not-so-easy part would be adding node's functionality to it. For that node itself would have to have its own 'isolates' branch that took care of its own global shared state.
--
Jorge.