Live data from Hacker News

Why low-latency Java still requires discipline?

chronicle.software

41–50 of 56 posts

Re: Why low-latency Java still requires discipline?

#41
post #35
post #34

Earlier quoted context omitted.

Yes. & in the end my experience has been that you can write low latency code with gc, but only by expending more effort than it'd take to use manual memory management

First of all it depends on the language, what GC models it supports, and what are the performance SLAs. Secondly if we are talking about something like real time audio, or sending the maximum amount of triangles per second, then there is zero memory management, the code should be allocation free across all the critical path, regardless of the language.

Aka 'follow JSF guidelines that still apply to C and not just C++'.

I.e. all alloc should happen up front, functions should have predictable execution time, etc etc

Re: Why low-latency Java still requires discipline?

#42

How about not using Java? Then you can have low latency. Average go, rust, c++ and c will outperform amazing java programs, and the former will also be way way more easy to run, troubleshoot, interpret logs from. Java is usch garbage in every stack.

Java is a great language and runtime. Java being slow is most often a pebcak scenario. There are massive, fast, low latency, Java systems out there that have been written by competent developers.

> Java being slow is most often a pebcak scenario

Am I the only one who thinks "pebkac" is a self-own? If you're blaming your users for the tool, it feels like maybe your tool is just hard to use properly. I have no doubt that there are big, fast, low latency Java systems out there, but why does it take so much extra effort to build these systems in Java compared with other languages? Maybe it would be better to have competent developers focus their attention beyond managing Java's shortcomings?

I'm not even hating on Java here--I actually like the JVM quite a bit, but blaming users feels like an implicit admission.

Re: Why low-latency Java still requires discipline?

#43

Earlier quoted context omitted.

Java is a great language and runtime. Java being slow is most often a pebcak scenario. There are massive, fast, low latency, Java systems out there that have been written by competent developers.

> Java being slow is most often a pebcak scenario Am I the only one who thinks "pebkac" is a self-own? If you're blaming your users for the tool, it feels like maybe your tool is just hard to use properly. I have no doubt that there are big, fast, low latency Java systems out there, but why does it take so much extra effort to build these systems in Java compared with other languages? Maybe it would be better to have…

> Am I the only one who thinks "pebkac" is a self-own?

There's no such thing as a programming language that guarantees excellent performance regardless of programming competence.

> why does it take so much extra effort to build these systems in Java compared with other languages?

They didn't say that.

Re: Why low-latency Java still requires discipline?

#44

Earlier quoted context omitted.

> Java being slow is most often a pebcak scenario Am I the only one who thinks "pebkac" is a self-own? If you're blaming your users for the tool, it feels like maybe your tool is just hard to use properly. I have no doubt that there are big, fast, low latency Java systems out there, but why does it take so much extra effort to build these systems in Java compared with other languages? Maybe it would be better to have…

> Am I the only one who thinks "pebkac" is a self-own? There's no such thing as a programming language that guarantees excellent performance regardless of programming competence. > why does it take so much extra effort to build these systems in Java compared with other languages? They didn't say that.

> They didn't say that.

The entire premise of the conversation is that other languages allow us to write idiomatic code and get good performance, and the parent's position was that Java requires "competent developers". So yes, the parent did say that, however...

> There's no such thing as a programming language that guarantees excellent performance regardless of programming competence.

No one made any claim remotely like this. This is a very obvious straw man argument. What was argued was that you can get decent performance from other languages without additional competence beyond idiomatic code.

Re: Why low-latency Java still requires discipline?

#45
post #16

Earlier quoted context omitted.

If low latency is your goal than you don't want JIT. JIT has two issues in low latency, first the first time through your code isn't compiled yet and so you get high latency. Second, it optimizes for the common case, which means when you hit an exception that exception will be higher latency because everything hits a branch miss. Of course we are talking generals here. Sometimes the above is acceptable and Java/JIT i…

Valid points, but this doesn't mean JIT doesn't work for relatively lower-latency coding. To avoid the compilation etc. hit, common practice is to do some "warmups" before serving users. (Another reply has other ways to avoid this hit.) Handling exceptions is higher latency, but they can/should be optimized out, so you're not hitting exceptions as part of your standard workflow (or even your 1% workflow).

