5 ms·
Go has gc too and arguably worse one than Java
by zokier 7mo ago
Go has gc too and arguably worse one than Java
- zadikian 7mo agoYeah but I do like not having to give Go several flags to do something reasonable with its memory
- oblio 7mo agoThat's a very shallow argument.
- zadikian 7mo agoIf it were shallow, it'd be easy for them to fix
- oblio 7mo agoBackwards compatibility, every vim and emacs and bash enthusiast should know about it. It's easy for the USER to fix, since there are flags available. In the day of LLMs it's also easy to find out about those flags and what they do. And if it's so important, testing shouldn't be supremely hard, either.
- zadikian 7mo agoDo you mean backwards compatibility for things that rely on the default settings? The defaults have already changed across Java versions and also depend on the system. Normally when you run a non-Java binary, it uses very little memory to start, doesn't have a limit, and returns memory to the system when it frees things. Supposedly you can set JVM flags to do all that, but performance probably suffers, otherwise they would've just done that. So in practice users are always setting the flags carefully.
- gf000 7mo agoThe "reasonable" thing go does is pausing core threads doing the actual work of your program, if it feels they create too much garbage so it can keep up, severely limiting throughput.
- mknyszek 7mo agoI think this is a misunderstanding. If the program out-paces the GC because the GC guessed the trigger point wrong, something has to give. In Go, what gives is goroutines have to use some of their time slice to assist the GC and pay down their allocations. In Java, I believe what you used to get was called "concurrent mode failure" which was somewhat notorious, since it would just stop the world to complete the mark phase. I don't know how this has changed. Poking around a little bit it seems like something similar in ZGC is called "allocation failure"? The GC assist approach adopted by Go was inspired by real-time GC techniques from the literature and in practice it works nicely. It's not perfect of course, but it's worked just fine for lots of programs. From a purely philosophical point of view, I think it results in a more graceful degradation under unexpectedly high allocation pressure than stopping the world, but what happens in practice is much more situational and relies on good heuristics in the implementation.
- adgjlsfhk1 7mo agoA lot of the answer is that if you can do more work while generating less garbage (lower allocation rate) this problem basically solves itself. Basically every "high performance GC language" other than Java allows for "value type"/"struct"s which allow for way lower allocation rate, which puts a lot less pressure on the GC.
- rossjudson 7mo agoAnd yet Java outruns pretty much all of them, because it doesn't actually allocate everything on the heap all of the time. And you've been able to declare and work with larger structures in raw memory for ... 20 years? You mostly don't need to, but sometimes you want to win benchmark wars. And of course it's getting value types now, so it'll win there too. As well as vectors.
- vips7L 7mo agoYou don’t have to do that with Java either.