Bill Allombert on Thu, 16 Dec 2004 23:56:06 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Two stacks at once


On Thu, Dec 16, 2004 at 01:52:51PM -0800, Ilya Zakharevich wrote:
> On Thu, Dec 16, 2004 at 02:21:27PM +0100, Bill Allombert wrote:
> > 1) Stack overflow might happen in either stacks, so we have to allocate
> > a suitable amount for each stacks. 
> 
> In practice, I think that 2 stacks of 3M should work as well as one of
> 4M; so it is a price of 2M for the default configuration.  And if it
> is a custom-made stack size, one could custom-modify it without a
> large pain.  Given the memory situation of today, I do not think that
> extra 30% of virtual memory would matter.

Sure, but some computations require more than 1Gb of stack. Optimising
the size of each stacks might not be easy.

> > 2) We cannot allow recursive objects in a stack to include pointers to the 
> > other stack, else we will not be able to garbage collect.
> 
> You get anything on another stack only if you ask for it.  So how it
> can hurt?

It will not hurt, but it reduces the situation where a multi-stack
approach can be used. 

> > 1) Given 2) above, making sure objects are created in the correct stack
> > without requiring extra copy can be painful.
> 
> My hope was that no change to existing code is *needed*.  One *can*
> use stack switching to optimize performance.  If it is used often
> enough, one gets the "stack randomization effect" described above,
> when you may use each-stack-of-lower size for the same calculation.

We would still need to identify what routine could benefit from
the scheme and to update them. Do you have some candidates ?

> > 2) Most of the time lazy garbage collecting is nearly as good as a
> > multi-stack approach.  Karim have developed fast gerepile alternative
> > that have nearly the same cost as a copy.
> 
> How a copy can be as good as 6 assignments?

The idea is to make the garbage collection unfrequently so that the
overall cost is negligible.

GP handles a lot of very small objects that span 3 or 4 words, so a copy
can be less than 6 assignments.

That said, the idea of several stacks has a lot of merit, but I don't
think we can retrofit it at this stage without major though.

Cheers,
Bill.