Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
CallCC using fork (and garbage collected processes)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] CallCC using fork (and garbage collected processes)
On Mon, 2007-07-16 at 17:46 +0100, Richard Jones wrote:

> > However the C method doesn't work, because Unix uses
> > linear bounded stacks, and there isn't enough address 
> > space to create enough stacks.
> This is more of a problem with 32 bit machines.  64 bit machines
> shouldn't have an issue.  Even on a 32 bit machine I could get
> thousands of threads before hitting a limit.

Yeah, 16 bit machines have some problems but 32 bits is HEAPS .. 
woops .. 32 bit machines have some problems but 64 bits is HEAPS ..
woops .. :)

Yes, more can be done with 64 bits: say you allocate 8 bits for
stack choices, that's 256 stacks, 16 bits is 64K .. still
of your pair of 32 bit half words, say one half is used up,
the 16 bits is half the bits you have left .. just for 64K
threads .. which isn't really a lot.

Minimum stack size is one 4K page .. 4K x 64K = 256Meg ..
a quarter of my RAM wasted .. goto 18 bits and ALL my RAM 
is wasted (on 1G machine).

Yes, 64 bit box does give much higher capacity .. but Felix
can run several million threads on the same box without
any such problems because it uses linked heap objects instead
of a linear stack.

One stack is faster than the heap.. it isn't clear that
millions of stacks is faster though, especially if you have
a good heap manager such as the Ocaml gc. 

Actually be interesting to measure the relative performance
of spaghetti and linear stack on 64 bit box.

The one to look at here is MLton IMHO .. since it uses
a garbage collected (compacted) linear stack with mmap() 
extension .. hopefully obtaining the benefits of both
linear performance from linear addresing and low
resource usage from spaghetti stack implementation.

John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: