by sephamorr · 8y ago · 0 comments
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.
Furthermore, there isn't much of a relevant difference between stack allocated and nursery allocated objects, because they have to be scanned either way--either as roots or via a Cheney scan. The difference is only in sweeping, which is incredibly fast for nursery objects.
What's really important about generational GC is that heap allocation becomes nearly as cheap as stack allocation. That's a game changer.
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.