Re:Getting to Go: Garbage collection and runtime issues
by enneff on Tuesday July 17, 2018 @06:32PM
(#17554075)
> Go programmers have a habit of manually microoptimizing short-lived allocations to keep escape analysis "happy"
I've been writing Go for 8+ years and have never done this, and I wouldn't approve a code review of a teammate that did this.
Re:Getting to Go: Garbage collection and runtime issues
by pcwalton on Tuesday July 17, 2018 @06:33PM
(#17554080)
But that's what the article says: "We started creating tools to help our users find objects that escaped and if it was minor they could make changes to the code and help the compiler allocate on the stack."
Re:Getting to Go: Garbage collection and runtime issues
by enneff on Tuesday July 17, 2018 @07:22PM
(#17554393)
"Tools used by a small minority of users to find performance issues," != "Go programmers have a habit of microoptimizations to avoid heap allocations." You are being disingenuous.
Re:Getting to Go: Garbage collection and runtime issues
by ngrilly on Thursday July 19, 2018 @09:30AM
(#17566058)
> The most important point, though, is that you don't know whether the hypothesis that Go wouldn't benefit from generational GC is true until you test it. Nobody has tested it.
I agree. But you would probably agree it would be a fairly difficult endeavour to test your hypothesis? To make a fair comparison, we'd need to implement an alternative version of the Go compiler and runtime, replacing the current GC with a copying generational GC, with a similar multi-year effort in optimizing and refining it.
The most important point, though, is that you don't know whether the hypothesis that Go wouldn't benefit from generational GC is true until you test it. Nobody has tested it. And there is plenty of indirect evidence to suggest that this is not true. For one, Go programmers have a habit of manually microoptimizing short-lived allocations to keep escape analysis "happy", which is something that becomes much less important with bump allocation in the nursery. Another simple observation is that .NET has the same situation regarding value types as Go does, and .NET uses a copying generational garbage collector. A final observation is that certain situations, like indirect calls [1], cause objects to be spilled to the heap unconditionally.
[1]: https://github.com/golang/go/blob/964639cc338db650ccadeafb74...