182 points · by beyang · 8y ago · 42 comments
FYI, this was part of a technical liveblog that covered all the talks at GopherCon this year in a similar fashion. If you missed the conference or are looking to review material, you might find https://sourcegraph.com/gophercon helpful. (Disclosure: I'm CTO of Sourcegraph—we organized the liveblog and love Go!)
In other words, you're tuning to today's runtime if you reuse heavily. Those techniques may not age well, and will harm readability and maintainability.
It isn't, and will probably never be. The Go runtime developers have actually implemented and tested a generational GC, but found that it's not useful, and even harmful at times, to the goal of having fast, low-latency, concurrent garbage collector. Mostly because most short-lived objects are allocated on stack, and the escape analysis is getting better with each release.
This benefit is directly relevant to this thread, because bump allocation in the nursery makes the allocation fast path somewhere on the order of 6 instructions.
Go should switch to this strategy as well.
Can this be detected statically?
Ergo, this value is safe to allocate on stack.
Please quote where i said this. I said:
> for me
My requirements are not your requirements. Runtime pausing execution arbitrarily = bad for me.
I do also consider it a design failure to plug GC into what was originally marketed as a systems language.
EDIT: Not sure why I'm being downvoted; if this is a contentious topic, I wasn't aware. I'm certainly not trying to make a point one way or another; I only posted this hoping someone who was more knowledgeable than me could respond.
2. Go does not have "a powerful GC", it has a GC built quite specifically for it and the applications it's intended to support with low-latency, middling throughput, and the assumption that allocations are long-lived (because short-lived objects don't escape and thus don't get heap-allocated)
3. Which is the issue of providing generic GC strategies: the type of GC you want and how you want to tune it is very much a factor of the language's semantics and its intended use cases, hence the official JVM shipping with something like half a dozen different GCs, and third-party JVMs having their own with their own tradeoffs
2. The assumption that allocations are long-lived can often be made because a compiler can perform escape-analysis (and in fact LLVM could provide utilities for this).
3. Yes, I'm not saying that GoLang's GC (or an adaptation thereof) is the holy grail, just that it would be very useful for many other languages. And work in this area could help bring LLVM's suite of GCs to a competitive, world-class level.
And when one have some (parts, modules, libraries) in your program which are best suited with different GC behaviour, things tend to become complicated. And cross-language boundaries is yet another talk.
That being said, the Bohem garbage collector tends to be what languages use until they can write their own.