Abandoning segmented stacks in Rust
mail.mozilla.org
mail.mozilla.org
[1] https://docs.google.com/document/d/1wAaf1rYoM4S4gtnPh0zOlGzW...
You might have better use of your memory (caching, in memory databases) than wasting it for even a fraction of a million of routines that are just waiting for something to happen.
https://github.com/roboprog/buzzard/blob/master/test/src/mai...
It performed reasonably well in a demo doing a bunch of string concatenation, but I never followed up on it.
https://github.com/roboprog/mp_bench/blob/master/thd_frk.bzr...
Now, for context, remember that Graydon began working on this language (in his own free time) in 2006, when the architecture landscape was much different. And then later in 2009/2010, after Mozilla picked up the language in order to write a web browser in it, one of the primary goals was to be able to target phones, which lag fairly far behind desktops in 64-bit adoption. But now that Rust has a stable release target of mid-2014, tailoring core language features to the diminishing 32-bit demographic is just no longer tenable.
How about avoiding hot split by changing the deallocation algorithm to allow empty blocks and see what happens?
Not really. With segmented stacks, when you hit the end of a stack, you must (1) allocate a new segment to extend the stack and (2) copy the current function frame to the new segment and resume execution. Then, when the function returns, you have to (3) deallocate the new segment and shrink the stack, and (4) resume execution of the last function frame on the previous stack segment.
Now, steps (1) and (3) are optional, but steps (2) and (4) are not, and incur a significant overhead (compared with non-segmented, contiguous stack, e.g. C stack).
Their point is that if you have done something wrong if you have to dynamically turn on profiling to keep the stack from catching on fire.
I thought that Rust is meant to aim for a "C replacement", but then doesn't the above quote raise some concerns towards ARMs and more embedded targets (e.g. AVRs, ...)? Or maybe my hopes were misguided from the beginning, I start to think now, given multithreading etc.? I'm confused now.
In any case, this ML post is basically saying "Rust is reverting to C-like stack behaviour" (with some checks to handle stack-overflow safely (i.e. memory safety & security), the current implementation just aborts the whole process on stack overflow).
Couldn't segmented stacks for async/await-style IO be simulated by swapping the stack out at every await? I mean copying out the registers and the raw stack to some heap location, then restoring them by reversing the process later.
(One problem I see is that it'd be slow when lots of IO operations are involved.)