News for hackers. Stuff that matters.
Re:Go’s march to low-latency GC by pcwalton on Wednesday July 06, 2016 @12:15PM (#12044044)
> Reading this causes me to experience déjà vu; years and years of reading stories and watching presentations about someone struggling with GC in the JVM. It's happening all over again with Go.

It's because GC is an area full of tradeoffs, and despite popular belief, the HotSpot GC is really good. In fact, I honestly don't know of any way to improve on the HotSpot GC for general-purpose use (i.e. throughput/latency balancing). HotSpot has a generational, concurrent, compacting GC; allocation takes 4 or 5 instructions (really!); the compiler has SROA to aggressively optimize out allocations where unneeded.

Re:Go’s march to low-latency GC by SEJeff on Wednesday July 06, 2016 @12:49PM (#12044302)
Look up the Azul Systems pgc. That is more or less the holy grail, but it is patented out the wazoo, and is a commercial implementation only.

Also, the jrockit jvm (which was from BEA and was purchased by Oracle) is actually quite a bit faster than hotspot and easier to introspect (lookup jrockit mission control) than hotspot. I suspect eventually they'll merge however.

Re:Go’s march to low-latency GC by pcwalton on Wednesday July 06, 2016 @01:30PM (#12044593)
> Look up the Azul Systems pgc. That is more or less the holy grail, but it is patented out the wazoo, and is a commercial implementation only.

That's what I was alluding to in the parenthetical. According to the paper, C4 trades off a significant amount of throughput for reduced latency. That's what you want for many applications, and C4 is a great advance for those apps, but throughput is very important for most workloads, so HotSpot's GC ends up yielding a good balance.

Re:Go’s march to low-latency GC by SEJeff on Wednesday July 06, 2016 @03:09PM (#12045173)
Touche, I clearly didn't fully understand your original statement. You're entirely correct in this case.
Re:Go’s march to low-latency GC by snaky on Wednesday July 06, 2016 @06:33PM (#12046328)
So we finally reaching the point where batch and interactive jobs are clearly separated because the very different tradeoffs they need. http://www.winestockwebdesign.com/Essays/Eternal_Mainframe.h... indeed.
Re:Go’s march to low-latency GC by sievebrain on Wednesday July 06, 2016 @01:02PM (#12044408)
It's not perfect. Azul's C4 does a lot of work in read barriers, so code that looks intuitively like it should be fast can end up causing "read storms" that bog the code down.

C4 never pauses, and that's impressive. But there's no free lunch. The work the GC would do when the app is paused is sometimes being simply done by the app threads instead.

Re:Go’s march to low-latency GC by BenoitP on Wednesday July 06, 2016 @02:29PM (#12044940)
I heard the read storm problem has been solved by Shenandoah, a GC developed by Christine Flood (who was in the original GC G1 team at Sun in 2001). It is under the RedHat umbrella and should be merged in OpenJDK [1].

Shenandoah uses a forwarding pointer in each object, adding overhead but limiting the problem only to write barriers. Here is Christine commenting on Azul vs Shenandoah [2]

From the talk: average pause is 6-7ms, max is 15ms, and the talk is one year old.

She hints at further developments in a version 2 which would make it entirely pauseless.

She has made another talk at RedHat's DevNation conference a few days ago, but they just won't put the video online arg!

[1] http://openjdk.java.net/jeps/189

[2] https://youtu.be/4d9-FQZZoVA?t=13m11s

Re:Go’s march to low-latency GC by astrange on Wednesday July 06, 2016 @04:27PM (#12045676)
Does Java still have a word in every object allocation for locking it? Adding a 64-bit pointer sounds terribly inefficient.

Did you know Objective-C does locks and retain counting without allocating any extra fields in objects?

Re:Go’s march to low-latency GC by sbanach on Wednesday July 06, 2016 @05:56PM (#12046133)
On hotspot: There are two bits in the header of every object. This is enough for an object that's never been used as a contended lock, CAS operations on the header can be used to handle the locking and that's that. As soon as you actually block on it, a 'real' lock is created (you can't get around the need for a list of threads to wake up as the lock is released) and the header grows to accomodate it. The process is called 'monitor inflation'. At a later date this might be cleaned up by a 'monitor deflation'.
Re:Go’s march to low-latency GC by jdmichal on Wednesday July 06, 2016 @01:36PM (#12044641)
There's a certain amount of work that has to be done for GC, and that work is going to be done somewhere. The question is just what trade-offs you want.

Don't want compacting? You'll pay for it in allocation.

Don't want pausing? You'll pay for it in application threads.

Re:Go’s march to low-latency GC by pcwalton on Wednesday July 06, 2016 @01:41PM (#12044665)
Precisely, and this is what is so often missed in these discussions. Most of the time, when you see claims of GC silver bullets, there's some hidden downside that's being papered over. Latency wins (i.e. "max pause time" or whatnot) tend to be throughput losses. Less copying results in more fragmentation. Value types can result in more copying, reducing performance over pointer indirections through nursery allocations. And so forth.
Re:Go’s march to low-latency GC by weberc2 on Wednesday July 06, 2016 @04:46PM (#12045793)
I don't know that anyone disputes this. The discussions I participate in don't deny this; they mostly talk about whether or not the tradeoffs result in a net gain (if you sacrifice a little from the minority of cases to gain the same amount in the majority of cases, you do indeed have a net gain).

> Value types can result in more copying, reducing performance over pointer indirections through nursery allocations

Having value types means you can pass by copy, but it also means you can allocate on the stack and pass by reference--in other words, you get performant passing without involving the GC.

Re:Go’s march to low-latency GC by cliffc on Friday July 08, 2016 @12:33PM (#12056744)
Nearly all the work you allude to is done in other threads - which indeed consume machine resources (CPU cycles, memory bandwidth). If your application does not burn all cores/bandwidth then the GC work is all done on the idle/spare machine resources. At the limit though, indeed you'll have to slow down the Application so that GC can play catchup - and bulk/batch stop-the-world style GC's require less overhead than the background incremental GCs Cliff
Re:Go’s march to low-latency GC by needusername on Wednesday July 06, 2016 @01:47PM (#12044699)
> C4 never pauses

To my knowledge this is false. AFAIK while the C4 algorithm is pauseless the C4 implementation is not. It's just that the pauses are really short.

Re:Go’s march to low-latency GC by sievebrain on Thursday July 07, 2016 @05:17AM (#12048296)
My understanding: C4 does not pause but the JVM still does for various other reasons and a part of the work on Zing has been forcing down those pause times too.
Re:Go’s march to low-latency GC by cliffc on Friday July 08, 2016 @12:30PM (#12056721)
Sorta kinda all of the above. C4 the algo has no pauses, but individual threads stop to crawl their own stacks. i.e., threads stop doing mutator work, but only 1-by-1, and only for a very short partial self-stack crawl. C4 the impl I believe now has no pauses also. HotSpot the JVM has pauses, and yes much Zing was on forcing these pause times down. Cliff
Re:Go’s march to low-latency GC by jstimpfle on Wednesday July 06, 2016 @12:53PM (#12044330)
Isn't it also because Java and/or having GC makes certain patterns easy although they should be hard? At least my limited experience with Java, from writing a system which dealt with millions of integers, is that Java really wants you to use ArrayList<Integer> instead of the GC-friendly int[].
Re:Go’s march to low-latency GC by Skinney on Wednesday July 06, 2016 @01:02PM (#12044401)
The problem with Java is that most things are a pointer, which means the GC has to deal with it. Go on the other hand allows the user to specify which things should be a value and what should be a pointer, which significantly decreases stress on the GC.

C# has something called value types, and while this helps (and Java is working on implementing something similar for Java 10) it's not as flexible as Go, where users can decide this at whim instead of specifying it in the type.

Re:Go’s march to low-latency GC by sievebrain on Wednesday July 06, 2016 @01:01PM (#12044397)
Java doesn't "want" you to use ArrayList<Integer>, that's merely more convenient if you need a dynamically sized array and don't want to do the resize yourself.

But the JVM folks are adding support for ArrayList<int> to the language, with the efficiency you'd expect from it.

Re:Go’s march to low-latency GC by tmd83 on Wednesday July 06, 2016 @03:00PM (#12045121)
Value types would hopefully get a big help in terms of getting the JVM GC better once the SDK and popular libraries full utilize it, both by reducing memory pressure and making the heap more GC friendly.
Re:Go’s march to low-latency GC by cliffc on Friday July 08, 2016 @12:36PM (#12056777)
Fun stuff I've been doing with the H2O project is basically using nearly-pure Java (some Unsafe) to hold onto numbers with better efficiency than e.g. int[], and giving out an easy-enough-to-use API for writing parallel & distributed code over an Array-like API. i.e., feels "almost like an array", and "for-loops" run at memory bandwidth speeds and also parallel and distributed. Cliff
Re:Go’s march to low-latency GC by cliffc on Friday July 08, 2016 @12:37PM (#12056783)
And the actual data is stored in giant byte[] (hidden behind the API), so the GC costs are near zero. Cliff