News for hackers. Stuff that matters.
Re:Rust means never having to close a socket by krig on Tuesday October 07, 2014 @02:23PM (#8422944)
It sounds like they are talking about a semi-space collector, which I can imagine might in theory be faster than scoped allocation since allocation is a simple pointer bump (just like stack allocation) but when garbage collecting you only have to traverse the live set. However, semi-space collectors can't collect non-memory resources without additional metadata, and they have a memory overhead of at least 2x the maximum live set. I have a hard time imagining even a semispace collector outperforming stack allocation.

Of course if your program is short-lived you can just allocate a sufficiently large heap, pointer bump the whole way and free all non-memory resources on program termination, which ought to be cheaper (but probably not that much in practice due to cache effects).

Re:Rust means never having to close a socket by wycats on Tuesday October 07, 2014 @02:28PM (#8422984)
In Rust, you often use stack allocation, which, as you pointed out, is much more efficient. There's some heap allocation in Rust, but in my experience it's actually a minority of all allocations.

Rust also has an Arena library (http://doc.rust-lang.org/0.11.0/arena/index.html), which can be used for cases where you know that you have enough memory for a given operation and are willing to throw out the entire thing when the operation (or program ;) ) is done.

Re:Rust means never having to close a socket by eddyb on Wednesday October 08, 2014 @04:01AM (#8425754)
That link is outdated, see http://doc.rust-lang.org/arena/.
Re:Rust means never having to close a socket by spullara on Tuesday October 07, 2014 @04:03PM (#8423658)
Arena allocation has similar efficiencies as GC.
Re:Rust means never having to close a socket by pcwalton on Tuesday October 07, 2014 @05:25PM (#8424114)
Except for not having the mark phase (also not having to copy). The mark phase can take a lot of time.