Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Go's GC's throughput is significantly lower than that of all OpenJDK's GCs, and its latency numbers are misleading because they don't account for throttling. To give you an example, a GC that works as follows -- allocate by pointer bumping from a thread-local buffer, and when it runs out, freeze the thread forever -- would count as having zero latency according to Go's metrics, because this infinite pause is per-thread rather than stop-the-world; of course, the throughput will eventually drop to zero, too, but they don't report throughput. Why, then, do you see Go applications performing more-or-less OK? Because of two things: they allocate fewer objects, and they just run significantly more slowly than Java, except this slowdown is paced. In terms of algorithm, Go's GC is pretty-much a simplified version (no young generation) of OpenJDK's now-defunct CMS plus throttling. G1 is a generation beyond that, and ZGC is two.


Generational garbage collection doesn't help much with a language with value types, stack allocation, and decent escape analysis.

“It isn't that the generational hypothesis isn't true for Go, it's just that the young objects live and die young on the stack. The result is that generational collection is much less effective than you might find in other managed runtime languages” https://twitter.com/davecheney/status/1019430967054819328

Go's GC improvements are revealed in P99.9 latencies of servers over time, not just in the raw numbers of how long it's stopping the world.


That doesn't change the fact that Go's GC is a simplified CMS. It is true that Go does have an easier life -- Java does do escape analysis and allocates on the stack, but it doesn't have value types just yet, and so the allocation rates are higher, which is why Java is not drastically faster. I.e. a cruder GC that's similar to OpenJDK's GC from two generations ago works OK for Go. Despite Go having an easier life, Java 14 performs noticeably better than Go, partly due to having a better compiler, but also because its GCs are just better.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: