News for hackers. Stuff that matters.
Re:Go’s march to low-latency GC by geodel on Wednesday July 06, 2016 @07:20AM (#12042361)
Technically hotspot GC might do more work in same amount of time but Go's GC makes some performance guarantees like <10ms STW phase which hotspot do not claim or offers for large heaps.
Re:Go’s march to low-latency GC by pcwalton on Wednesday July 06, 2016 @11:59AM (#12043929)
HotSpot does offer that. It's basic functionality that all incremental or concurrent garbage collectors offer. You can adjust the max pause time with -XX:MaxGCPauseMillis.
Re:Go’s march to low-latency GC by pas on Friday July 08, 2016 @05:29AM (#12054417)
That's a target. (GC ergonomics)

It won't guarantee it, just tires to size things (eden space, survivor spaces) and time things to meet its target.

But it's a fickle beast. And usually it requires a lot of tinkering with the code for it to be able to meet it. And then it's easier to disable ergonomics, set fixed sizes, and just enjoy how blazingly fast CMS is, restart the app every few weeks (CMS heap fragmentation), and try G1 with every new point release, maybe finally it beats CMS.

Re:Go’s march to low-latency GC by sievebrain on Wednesday July 06, 2016 @08:26AM (#12042593)
Yes, but that's because the Go GC doesn't compact, and nobody quotes throughput numbers. Building a slow GC that leaves the heap fragmented but has short pauses is not that difficult indeed, the tricky part starts when you wish to combine all these things together.
Re:Go’s march to low-latency GC by geodel on Wednesday July 06, 2016 @08:46AM (#12042670)
Of course Java has all technical bullet points checked and may be superior GC from strictly that point of view. But Go has 2 things from users' perspective upfront which Java lacks.

1. It uses about an order of magnitude less memory than Java.

2. It openly proclaims <10ms STW pauses for GC.

Re:Go’s march to low-latency GC by mdasen on Wednesday July 06, 2016 @10:27AM (#12043237)
Go definitely does not use "an order of magnitude less memory than Java". That would mean that a Go program that uses 1GB of memory would need 10GB in Java.

Google wrote a paper comparing C++, Java, Scala, and Go and definitely did not find that (https://days2011.scala-lang.org/sites/days2011/files/ws3-1-H...).

I like Go and it has many wonderful qualities. Still, it's important to be realistic.

Re:Go’s march to low-latency GC by richard_todd on Wednesday July 06, 2016 @12:32PM (#12044176)
I think for "small-data" programs it does work out to about an order of magnitude of overhead in Java. I have ported several small Java programs to Go and I see it (like 100MB Java vs 8MB Go). One encryption program I coded multiple versions of ran 350k C vs. 1.3MB Go vs. 16MB Java.

Programs holding GBs of data in arrays would look much closer, though, I imagine, as the overhead would be dwarfed by the data itself.

Re:Go’s march to low-latency GC by geodel on Wednesday July 06, 2016 @02:37PM (#12044990)
Possible. But typically idiomatic Java usage patterns with collection types have huge overheads. So unless Java code is written in specially memory efficient way that memory usage gap should remain

https://www.cs.virginia.edu/kim/publicity/pldi09tutorials/me...

Re:Go’s march to low-latency GC by lossolo on Wednesday July 06, 2016 @10:52AM (#12043431)
In my experience it does use less memory than Java. I had application written in Java which i migrated to Go and i see less memory usage.
Re:Go’s march to low-latency GC by geodel on Wednesday July 06, 2016 @12:18PM (#12044077)
Well depending on program. Here is what I see.

https://benchmarksgame.alioth.debian.org/u64q/go.html

Re:Go’s march to low-latency GC by igouy on Wednesday July 06, 2016 @12:45PM (#12044275)
"When there's a big disparity between those Java and [Go] programs, it's mostly the default JVM memory allocation versus whatever [Go] needs."

http://programmers.stackexchange.com/questions/189542/is-mem...

Re:Go’s march to low-latency GC by geodel on Wednesday July 06, 2016 @01:59PM (#12044783)
I looked at this:

http://stackoverflow.com/questions/5673388/what-is-the-small...

For me using Java 1.8 the number is around 1.5MB. Something similar in Go is 60KB

Re:Go’s march to low-latency GC by kasey_junk on Wednesday July 06, 2016 @09:57AM (#12043061)
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.
Re:Go’s march to low-latency GC by gribbly on Wednesday July 06, 2016 @10:59AM (#12043490)
On 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 ?

Re:Go’s march to low-latency GC by pcwalton on Wednesday July 06, 2016 @12:01PM (#12043939)
> 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.

Re:Go’s march to low-latency GC by gribbly on Wednesday July 06, 2016 @12:52PM (#12044322)
>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.

Re:Go’s march to low-latency GC by pcwalton on Wednesday July 06, 2016 @01:35PM (#12044629)
> 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.

Re:Go’s march to low-latency GC by gribbly on Wednesday July 06, 2016 @06:44PM (#12046371)
>Not according to the transactional collector proposal.

That's hardly the end all of Go GC development, also as I understand it's not even certain it will be used in a Go release as it depends on it actually showing the benefits aren't just theorethical.

>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".

This was not about generational GC's 'working' or not, it was if it is the best solution for the typical workloads of Go applications.

Re:Go’s march to low-latency GC by tptacek on Wednesday July 06, 2016 @09:21PM (#12046947)
Speaking as someone who works in Go full-time and really likes it: kind of the whole point of Go is that it's workloads are very much like every other language.
Re:Go’s march to low-latency GC by gribbly on Thursday July 07, 2016 @10:15AM (#12049424)
I figured the wide use of goroutines would be the cause for different choices in Go's GC compared to other GC's for languagues not sharing that characteristic.

From what I understand, the upcoming transactional collector is written directly with Go's goroutines in mind.

Re:Go’s march to low-latency GC by pcwalton on Thursday July 07, 2016 @10:09PM (#12053222)
> From what I understand, the upcoming transactional collector is written directly with Go's goroutines in mind.

I'm pretty skeptical that it will produce wins over a traditional generational GC. At best the "transactional hypothesis" will roughly approximate the generational hypothesis, without the primary benefit that truly generational GC gives you, namely bump allocation in the nursery. Time will tell.

Re:Go’s march to low-latency GC by weberc2 on Wednesday July 06, 2016 @10:07AM (#12043114)
How do you mean? The 1.5 benchmarks showed Go cleaning up a 250GB heap in 5ms.
Re:Go’s march to low-latency GC by kasey_junk on Wednesday July 06, 2016 @10:16AM (#12043167)
Your 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.

Re:Go’s march to low-latency GC by geodel on Wednesday July 06, 2016 @01:12PM (#12044469)
Zing 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.

Re:Go’s march to low-latency GC by kasey_junk on Wednesday July 06, 2016 @09:34PM (#12046983)
When 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.

Re:Go’s march to low-latency GC by uluyol on Wednesday July 06, 2016 @11:48AM (#12043839)
It 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.

Re:Go’s march to low-latency GC by weberc2 on Wednesday July 06, 2016 @10:33AM (#12043287)
Cool, thanks for the information. :)
Re:Go’s march to low-latency GC by geodel on Wednesday July 06, 2016 @10:20AM (#12043196)
I 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.
Re:Go’s march to low-latency GC by pcwalton on Wednesday July 06, 2016 @12:16PM (#12044069)
binary-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.ph...
Re:Go’s march to low-latency GC by igouy on Wednesday July 06, 2016 @01:32PM (#12044610)
From 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.

Re:Go’s march to low-latency GC by geodel on Wednesday July 06, 2016 @12:43PM (#12044261)
I 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.
Re:Go’s march to low-latency GC by igouy on Wednesday July 06, 2016 @01:14PM (#12044486)
Header 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."

Re:Go’s march to low-latency GC by pcwalton on Wednesday July 06, 2016 @01:31PM (#12044600)
Most 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.
Re:Go’s march to low-latency GC by the8472 on Wednesday July 06, 2016 @12:02PM (#12043952)
> 2. It openly proclaims <10ms STW pauses for GC.

Java's GCs make no concrete claims because they scale from tiny to very large heaps with vastly different object populations and root set sizes.

Some java applications run with 100GB heaps or on 128-core NUMA machines with lots of threads.

10ms pause times are achievable with "modest" heap sizes (~single-digit GBs) if you have some cores to spare for a concurrent collector to do its work, well, concurrently.

If you don't have enough spare CPU time or have a larger heap or a workload without enough breathing room then it would be silly to make such guarantees.

Of course they could easily write "<10ms STW pauses. sometimes. read the fine print"