On Tue, Jan 17, 2012 at 14:03, maga <denel...@gmail.com> wrote: > Is there any docs on isolates yet?
Not yet[1].
Isolates are (will be) API-compatible with child processes. So you call child_process.fork({thread:true}) and it will spawn a new isolate instead a new process.
Just curious: If isolates maintain complete separate states, and objects from one isolate are not be used in other isolates then how is an isolate different than a separate run of a process?
If isolates maintain complete separate states, and objects from one isolate
> are not be used in other isolates then how is an isolate different than > a separate run of a process?
The javascript state of isolates are completely separated from one another, but the creation cost of an isolate should be lower than that of a separate process; for example, some of the v8 state and the eio thread pool (on unix systems) will be shared.
On Tue, Jan 17, 2012 at 11:50 PM, Paddy Byers <paddy.by...@gmail.com> wrote: > Hi,
> If isolates maintain complete separate states, and objects from one >> isolate are not be used in other isolates then how is an isolate different >> than a separate run of a process?
> The javascript state of isolates are completely separated from one > another, but the creation cost of an isolate should be lower than that of a > separate process; for example, some of the v8 state and the eio thread pool > (on unix systems) will be shared.
So, isolate is sync'ed with the parent on the death, and for all other practical purposes, it is an independent process. I guess if your app forks a few processes, then you don't need to worry about taking them all down when parent exits, clean up is on the house. What use cases can you think of could be candidates for isolates?
On Tue, Jan 17, 2012 at 10:21 AM, Seva Adari <oddiss...@gmail.com> wrote: > So, isolate is sync'ed with the parent on the death, and for all other > practical purposes, it is an independent process. I guess if your app forks > a few processes, then you don't need to worry about taking them all down > when parent exits, clean up is on the house. What use cases can you think > of could be candidates for isolates?
> What use cases can you think of > could be candidates for isolates?
Theoretically, it should be possible to pass node buffers between them (sharing would work, too, but meh, it'd just cause race conditions). So, maybe for tasks with much input data, much output data and even more computation that have to be done in a new thread?
On Tue, Jan 17, 2012 at 2:05 PM, Jann Horn <jannh...@googlemail.com> wrote: > 2012/1/17 Seva Adari <oddiss...@gmail.com>: > > What use cases can you think of > > could be candidates for isolates?
> Theoretically, it should be possible to pass node buffers between them > (sharing would work, too, but meh, it'd just cause race conditions). > So, maybe for tasks with much input data, much output data and even > more computation that have to be done in a new thread?
There are a number of possible strategies for safely passing data back and forth between isolates efficiently. Isolates lay the groundwork for some really interesting concurrency experiments.
I remember a video of Ryan Dahl mentioning a web server as an exemple where requests would run in isolate. In this exemple, using isolate prevent a process, understand the web server, to be kill in case of an uncatch error while handling a request.
> I remember a video of Ryan Dahl mentioning a web server as an exemple where requests would run in isolate. In this exemple, using isolate prevent a process, understand the web server, to be kill in case of an uncatch error while handling a request.
There was a separate Domains proposal to try to handle that situation within a single process. What's the status with that? Does it still seem feasible?
On Tue, Jan 17, 2012 at 22:16, Ted Young <t...@radicaldesigns.org> wrote: > There was a separate Domains proposal to try to handle that situation within a single process. What's the status with that? Does it still seem feasible?
Yes and yes. Bert is working on domains but it's not ready yet.
Correct me if I'm wrong but this is the seperation.
domains are for encapsulating and handling errors in process. you can think of it like adding a wrapper around a set of application code to treat it, and all the IO it does and it's descendant callbacks, as a transaction.
isolates are a replacement for processes as the preferred method of scaling a node application to multiple cores.
running each "transaction" in an isolate would be too costly.
-Mikeal
On Jan 17, 2012, at January 17, 20121:18 PM, Ben Noordhuis wrote:
> On Tue, Jan 17, 2012 at 22:16, Ted Young <t...@radicaldesigns.org> wrote: >> There was a separate Domains proposal to try to handle that situation within a single process. What's the status with that? Does it still seem feasible?
> Yes and yes. Bert is working on domains but it's not ready yet.
> Correct me if I'm wrong but this is the seperation.
> domains are for encapsulating and handling errors in process. you can think of it like adding a wrapper around a set of application code to treat it, and all the IO it does and it's descendant callbacks, as a transaction.
> isolates are a replacement for processes as the preferred method of scaling a node application to multiple cores.
> running each "transaction" in an isolate would be too costly.
> -Mikeal
> On Jan 17, 2012, at January 17, 20121:18 PM, Ben Noordhuis wrote:
> > On Tue, Jan 17, 2012 at 22:16, Ted Young <t...@radicaldesigns.org> wrote:
> >> There was a separate Domains proposal to try to handle that situation within a single process. What's the status with that? Does it still seem feasible?
> > Yes and yes. Bert is working on domains but it's not ready yet.
On Wed, Jan 18, 2012 at 00:17, billywhizz <apjohn...@gmail.com> wrote: > quick question - do isolates allow us to set the processor affinity of > each isolate so we can "pin" an isolate to a particular cpu?
> On Wed, Jan 18, 2012 at 00:17, billywhizz <apjohn...@gmail.com> wrote:
> > quick question - do isolates allow us to set the processor affinity of
> > each isolate so we can "pin" an isolate to a particular cpu?
On Tue, Jan 17, 2012 at 6:26 PM, Ben Noordhuis <i...@bnoordhuis.nl> wrote: > On Wed, Jan 18, 2012 at 00:17, billywhizz <apjohn...@gmail.com> wrote: > > quick question - do isolates allow us to set the processor affinity of > > each isolate so we can "pin" an isolate to a particular cpu?
> No.
Is this a "not on your life" no, or just a "no for now"?
On Wed, Jan 18, 2012 at 00:30, billywhizz <apjohn...@gmail.com> wrote: > thanks. that's a pity. would it be worth raising an issue with the v8 > team to allow this?
It's not a V8 issue, the isolate runs in a thread that is created by Node.
On Wed, Jan 18, 2012 at 00:30, Dean Landolt <d...@deanlandolt.com> wrote: > On Tue, Jan 17, 2012 at 6:26 PM, Ben Noordhuis <i...@bnoordhuis.nl> wrote: >> On Wed, Jan 18, 2012 at 00:17, billywhizz <apjohn...@gmail.com> wrote: >> > quick question - do isolates allow us to set the processor affinity of >> > each isolate so we can "pin" an isolate to a particular cpu?
>> No.
> Is this a "not on your life" no, or just a "no for now"?
Probably the former. It's nearly always better to leave work load scheduling to the OS. I say 'nearly' but I can't really think of a scenario where that's not the case.
i can think of many scenarios where i would like to pin tasks to
certain cpu's to allow soft real time processing by ensuring no other
processes will be contending with the cpu the node.js isolate is on...
On Jan 17, 11:39 pm, Ben Noordhuis <i...@bnoordhuis.nl> wrote:
> On Wed, Jan 18, 2012 at 00:30, Dean Landolt <d...@deanlandolt.com> wrote:
> > On Tue, Jan 17, 2012 at 6:26 PM, Ben Noordhuis <i...@bnoordhuis.nl> wrote:
> >> On Wed, Jan 18, 2012 at 00:17, billywhizz <apjohn...@gmail.com> wrote:
> >> > quick question - do isolates allow us to set the processor affinity of
> >> > each isolate so we can "pin" an isolate to a particular cpu?
> >> No.
> > Is this a "not on your life" no, or just a "no for now"?
> Probably the former. It's nearly always better to leave work load
> scheduling to the OS. I say 'nearly' but I can't really think of a
> scenario where that's not the case.
> > What use cases can you think of could be candidates for isolates?
>> Theoretically, it should be possible to pass node buffers between them >> (sharing would work, too, but meh, it'd just cause race conditions). >> So, maybe for tasks with much input data, much output data and even >> more computation that have to be done in a new thread?
> There are a number of possible strategies for safely passing data back and > forth between isolates efficiently. Isolates lay the groundwork for some > really interesting concurrency experiments.
If the intent of isolate is to box it and separate it, why try to use it in a case where data sharing is required. If the use case requires data sharing is isolate really a candidate for it?
> i can think of many scenarios where i would like to pin tasks to > certain cpu's to allow soft real time processing by ensuring no other > processes will be contending with the cpu the node.js isolate is on...
Even if you have a way to schedule/assign to a particular core/cpu, is it not the prerogative of the OS to either honor/dishonor it?
You could probably make a native extension to do it, even if it isn't
built into node out of the box.
However, it does sound like a strange requirement at the application
level.
The OS should already favor having the same thread run on the same CPU
if it can, since that makes better
use of the CPU caches.
And, just because you told the OS to run that thread on that CPU with
high priority, it doesn't mean the OS
won't run other threads on that CPU while that task is not in a run
state.
On Jan 18, 7:43 am, billywhizz <apjohn...@gmail.com> wrote:
> i can think of many scenarios where i would like to pin tasks to
> certain cpu's to allow soft real time processing by ensuring no other
> processes will be contending with the cpu the node.js isolate is on...
> On Jan 17, 11:39 pm, Ben Noordhuis <i...@bnoordhuis.nl> wrote:
> > On Wed, Jan 18, 2012 at 00:30, Dean Landolt <d...@deanlandolt.com> wrote:
> > > On Tue, Jan 17, 2012 at 6:26 PM, Ben Noordhuis <i...@bnoordhuis.nl> wrote:
> > >> On Wed, Jan 18, 2012 at 00:17, billywhizz <apjohn...@gmail.com> wrote:
> > >> > quick question - do isolates allow us to set the processor affinity of
> > >> > each isolate so we can "pin" an isolate to a particular cpu?
> > >> No.
> > > Is this a "not on your life" no, or just a "no for now"?
> > Probably the former. It's nearly always better to leave work load
> > scheduling to the OS. I say 'nearly' but I can't really think of a
> > scenario where that's not the case.
if you use taskset and cgroups in linux you can do all sorts of things
like running everything under init on 1 cpu and then running specific
processes/threads on other cpu's. it can be useful in certain
scenarios, especially where you want as little context switching as
possible in your application (i.e. low latency).
you also may want to make sure that two threads run on specific cores
so that they share the same cpu cache(s). this would only be useful if
both threads were accessing the same shared memory.
if node.js is allowing threads to be spawned then it should support
setting thread affinity imho.
> You could probably make a native extension to do it, even if it isn't
> built into node out of the box.
> However, it does sound like a strange requirement at the application
> level.
> The OS should already favor having the same thread run on the same CPU
> if it can, since that makes better
> use of the CPU caches.
> And, just because you told the OS to run that thread on that CPU with
> high priority, it doesn't mean the OS
> won't run other threads on that CPU while that task is not in a run
> state.
> On Jan 18, 7:43 am, billywhizz <apjohn...@gmail.com> wrote:
> > i can think of many scenarios where i would like to pin tasks to
> > certain cpu's to allow soft real time processing by ensuring no other
> > processes will be contending with the cpu the node.js isolate is on...
> > On Jan 17, 11:39 pm, Ben Noordhuis <i...@bnoordhuis.nl> wrote:
> > > On Wed, Jan 18, 2012 at 00:30, Dean Landolt <d...@deanlandolt.com> wrote:
> > > > On Tue, Jan 17, 2012 at 6:26 PM, Ben Noordhuis <i...@bnoordhuis.nl> wrote:
> > > >> On Wed, Jan 18, 2012 at 00:17, billywhizz <apjohn...@gmail.com> wrote:
> > > >> > quick question - do isolates allow us to set the processor affinity of
> > > >> > each isolate so we can "pin" an isolate to a particular cpu?
> > > >> No.
> > > > Is this a "not on your life" no, or just a "no for now"?
> > > Probably the former. It's nearly always better to leave work load
> > > scheduling to the OS. I say 'nearly' but I can't really think of a
> > > scenario where that's not the case.