Exceptions depend on the workflow. For some high frequently trades the normal case is you won't make money so don't trade - the exceptions for them are the only case where latency matters.

Don't read the above, as you can't use JIT or Java for low latency. I never intended to say that. However, you are going to be fighting the system if you do try to use them. fighting the system even more than C where you have more control

Re: Why low-latency Java still requires discipline?

#46
post #35
post #34

Earlier quoted context omitted.

Yes. & in the end my experience has been that you can write low latency code with gc, but only by expending more effort than it'd take to use manual memory management

First of all it depends on the language, what GC models it supports, and what are the performance SLAs. Secondly if we are talking about something like real time audio, or sending the maximum amount of triangles per second, then there is zero memory management, the code should be allocation free across all the critical path, regardless of the language.

Not just allocation free. It needs to be page-in free too. And critical loops need to be cacheline friendly.

Re: Why low-latency Java still requires discipline?

#47
post #16
post #9

Earlier quoted context omitted.

Rust? OK. C++ or go? Then you'll have to take a very closer look, because the java JIT is wonderful. A masterpiece of several hands, actually.

If low latency is your goal than you don't want JIT. JIT has two issues in low latency, first the first time through your code isn't compiled yet and so you get high latency. Second, it optimizes for the common case, which means when you hit an exception that exception will be higher latency because everything hits a branch miss. Of course we are talking generals here. Sometimes the above is acceptable and Java/JIT i…

> If low latency is your goal than you don't want JIT.

To be more specific, you don't want Java-style-JIT. Julia JIT (which functions closer to AOT in this case) is fine for low latency.

Re: Why low-latency Java still requires discipline?

#48
post #16
post #9

Earlier quoted context omitted.

Rust? OK. C++ or go? Then you'll have to take a very closer look, because the java JIT is wonderful. A masterpiece of several hands, actually.

If low latency is your goal than you don't want JIT. JIT has two issues in low latency, first the first time through your code isn't compiled yet and so you get high latency. Second, it optimizes for the common case, which means when you hit an exception that exception will be higher latency because everything hits a branch miss. Of course we are talking generals here. Sometimes the above is acceptable and Java/JIT i…

[deleted]

Re: Why low-latency Java still requires discipline?

#49

Earlier quoted context omitted.

Java is a great language and runtime. Java being slow is most often a pebcak scenario. There are massive, fast, low latency, Java systems out there that have been written by competent developers.

> Java being slow is most often a pebcak scenario Am I the only one who thinks "pebkac" is a self-own? If you're blaming your users for the tool, it feels like maybe your tool is just hard to use properly. I have no doubt that there are big, fast, low latency Java systems out there, but why does it take so much extra effort to build these systems in Java compared with other languages? Maybe it would be better to have…

pebkac is always the excuse with Java. "Oh, you didn't pass 6 -Xmxsmxmwhatever flags to make the JVM do sane things with your memory? You did stuff the regular way instead of whatever decorator-heavy framework? You didn't use this new feature they added last release? Were you born yesterday?"

And then there is real pebkac. Java code tends to be the worst, even though there are more newb-friendly things out there like JS. Sure you can choose to be a good programmer and use Java, but if you're being offered to join a "Java team," that doesn't usually mean good things.

Re: Why low-latency Java still requires discipline?

#50

How about not using Java? Then you can have low latency. Average go, rust, c++ and c will outperform amazing java programs, and the former will also be way way more easy to run, troubleshoot, interpret logs from. Java is usch garbage in every stack.

I've done some tests with current value classes in latest prototype with full optimisation through annotation. Apparently, everything was being compiled to assembly code with no gc calls. It seems this old school ideology of slow java is about to end in near future. I'm actually intrigued how it will compete with Rust which can't optimise code further while running, while JVM JIT has more info which it could aggressi…

Value classes and virtual threads are two things that change your Java usage almost fundamentally, but they're both relatively recent, so there's lots of old code that can't easily switch.
Post reply on HN