News for hackers. Stuff that matters.
Re:GraalVM by hedora on Sunday August 09, 2020 @11:18PM (#24105144)
Java’s linker is based on an open world assumption, where you can add arbitrary stuff to the classpath and dynamically link it at runtime. This defeats most compiler optimizations, so you’re left with the JIT.

GraalVM makes a closed world assumption, so it can do things like dead code elimination (for library functions that don’t get called), and apply static analysis to inline virtual method calls, perform constant propagation, and so on.

This lets it greatly outperform the JVM, at the expense of some rarely used functionality.

Basically, it’s like switching from the JIT to a C compiler’s -O3.

Re:GraalVM by bdibs on Sunday August 09, 2020 @11:28PM (#24105201)
And is that with their javac or is it reserved only for their native image generation?
Re:GraalVM by smabie on Monday August 10, 2020 @12:24AM (#24105547)
In my experience, native image is noticeably slower than regular openjdk, at least for Scala. The start up speed is nice, though.
Re:GraalVM by asymptotically2 on Monday August 10, 2020 @12:53AM (#24105675)
You need to pay Oracle $lots for a GraalVM enterprise licence to get profile guided optimisations, if you want some of your peak performance back.
Re:GraalVM by pjmlp on Monday August 10, 2020 @02:09AM (#24106092)
Twitter thinks otherwise, as they are the major consumer of GraalVM in production.
Re:GraalVM by didibus on Monday August 10, 2020 @02:16AM (#24106132)
GraalVM is a JIT compiler for the most part. That's the one Twitter uses I believe. SubstrateVM is what lets you perform a closed world assumption ahead of time build. And that does indeed run left performant most of the time, but it uses less memory and starts faster.
Re:GraalVM by pjmlp on Monday August 10, 2020 @03:03AM (#24106408)
Unless one feeds it with PGO data, just like it happens in most AOT workflows for optimizations like devirtualization.
Re:GraalVM by secondcoming on Monday August 10, 2020 @04:36AM (#24106913)
What part of production, do you know? Because mobile.twitter.com links are slow as hell to load
Re:GraalVM by pjmlp on Monday August 10, 2020 @04:47AM (#24106982)
Re:GraalVM by marta_morena_25 on Monday August 10, 2020 @01:42AM (#24105944)
> This lets it greatly outperform the JVM, at the expense of some rarely used functionality.

Outperform in what metric? Startup time? Granted. Anything else? Not so much.

>Basically, it’s like switching from the JIT to a C compiler’s -O3.

Yeah and that would be pretty bad (it's not a good analogy to begin with). "-O3" doesn't have anything that a JIT couldn't have. The only advantage is again, startup time. JIT compilation has otherwise only advantages over static compilcation, especially in highly polymorphic code, such as java. Static compilation for polymorphic code is a joke in terms of performance... And every C++ programmer should know that.

I didn't look at the spec, but I would assume that AOT is only the bootup and then the JIT will take over anyway. This means, they'd do some basic precompilation for fat bootup and then use JIT again to optimize the code further based on runtime analysis. Everything else would be a ridicolous step backwards in time and make AOT completely useless, except for some niche scenarios.

Re:GraalVM by TimTheTinker on Monday August 10, 2020 @02:28AM (#24106214)
As far as I know, Truffle is able to do some absolutely incredible compile-time optimizations —- reaching deeply into what we would normally regard as strictly semantic territory.

(For an example, see some of the optimizations done by TruffleRuby for things like `myArray.sort.first` - which it apparently optimizes by terminating the sort as soon as the first element is sorted to the front of the array... and all that without any special hints in the standard library. Please correct me if I’m wrong... it’s been a few years since I’ve read in depth about TruffleRuby. And granted this example isn’t Java, but I imagine there are great parallels there.)

Re:GraalVM by tosh on Monday August 10, 2020 @06:35AM (#24107633)
I'm not sure how it would terminate sort early, my initial assumption was that for small arrays there might be special-casing?

this seems to be a related thread on twitter:

https://twitter.com/ChrisGSeaton/status/1001582169578524672

Re:GraalVM by monadic2 on Monday August 10, 2020 @07:36AM (#24108133)
Are you unsure about the runtime considerations or how the compiler would infer the necessary optimizations?
Re:GraalVM by innagadadavida on Monday August 10, 2020 @10:50AM (#24109853)
Can the storage of generic containers change as well? For example, store the objects in the container instead of reference?
Re:GraalVM by galaxyLogic on Monday August 10, 2020 @02:34AM (#24106244)
> Startup time? Granted. Anything else? Not so much.

Startup time matters a lot especially for Java applications. The reason Java never got to the desktop (including browser) I believe was the startup time.

Startup time matters a lot also for micro-services.

A 2nd great benefit of GraalVM I think is it makes it easy to integrate programs written in different languages, say Node.js and Java for instance.

Re:GraalVM by Erlich_Bachman on Monday August 10, 2020 @04:59AM (#24107053)
> Java never got to the desktop (including browser)

What do you mean by this? There are a lot of desktop Java applications...

Re:GraalVM by outadoc on Monday August 10, 2020 @09:31AM (#24109007)
I'd like to hear about them, because apart from enterprise applications, there aren't that many left. Electron is the new desktop Java.
Re:GraalVM by hoistbypetard on Monday August 10, 2020 @05:19PM (#24114113)
I wouldn't call them dominant by any stretch, but I wouldn't call them uncommon. Ones I use somewhere between daily and semi-regularly:

* Pycharm * Datagrip * Charles * JDiskReport * TexturePacker * Android Studio and associated tools * Apache Directory Studio * Zed attack proxy

That's just stuff that I've used recently and on an ongoing basis... I feel like I see quite a bit more of it.

Re:GraalVM by galaxyLogic on Tuesday August 11, 2020 @02:35AM (#24117725)
I used to use a thing called JMeter. But its GUI felt inferior in my view compared to typical Windows applications.
Re:GraalVM by mikkom on Monday August 10, 2020 @05:16AM (#24107159)
> The reason Java never got to the desktop (including browser) I believe was the startup time.

I think it's mainly the fact that it has always been very difficult to create executable files.

Running java requires you to install the given version of JRE instead of just downloading an application and starting it.

Re:GraalVM by pjmlp on Monday August 10, 2020 @07:50AM (#24108252)
It was always very easy, just package the JRE with the application, use an installer like any other desktop application, or buy one of those commercial AOT compilers available since the start of century.
Re:GraalVM by benibela on Monday August 10, 2020 @04:54PM (#24113861)
But that takes a lot of space

You could not fit it on a floppy

Re:GraalVM by pjmlp on Monday August 10, 2020 @04:57PM (#24113907)
The 8 and 16 bit home computer scene are way past us.
Re:GraalVM by sriku on Monday August 10, 2020 @03:36AM (#24106585)
There's also an expectation that memory footprint will be lower and that can contribute to speed by reducing GC time. The "JIT can do it too" arguments generally don't consider bounded memory.
Re:GraalVM by avasthe on Monday August 10, 2020 @11:52PM (#24117016)
Hehehe the old AOT vs JIT debate.

JITs can do great optimizations in theory. But in practice they have only so much time to do optimizations.

And startup time, binary distribution size, memory footprint matter too.