News for hackers. Stuff that matters.
Re:Java is better than C++ for high speed trading systems by jjav on Thursday November 26, 2020 @02:30AM (#25217741)
You should not have any full GC (pause) events, ever, in properly written production Java code.

Source: I worked on several extremely high performance Java systems at Sun and also worked optimizing various Java servers at subsequent jobs based on my Sun experience.

At one company (after Sun) I took on a backend service which was doing GC pauses every 3-5 minutes, the code was a dumpster fire mess. After cleaning things up we didn't hit a single full GC in two months of production use (they redeployed every two months so that's as long as the process lasted).

Re:Java is better than C++ for high speed trading systems by blub on Thursday November 26, 2020 @02:36AM (#25217790)
Extremely high performance properly written Java code has been mentioned so many times in Java performance discussions that it has acquired an almost legendary status, right there with the sufficiently smart compiler.
Re:Java is better than C++ for high speed trading systems by RhysU on Thursday November 26, 2020 @04:46AM (#25218453)
I have observed the former, written by exceptional coworkers, but never the latter.
Re:Java is better than C++ for high speed trading systems by zozbot234 on Thursday November 26, 2020 @02:42AM (#25217813)
Maybe, but that just raises the question...If you're coding your system under the constraint that you should not be having any GC-event, what's the point of picking a GC language in the first place?
Re:Java is better than C++ for high speed trading systems by jjav on Thursday November 26, 2020 @03:06AM (#25217939)
As others said, no full GC events. Young generation GC is cheap, no need to avoid that.

Productivity is the point. Even while paying attention to GC, it's much faster to write good code in Java than to worry about every malloc() in C. I love C, but if I need to churn out high performance code quickly, Java is the choice.

Re:Java is better than C++ for high speed trading systems by jcelerier on Thursday November 26, 2020 @03:27AM (#25218043)
But here we're talking about C++: you don't write malloc, you use containers that encapsulate memory management - likely std::containers with pool allocators. And you put things on the stack. Code is as readable if not more than java - there isn't any "new," anywhere in sight
Re:Java is better than C++ for high speed trading systems by jjav on Thursday November 26, 2020 @03:50AM (#25218161)
Modern C++ is probably about as good, with sufficient team discipline. I don't have enough recent experience with C++ to have a strong opinion.

IMO (possibly biased by how much I hated C++ in the 90s) it is easier to maintain clean code discipline in a large team with Java than it is with C++.

Re:Java is better than C++ for high speed trading systems by lordnacho on Thursday November 26, 2020 @08:46AM (#25219954)
C++ after 11 is a very different beast. It's more pleasant to write compared with pre-11. Memory model, move semantics, smart pointers, lots of stuff standardized instead of left to the libraries.

Definitely depends on your team of course.

Re:Java is better than C++ for high speed trading systems by mistrial9 on Thursday November 26, 2020 @10:10AM (#25220621)
smart pointer template blah, instead of pointer blah, in a very large code base.. hmm not so pleasant.. the debug level function definitions, adding templated parameters, are literally unreadable. I will agree that the mental model is tamer.
Re:Java is better than C++ for high speed trading systems by brazzy on Thursday November 26, 2020 @02:56AM (#25217893)
GP was not talking about "any GC-event", but about "any full GC (pause) events". That's where the heap has gotten so messy that everything has to stop while the GC sorts it out. It's an absolute worst case scenario. Under normal conditions on a modern JVM, the GC runs in parallel with the application and does not cause any pauses.
Re:Java is better than C++ for high speed trading systems by tsimionescu on Thursday November 26, 2020 @03:00AM (#25217907)
They said no full GC. The GC runs constantly in parallel with your program and cleans up what it can, but never has to pause execution of the whole program to reclaim even more memory. Not claiming I know how to do this, but I believe this is what they claiming.
Re:Java is better than C++ for high speed trading systems by benjaminjackman on Thursday November 26, 2020 @10:49AM (#25220982)
Well, the first place may have predated you and a rewrite is out of the question.

A few other reasons:

The rest of the platform for review and analysis doesn’t have such stringent performance requirements and it would be nice to reuse code.

There also may be some good libraries that are jvm only that your program relies on.

Packing up a fat jar can be a lot easier, less complex and more reliable than building a binary.

Your dev team has a lot Java expertise.

Getting Java to not allocate is not as hard as it seems if you set out to do it from the start. And even if not it’s not impossible because the tooling is so good. You just have to know the right tricks and it can be easier to incrementally learn those tricks for a dev team than learn C++ and it’s ecosystem.

Re:Java is better than C++ for high speed trading systems by stef-13013 on Thursday November 26, 2020 @04:15AM (#25218291)
I agree, because I've seen that in my previous jobs...

Programmers used to say that the GC and its fuc*#=+ STW was a pure mess, but under the hood, they didn't realize (accept ?) in fact the code WAS the mess.

Don't (always) blame the tool !

Re:Java is better than C++ for high speed trading systems by antpls on Thursday November 26, 2020 @02:48AM (#25217845)
Did you ever detailed on the Internet about those methods to attain no GC pause? It would be interesting to learn from your experience
Re:Java is better than C++ for high speed trading systems by jjav on Thursday November 26, 2020 @03:01AM (#25217911)
It's not rocket science honestly. Mostly any Java performance guide will tell you how.

Allocate either locally on the stack or allocate for the life of the process so it never gets GC'd.

Of course, spend time profiling to make sure you got it. Figure out your redeployment cadence and that sets the ceiling for how much data can be an exception to these rules.

(e.g. if you redeploy nightly then it's fine to grow the memory consumption as long as you don't hit full GC in less than 24hrs.)

In a nutshell that's it.