On Tue, Oct 29, 2013 at 7:08 PM, Niko Matsakis <n...@alum.mit.edu> wrote:

> If I understand correctly, what you are proposing is to offer fixed
> size stacks and to use a guard page to check for stack overflow (vs a
> stack preamble)?
>
> My two thoughts are:
>
> 1. I do think segmented stacks offer several tangible benefits:
>
> - Recursion limited only by available memory / address space
> - Avoid chewing up address space on 32 bit builds
>
> However, I can accept that on balance they are not worth the price,
> given that point #2 is probably not that important for 64-bit systems.
>
> It is sad to lose limitless recursion but typically one can rewrite
> routines that recurse arbitrarily deep to use a stack on the heap,
> though sometimes the code is very unnatural, and using a stack on the
> heap will not play as well with lifetimes, since the compiler doesn't
> know that you are obeying a stack discipline.


Fixed stacks can be expanded once you have precise collection ( help will
come from LLVM eventually...).

What i think hasnt been discussed ( though it has previously) is  how much
of a penalty segmented stacks represent and what it could be ..

In terms of memory allocations a faster expansion or greater reuse from a
segment pool  ( Why does the scheduler segment pool  start empty. I would
have thought you would have  2Meg worth pre allocated - one runs in the
context of a microbench the other allocated before hand ( like C stacks) )
.  a 4^N expansion of each stack  would result in more contigous stacks.
And if stack is unused for a long time hand some segments back.

In terms of the stack size check  , as has been mentioned you can do more
with some analysis  , each method gives an indication of worst cases stack
growth , these can then be added together to reduces checks by 80% and
hence significantly reduce the performance impact .

Though obviously for production release soon you will get there faster with
fixed stacks earlier.

Ben
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to