The advantage of segmented stacks is that blocked tasks only take up as much
memory as they actually need to store state, so that for instance a network
server can use a task for each connection, and still only use, say, 64 bytes
per connection if that's possible instead of the number of stack pages that got
allocated for previous computation (assuming an "extreme" version that
allocates a stack segment on every call).
However, there is another approach that can replace segmented stacks for that
purpose, namely having the compiler automatically transform blocking functions
to instead return a future (with limited lifetime).
This means that segmented allocation only happens for functions that indirectly
perform I/O and only allocates the exact amount of memory needed to retain
state that must persistent across the blocking I/O operation, while other
functions execute normally using traditional stacks.
The simplest example of this feature is async/await in C# 5, and Scala has a
delimited continuation passing transformation that can be used to do the same
thing.
Has this been considered for Rust?
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev