News for hackers. Stuff that matters.
Re:IT Runs on Java 8 by babaganoosh89 on Friday May 10, 2019 @01:08PM (#19879854)
For such an advanced JVM, having to prewarm it by calling code 5000x times or the JVM being much more memory hungry than other non-JVM languages doesn't feel like the cutting edge.
Re:IT Runs on Java 8 by CountHackulus on Friday May 10, 2019 @04:57PM (#19882153)
If you're not calling your code 5000x then it's likely not important for performance. I worked in compilers for 5 years and people's intuition for what parts of the code are the bottleneck is generally not very good. This includes me, I've guessed wrong a WHOLE lot.

If you're running microbenchmarks and having issues, then you're likely not using JMH, the Java Microbenchmark Harness which used to be a 3rd party library but is now built in to Java 12.

Is Java memory hungry? Maybe. If you're just writing a small routing server, probably not the right use case for Java. If you're writing a big and complicated game server with hundreds of routes and you need to talk to MySQL, Redis, and Memcache then I'd say the memory overhead of Java is really quite good. Don't forget that you can tune the min/max heap and other things like that, especially with the module system in Java 11. However if very low memory is a requirement, then you're probably running in an embedded environment and you probably shouldn't be using Java.

Re:IT Runs on Java 8 by tus87 on Friday May 10, 2019 @05:33PM (#19882461)
> If you're just writing a small routing server, probably not the right use case for Java.

General purpose languages have "use-cases"?

Re:IT Runs on Java 8 by ric2b on Saturday May 11, 2019 @08:48AM (#19885885)
Yes, I wouldn't use Haskell for scripting and I wouldn't use javascript for a 3D game engine.
Re:IT Runs on Java 8 by evacchi on Friday May 10, 2019 @05:41PM (#19882506)
I think in this context Java means "the platform" i.e. the JDK
Re:IT Runs on Java 8 by xxs on Friday May 10, 2019 @01:53PM (#19880396)
the usual C2 kicks-in is 10000, not 5k. But that statement about warming up is true only for microbenchmarks.

C1 which is an dumb (but not terrible) compiler tends to be at 1k, and if you cannot get your code to 1k, likely it never needs compilation, so no point to spend time and space on performing the said compilation.

The 'prewarming' does include perf. counters, so it's guided compilation to boot.

Re:IT Runs on Java 8 by knowsmorsecode on Friday May 10, 2019 @01:32PM (#19880147)
What?
Re:IT Runs on Java 8 by stingraycharles on Friday May 10, 2019 @01:40PM (#19880231)
I suspect that the parent is talking about the JVM's JIT, where it compiles java bytecode into machine instructions after loading the application. This is why the first few requests on a JVM are usually considerably slower than the rest.

Parent is obviously exaggerating with the 5000x, and he could have made his point in a different way, but there's some truth to it.

Re:IT Runs on Java 8 by wolf550e on Friday May 10, 2019 @02:02PM (#19880487)
5000 refers to number of times a method needs to be called before the JIT decides the method is "warm" and needs to be compiled by the expensive to run C2 compiler which produces good quality machine code.

If you're benchmarking java code and the method was not called enough times before you measure, you're measuring code compiled by C1 (or even interpreted).

The performance gap between Java and C is on the order of x2 to x5.

Re:IT Runs on Java 8 by rsanek on Friday May 10, 2019 @03:03PM (#19881123)
Why not just pass -Xcomp? From the docs[1]: "You can completely disable interpretation of Java methods before compilation by specifying the -Xcomp option."

[1] https://docs.oracle.com/javase/8/docs/technotes/tools/window...

Re:IT Runs on Java 8 by shawnz on Friday May 10, 2019 @01:53PM (#19880392)
At the same time, JIT can outperform native code in some specific circumstances, since there are certain optimizations which can be proven safe at runtime which can not be guaranteed to be safe at compile time
Re:IT Runs on Java 8 by gameswithgo on Friday May 10, 2019 @04:48PM (#19882089)
this is a thing people say a lot but it is not something that seems to often result in an actual java program or benchmark being faster than program compiled AOT by an equivalently smart compiler (llvm etc)
Re:IT Runs on Java 8 by xxs on Friday May 10, 2019 @02:10PM (#19880567)
Actually one of the less known features of the JIT is the ability to deoptimize/recompile based on CHA (class hierarchy analysis) or pushed compilation request via invokeDynamic&friends.