5 ms·
The lack of compaction is not just a bullet point. Especially on large memory data-sets Go's GC will start to suffer and not just on the collection side of thi
by kasey_junk 10y ago
The lack of compaction is not just a bullet point. Especially on large memory data-sets Go's GC will start to suffer and not just on the collection side of things but on the allocation side as well.
- weberc2 10y agoHow do you mean? The 1.5 benchmarks showed Go cleaning up a 250GB heap in 5ms.
- kasey_junk 10y agoYour allocation times will go up as the heap gets fragmented and the it becomes harder to find places to put new items. This is especially true of large interconnected data sets. Further, depending on your data access patterns you can see data access start to degrade over time as well because the memory locality is worse. GC benchmarks are great at showing how well 1 part of memory management is behaving (ie the deallocation step) but it doesn't do much for talking about the other 2 parts, allocation and access. That said, I use Go lang every day and the GC improvements to date have been great, especially given the kinds of memory patterns lots of the services I write have (small, short lived items that aren't really connected to each other). But there are definitely memory patterns where Hotspot will smoke the golang memory system and that doesn't begin to describe something like Zing.
- weberc2 10y agoCool, thanks for the information. :)
- uluyol 10y agoIt would be nice to quantify what the impact of this is. Go is no worse in this regard than C++ (it even uses a fork of tcmalloc for allocation) and has support for value types so there is a lot less pointer chasing than in Java. Not sure how it could be done but having some numbers on this would be great.
- geodel 10y agoZing is not some magic. To start with it needs heavily over provisioned servers with like 64GB+ RAM recommended. And to have the pauseless GC it needs additional contingency and pause prevention memory pools on top of -Xmx memory settings. And still I have heard the one of the best way to control GC in many trading systems where Zing might be popular is to just provision 100s of GBs of memory heap and simply restart server once trading day is over.
- kasey_junk 10y agoWhen I was writing trading systems on JVMs we were much more worried about allocation costs and memory access patterns than we were about GC. The former issues impact the normal latency while the latter impacted the worst case. Now you needed to think about and deal with the worst case, but as you say, making a system that doesn't GC often is pretty straight forward. Now that I'm writing high throughput systems in go I use many of the same techniques that I did writing low latency systems on the JVM (arena allocation, memory locality, etc). This is because the other 2 parts of memory management, allocation and access, continue to be major drivers of performance even though the deallocation step is fundamentally different. That is to say, GC times are not the only thing that matters when it comes to memory management and it is a relatively straightforward tradeoff between deallocation and allocation that the current golang GC is making.
- geodel 10y agoI do not disagree with that but unless some real life example is shown of Go vs Java GC I am inclined to believe advantage is mostly theoretical.
- pcwalton 10y agobinary-trees is Hans Boehm's benchmark of garbage collection performance (mostly throughput). Bump allocation in the nursery ends up being king here, and it's reflected in the numbers: https://benchmarksgame.alioth.debian.org/u64q/performance.php?test=binarytrees https://benchmarksgame.alioth.debian.org/u64q/performance.ph...
- geodel 10y agoI am not sure in the apps where Go/Java languages are mostly targeted how many times people are implementing binary trees as their core/dominating business logic.
- igouy 10y agoHeader comment from Hans Boehm's original test program -- "This is no substitute for real applications. No actual application is likely to behave in exactly this way. However, this benchmark was designed to be more representative of real applications than other Java GC benchmarks of which we are aware."
- pcwalton 10y agoMost allocations in real-world apps are nursery allocations (that's the generational hypothesis after all), so the speed of nursery allocations, which is what results in the throughput differential here, very much matters in practice.
- igouy 10y agoFrom Hans Boehm's java program -- "The results are only really meaningful together with a specification of how much memory was used. It is possible to trade memory for better time performance. This benchmark should be run in a 32 MB heap, though we don't currently know how to enforce that uniformly." For some years, the benchmarks game did show an alternative task where memory was limited -- but only for half-a-dozen language implementations. Figuring out an appropriate max heap size for each program was too hands-on trial and error.
- gribbly 10y agoOn the other hand, compaction is itself an extremely expensive operation as it means moving the blocks of memory (allocations) around in the heap. Do you know of any real-world examples where the lack of compaction is impacting usage of Go ?
- pcwalton 10y ago> On the other hand, compaction is itself an extremely expensive operation as it means moving the blocks of memory (allocations) around in the heap. That's why you don't do it often. > Do you know of any real-world examples where the lack of compaction is impacting usage of Go ? The biggest problem with all nongenerational GCs, including Go's, is lack of bump allocation in the nursery. You really want a two-space copying collector (or a single-space one) so that allocation in the nursery can be reduced to 3 or 4 machine instructions. By allowing fragmentation in the nursery, Go pays a heavy cost in allocation performance relative to HotSpot.
- gribbly 10y ago>That's why you don't do it often. You need to do it when you become too fragmented (or suffer the same potentially poor allocation performance as Go), how often that happens largely depends on what the application is doing. >including Go's, is lack of bump allocation in the nursery. Yes, but as I recall this is in the future roadmap for consideration/attempt. And again, as with everything it's not a silver bullet, as you sacrifice the high cost of promotion (again expensive moving of memory) in order to have very fast allocations while the nursery isn't fragmented or full. >Go pays a heavy cost in allocation performance relative to HotSpot. But not the cost of compaction/promoting, which are also heavy when they need to be performed. That said, I personally believe a bump allocator with generational copying will be a 'net win' if implemented in Go's GC, but all things considered I'd rather see some cold hard numbers confirming it.
- pcwalton 10y ago> Yes, but as I recall this is in the future roadmap for consideration/attempt. Not according to the transactional collector proposal. By not unconditionally tenuring young objects, it sacrifices one of the main benefits of generational GC: bump allocation in the nursery. > And again, as with everything it's not a silver bullet, as you sacrifice the high cost of promotion (again expensive moving of memory) in order to have very fast allocations while the nursery isn't fragmented or full. You're questioning the generational hypothesis. Generational GC was invented in 1984. Whether generational GC works is something we've had over 30 years to figure out, and the answer has consistently been a resounding "yes, it works, and works well". > all things considered I'd rather see some cold hard numbers confirming it. Again, we have over 30 years of experience. Generational GC is not some new research idea that we have to try to see if it works. The odds that things will be different in Go than in the myriad of other languages that preceded it are incredibly slim.