by jeffbee · 5y ago · 0 comments
"This typically causes Java programs to have complete freezes of several hundred milliseconds where objects get moved around"
Yeah, i mean, definitely not. The only language I regularly work with that has this property is, surprise, Go.
The proof is in the tasting, as they say. Go look at the gRPC daily benchmarks if you want hard data. Java beats Go latency at the median and at the tail while having substantially better specific throughput. In other words the Java GC has no tradeoff versus the Go GC; it is better in every way.
I worked with a lot of Java based solutions ( elastic search, hadoop etc ... ) and was never impressed by the GC.
I was disappointed with the first Go gRPC implementation, it allocated like crazy and was really slow because of it. It's been rewritten since then but I don't know how much better it is now. To get good performance out of Go it is important to think about memory allocations (unfortunately), just as it is in C and C++. Although allocating like crazy in C/C++ will probably mostly result in a general loss of performance, not affect tail latencies in network protocols much.
and I doubt you see pauses in golang longer than 30ms. proof please.
Also, shitty code does get written by developers quite often, regardless of language — at that point the runtime can only do that much.
and your assertion about the runtime only being able to do so much is just wrong here. golang will slow down your application in order to meet GC deadlines.
however its incredibly rare to see GC STW pauses for longer than 10s of ms. not even sure its possible given how the GC is written. this is true for heaps in the 100s of GBs.
this is why you don't hear about issues with golangs GC since like ~1.7. it just doesn't show up in 99% of use cases.
your basic assertion that java's GC is more advanced and therefor better is completely without merit. GC doesn't operate in isolation. java has more complicated GC systems because the language mandates them. golang entirely sidesteps the issues java has requiring said systems with better memory layouts and utilizing the stack.
its incredibly rare to hear stories about golangs GC because its simply not a problem.
java still has a bunch of issues and requires different GC tradeoffs as a result. meaning java will likely be in a constant state of 'which GC model do I use'
> golang will slow down your application in order to meet GC deadlines
Hardly a good thing for throughput-oriented applications. Java let’s you tune this (the default G1 collector has a target pause time parameter, and then there is also the two new low-latency GC, Shenandoah and ZGC which has <1ms maximum pause time.)
> golang entirely sidesteps the issues java has requiring said systems with better memory layouts and utilizing the stack.
As mentioned many times, having value types greatly decreases the amount of created garbage, thus a less-modern GC can be enough for most Go applications. But there absolutely are use-cases where new object creation is unavoidable and java will beat Go by a huge margin, due to its more advanced GC, see: