News for hackers. Stuff that matters.
Re:Go 1.19 Beta 1 is released by philliphaydon on Saturday June 11, 2022 @02:11AM (#31702374)
.NET is faster than Go for gRPC so I often wonder if it’s worth my time learning Go for performance when it seems same same.
Re:Go 1.19 Beta 1 is released by morelisp on Saturday June 11, 2022 @02:50AM (#31702520)
Stock gRPC is not a great demonstration of Go’s possible performance. The code is neither clean nor fast nor idiomatic. I have no idea why it’s so messed up.

(That said, C# and Java are no performance slouches and I expect they’d all be roughly comparable in the end if the Go code didn’t suck so much.)

Re:Go 1.19 Beta 1 is released by jpgvm on Saturday June 11, 2022 @03:24AM (#31702657)
C# and Java are almost always faster than Go.

Go isn't fast, it's decent but nothing special for AOT native code. (atleast the standard gc compiler, llgo, gccgo etc could end up being a different story). It can show good overall performance in I/O bound workloads because of native M:N green threading though. I imagine even that is no longer a point in Go's favor when Java's Virtual Threads land and become widespread however.

Go's only real interesting runtime feature was their emphasis on having a very low latency GC. This was somewhat special for a few years but between improvements made to .NET and Java's new GCs (Shanandoah and ZGC) that gap has been eliminated while these runtimes still provide better throughput on top of their now low latency.

There really isn't a good performance or resource usage reason to pick Go over C#/Java anymore, all of its advantages have been eroded.

Re:Go 1.19 Beta 1 is released by erik_seaberg on Saturday June 11, 2022 @04:11AM (#31702821)
Go’s GC throughput isn’t great, but they’re pretty good at keeping values off the heap. Java’s GC is amazing, but we’ll have big working sets and boxing overhead until value types land.
Re:Go 1.19 Beta 1 is released by kaba0 on Saturday June 11, 2022 @07:03AM (#31703581)
I would go as far to say that Go’s performance is good only because of value types. Their GC is known to slow down allocation when under big pressure.
Re:Go 1.19 Beta 1 is released by Groxx on Saturday June 11, 2022 @02:29PM (#31706844)
I was poking into a 7-10 second test a couple years ago out of curiosity, and pulled a tracing profile.

Garbage collection accounted for over 95% of the run-time. It was a perfect pathological case where it continually thrashed below/above a GC threshold, without hitting the point where it would make more room. Adding just a couple kilobytes of ballast[1] pushed it over the limit to where it reliably took about 200ms. (and then I rewrote the test to stop allocating so much junk)

Go's GC is mostly pretty good in practice, but yeah. It's definitely not something you can rely on blindly.

Also I wish they'd stop claiming that its pause times are tiny - the stop-the-world pauses are indeed consistently very short, but it hardly matters when it can pause goroutines for far, far longer[2]. And e.g. when you're allocating, your goroutine may be paused to "help" the GC, which can take a substantial amount of time (as happened in that^ test), which frequently leads to very large tail-latency. Most people don't care about stop-the-world times, they care about tail-latency, and Go is just leaning on people's misunderstanding that one is the cause of the other. It can be, but it's not the only source.

[1]: https://blog.twitch.tv/en/2019/04/10/go-memory-ballast-how-i...

[2]: http://big-elephants.com/2018-09/unexpected-gc-pauses/ among other sources of individual goroutine pauses.

Re:Go 1.19 Beta 1 is released by morelisp on Saturday June 11, 2022 @03:41PM (#31707567)
It's still possible to pace the GC like this in certain cases, but most specific benchmarks before the preemptive scheduler introduced in Go 1.14 aren't particularly relevant anymore. Today I think that Twitch blog post does more harm than help. (And even at the time, while an interesting case to analyze, the right fix is usually "make less garbage", not "add some ballast".)
Re:Go 1.19 Beta 1 is released by Groxx on Saturday June 11, 2022 @03:49PM (#31707660)
Oh yeah, completely agreed. The GC does keep improving, and that post is much less relevant than it used to be. It does still apply in some niches though :)

I think Go's GC is solidly "good enough", and much better than many languages, so I broadly like it. Coupled with built-in tracing that shows GC activity and it's in a pretty good position. It's more that all GCs have pathological behavior somewhere, and no amount of distracting hand-waving changes that.

Re:Go 1.19 Beta 1 is released by kaba0 on Saturday June 11, 2022 @07:04AM (#31703586)
Go’s GC are not low-latency in the ZGC Shenandoah meaning - it just slows down allocation (and thus every thread) under big pressure.
Re:Go 1.19 Beta 1 is released by jpgvm on Saturday June 11, 2022 @08:58AM (#31704117)
Technically so do ZGC/Shanandoah/C4.

All three use load-barriers which result in more work done in application threads as the pressure on the GC increases.

That said these GCs are substantially better than the Go GC so you are talking about much higher allocation throughput before running into these issues in practice vs Go.

Re:Go 1.19 Beta 1 is released by zaphirplane on Saturday June 11, 2022 @06:21AM (#31703402)
They originated from the same corporation which heavily leans on both
Re:Go 1.19 Beta 1 is released by morelisp on Saturday June 11, 2022 @07:17AM (#31703652)
> They originated from the same corporation which heavily leans on both

At Google's size this means nothing. The protobuf and gRPC developers don't even always align well, let alone with an entire language ecosystem.

By the same token, C#'s excellent gRPC performance is the result of MS dumping a chunk of resources into gRPC/PB optimization most recently. For Google it's cheaper to buy 2x as many nodes as it is to make Go gRPC 2x faster.

Re:Go 1.19 Beta 1 is released by jpgvm on Saturday June 11, 2022 @04:17PM (#31707924)
> For Google it's cheaper to buy 2x as many nodes as it is to make Go gRPC 2x faster.

That is definitely not true if Google was using Go gRPC at any reasonable scale.

A more accurate conclusion to draw from it is MSFT is using C# gRPC at scale and Google isn't using Go gRPC at scale. Which in itself makes a lot more sense because C# is the bread and butter language at MSFT for most large network services and Go isn't at Google, it barely has any penetration compared to Java and C++ (which predictably have much much faster gRPC and PB implementations).

Re:Go 1.19 Beta 1 is released by quixoticelixer- on Saturday June 11, 2022 @02:27AM (#31702432)
Yeah i really don't understand the advantage of go over c#. Async maybe?
Re:Go 1.19 Beta 1 is released by kjeetgill on Saturday June 11, 2022 @02:44AM (#31702492)
I'd argue goroutines are a mostly better alternative to async. Maybe a bit less optimal for a vast improvement of ergonomics and applicability.
Re:Go 1.19 Beta 1 is released by jpgvm on Saturday June 11, 2022 @03:05AM (#31702588)
Goroutines are better than C# async/await but C# is still a better language than Go.

When Java 19 lands you can have best of both worlds. Virtual Threads are equivalent to goroutines but you have access to better languages like Java, Kotlin and Clojure.

Re:Go 1.19 Beta 1 is released by morelisp on Saturday June 11, 2022 @03:51AM (#31702755)
I don't think virtual threads will be fully baked in time for production use at Java 19. IMO we'll be waiting at least one and probably two more releases.

Valhalla has also produced an amount of language machinery that results in most of the same issues as Go. (E.g. "is this function receiving an interface or concrete value?" becomes "do I have a class, value class, or primitive class?") The performance ripples of requiring value objects to be immutable also remains to be seen.

Re:Go 1.19 Beta 1 is released by jpgvm on Saturday June 11, 2022 @05:49AM (#31703253)
True. I intend to start using them the moment they land in preview but there is still some caveats (namely how they interact with synchronized).

I think by Java 21 they will be rock solid though which isn't really that far away in Java timescales.

Re:Go 1.19 Beta 1 is released by morelisp on Saturday June 11, 2022 @07:13AM (#31703637)
Sure, but by Java 21 we'll have Go 1.21 with a couple release cycles to push generics into stdlib, and we're back to more or less useless debates about aesthetic preferences and tooling priorities again.
Re:Go 1.19 Beta 1 is released by kaba0 on Saturday June 11, 2022 @07:00AM (#31703567)
Aren’t they in preview in 19 already?
Re:Go 1.19 Beta 1 is released by jpgvm on Saturday June 11, 2022 @09:12AM (#31704202)
Yes technically as they have been merged but 19 isn't out until September, you can download early-access builds today but we won't see a release build until the official release date.
Re:Go 1.19 Beta 1 is released by kaba0 on Saturday June 11, 2022 @07:00AM (#31703564)
> The performance ripples of requiring value objects to be immutable also remains to be seen

Immutability is trivial to optimize away.

Re:Go 1.19 Beta 1 is released by zija on Saturday June 11, 2022 @04:22AM (#31702862)
C# team began experimenting with green threads: https://twitter.com/davidfowl/status/1532880744732758018?t=P...
Re:Go 1.19 Beta 1 is released by jpgvm on Saturday June 11, 2022 @05:47AM (#31703243)
Well that is very cool!
Re:Go 1.19 Beta 1 is released by quixoticelixer- on Saturday June 18, 2022 @01:16AM (#31787406)
Yeah goroutines is what i meant by better async. I've used the clojure async stuff a fair bit which was heavily inspired by goroutines and it is quite nice.