enonic / xp-distro

Enonic XP full distribution.
GNU General Public License v3.0
3 stars 3 forks source link

Migrate to GraalVM #218

Closed rymsha closed 2 years ago

rymsha commented 2 years ago

GraalVM has an embedded GraalJS that gives significant performance boost in some cases

At the same time GraalVM is based on OpenJDK 11 and should work out of the box with existing XP.

Since plan is to replace deprecated Nashorn with Graal.JS anyway, it is better to start the migration sooner than XP 8.

rymsha commented 2 years ago

The biggest complexity is, probably, the use of GraalVM docker image (https://github.com/graalvm/container/pkgs/container/jdk/20645583?tag=ol8-java11-22.1.0-b1) instead of OpenJDK ones on hub.docker.com

gbbirkisson commented 2 years ago

The implications of changing our current base image to that new image:

Alternative is to find (or create) a graalvm ubuntu image. That will simplify the build but probably introduce technical dept down the line.

sigdestad commented 2 years ago

It would be nice to get some input on how much work would go into building our own docker base image (i.e. GraalVM + Ubuntu) vs changing our build process.

As this is a feature release (7.10) Keeping current build process and avoiding changes for customers would be a strongly preferable.

rymsha commented 2 years ago

support of s390x ppc64 and armv7 - is just a joke (I hope).

jsi commented 2 years ago

I have run some tests with the regular 7.10.0-SNAPSHOT image for Mac (https://repo.enonic.com/service/rest/repository/browse/dev/com/enonic/xp/enonic-xp-mac-sdk/7.10.0-SNAPSHOT/), and it is very obvious that previews of for instance the pages in SuperHero or Image Expert are much faster than before. On the other hand, loading of large images seems to take about the same time, which obviously makes a lot of sense, considering it is the JavaScript engine that is faster and nothing else. - Will continue Mac-specific testing with Slava tomrorrow.

jsi commented 2 years ago

Is there any documentation that we need for this?

sigdestad commented 2 years ago

Surprised if superhero and image expert are faster, since we are still using Nashorn there AFAIK? Does GraalVM improve Nashorn performance as well?

jsi commented 2 years ago

Well, I don't know, but do these apps require Nashorn? If they are just written in JavaScript, don't they use the engine available?

I do not know, but now I just did a simple comparison test between 7.9.2 (without Graal) and 7.10.0-SNAPSHOT (with graal) on my local machine, and it is very obvious when I just browse the pages in Content Studio: The first time I click on the front page or any of the posts in SuperHero, the loading icon circles 5 or 6 times with 7.9.2, but only about 2 times with 7.10.0. If I go on to click on other posts, they appear almost instantly on 7.10.0, while I still see something like a half to a whole rotation of the loading icon with 7.9.2. Sorry that this is not more scientific, but it is so obvious, that more detailed science is not necessary. 😜

rymsha commented 2 years ago

Thomas is right, Superhero still uses Nashorn even on GraalVM. For now only react4xp based apps using SSR can benefit from new JS engine.

This performance improvement may easily be an effect of something else. GraalVM Community Edition may be more performant than stock OpenJDK, but may be worse in some cases, too.

sigdestad commented 2 years ago

If this is the case though, it is a very very acceptable side-effect :-)

sigdestad commented 2 years ago

Could it be that the new Graal compiler is so much better than old JIT?

rymsha commented 2 years ago

For me it looks like Superhero performance is the same.