2 ms·
Stack allocation tends to have more predictable performance than GC. Being able to measure and reason about a function's performance may be better even if GC so
by skybrian 12y ago
Stack allocation tends to have more predictable performance than GC. Being able to measure and reason about a function's performance may be better even if GC sometimes beats it on average.
That said, the Go developers are also working on making garbage collection more predictable. [1]
[1] http://golang.org/s/go14gc http://golang.org/s/go14gc
- seanmcdirmid 12y agoStack allocation that depends on escape analysis is not very predictable at all, unless the programmer can force an error if escape analysis fails. Explicit stack allocation via pass/return-by-value structs (as in C#) works well if predictability is a goal.
- pcwalton 12y agoEspecially considering this very article is about the ways that escape analysis can fall down in surprising circumstances.
- seanmcdirmid 12y agoThis is a problem with any optimization that relies on analysis vs. language guarantees; if you can't codify some optimization in your semantics, it might as well not exist and can go away given any small change in your code. You have to track both correctness and performance regressions, with no real easy guidance on the latter.