Speed Up Groovy Script Execution 20x - GraalVM Tutorial 🚀

  Рет қаралды 6,165

Szymon Stepniak

Szymon Stepniak

Күн бұрын

Пікірлер: 40
@sferrazjr
@sferrazjr 4 жыл бұрын
I came to see another use case of GraalVM and got it in explained in a very elegant way, but the bonus part of using docker to compile it just blown my mind, how I didn't think about it before? Thanks Szymon!
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thanks for your kind words, Sergio! I'm happy to hear you find the bonus docker part useful :) Good luck with your GraalVM experiments, and have a good day! 👍
@tunedmystic1
@tunedmystic1 4 жыл бұрын
omg I love your background music
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thanks, Sandeep! I have the same feelings about it :) Have a good day!
@KieCodes
@KieCodes 4 жыл бұрын
Thank you for this well-produced video.
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thank you so much for the kind words and for watching it live with me today, Daniel! Have a good day, and see you soon either on here or on your KZbin channel! :D
@sbglasius
@sbglasius 3 жыл бұрын
Awesome video. This makes me want to skip /bin/bash entirely and do all my scripting in Groovy :-) I hope to see more videos from you in the future! Keep up the gr8 work!
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Thank you so much for your kind words, Soren! I wouldn't reinvent the wheel, but having a chance to run our lovely Groovy scripts just as they were written in the natively-compiled language is such a huge boost. I hope you will find a good usage of it :) Take care, and have a good day!
@Daveooooooooooo0
@Daveooooooooooo0 2 ай бұрын
❤ wow so much I didn't know. You rock❤
@jarosawkonojacki532
@jarosawkonojacki532 3 жыл бұрын
Great video, thank you for your work.
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Thank you so much for your kind words, Jarosław! Take care and have a good day!
@kashyapkiran1729
@kashyapkiran1729 4 жыл бұрын
excellent video :)
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thank you very much! :)
@TheOldCow
@TheOldCow 2 жыл бұрын
Great video. We use groovy a lot for our build scripts, but we compile it to a .jar file using gradle. Is there an easy way to use gradle to automate the compilation to a native image? Maybe an idea for another video?
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Hi Craig! Thanks for the kind words! You may want to take a look at this Gradle plugin - graalvm.github.io/native-build-tools/0.9.4/gradle-plugin.html And thanks for the suggestion - Gradle + GraalVM would be a nice topic to cover in the video! :) Take care, and have a good day!
@dragandzajic
@dragandzajic 4 жыл бұрын
Excellent video! I was looking for something like this for some time now. I am playing and experimenting with jlink + package to create custom runtime and than wrapping it (as .sh or exe) so it looks like native, and all that for purpose of having JavaFX application looking like native app. Does this look like interesting idea for you to make video? Ant, thanks again for all of your videos!!!
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thanks for your kind words, Darko! 👍 You may want to check Gluon (gluonhq.com) - I heard about it some time ago, but never tried it myself. It seems like it comes with a Maven plugin that helps you compiling JavaFX app to the standalone native binary using GraalVM. I spend almost all-time on the server side, and it's been more than 10 years since I developed a desktop app for the last time. But who knows - maybe GraalVM and JavaFX will be a good excuse to give it a shot again somewhere in the future :) Will see, I wrote down this idea, thanks! Have a good day!
@mrozi5838
@mrozi5838 4 жыл бұрын
Great video. Will this also work for other JVM-based languages ​​such as Kotlin, Scala etc?
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Yes, absolutely! The two statically typed languages are even in a better spot. Kotlin, for instance, compiles native-image a bit faster and produces smaller size (because of the much smaller size of the library itself.) The workflow for compiling Kotlin or Scala is the same as the one I've shown for Groovy. You can give it a try if you like it :) Good luck, have a good day!
@ErixSamson
@ErixSamson Жыл бұрын
Thanks, very useful as I'm starting with Groovy and Graal. On a side note, maybe the background music level could be lower, it disturbs a little bit...
@szymonstepniak
@szymonstepniak Жыл бұрын
Thank you for your kind words! Take care, and have a good day!
@dadocomm2867
@dadocomm2867 4 жыл бұрын
Great video! Can you explain why exactly is critical to use JDK 11? What are problems with JDK 8?
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thanks for your kind words, Dado! The problem with GraalVM JDK 8 is that this version (at least at the time of recording this video) had unresolved issue with e.g. coercing Groovy closure into Java functional interface. It means that you can't use idiomatic Groovy syntax in some use cases, like passing a closure to a method that expects a different type that can be easily coerced when you do it in a normal Groovy runtime. This problem does not exist in the GraalVM JDK 11 variant. You can look at this Github issue for more details - github.com/oracle/graal/issues/1306 Hope it answers your question. Have a good day!
@sanjayprawat
@sanjayprawat 4 жыл бұрын
Nice video 👍 Today I successfully compiled a Spring WebFlux Websockets Redis app into GraalVM native image, I have been trying this since months 😅 Question: Say after you compiled into native image and you get an error saying XYX class couldn't be instantiated (probably bcoz the agent couldn't create reflect.json for it) how can se manually add the configuration for that class? In other words, say I know I'm using Reflection in class A for class B, how do I configure both these so graal native image compiler understands what to do?
@sanjayprawat
@sanjayprawat 4 жыл бұрын
Btw I was getting error is webjars handlers in Spring WebFlux, so I removed it and added js file link directly in html using cdn 😜
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thanks for the kind words, Sanjay! You can always add the B class with "allPublicMethods": true to the reflect-config.json file. I wouldn't assume that native-image-agent couldn't track this reflection - it records all reflection usages, so it would be unusual if it didn't track just a single class. Make sure that you use the same classpath setting for running application with native-image-agent, and with the native-image compiler. Maybe you missed this class in the classpath that was set for the native-image compiler. Hope it helps. Have a good day!
@sanjayprawat
@sanjayprawat 4 жыл бұрын
@@szymonstepniak My guess is something wrong with Spring WebHandler... Coz I remember running the agent with correct classpath and I even ran the application, played with the app, moving to all possible places while the agent was On. I fixed the problem by removing the webjars itseltf, but I'll remember your trick next time in case I get this type of error again. 👍
@MotoBoyarin
@MotoBoyarin 4 жыл бұрын
thank you for great video! I have a question: can I use Groovy JsonBuilder or JsonSlurper with GraalVM?
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thanks for the kind words, Anton! It's always good to hear feedback from you :) Regarding your question - yes, you can, but not out-of-the-box. JsonBuilder requires dynamic compilation, so in this case you need to mix both compilation types, where dynamic compilation is limited to only JsonBuilder part. (The smaller dynamic scope the better for the AOT compiler.) I took JsonBuilder example from the Groovy docs and I put it into following script - gist.github.com/wololock/c9cdb28625b594c5cd19ac069a20f9c3 I also had to add "groovy-json-3.0.5.jar" to the existing classpath, and then I was able to compile native image and run it successfully. So as you can see, you can still use some dynamic features in the ahead-of-time compilation, but it requires some work to make it work. I hope it helps :) Have a good day!
@RubenKelevra
@RubenKelevra 4 жыл бұрын
Tried to do this with JOSM a while ago and failed miserable. This application could probably benefit a lot from a native image. Maybe you could take a look at it, if it's even possible to compile it natively? 🤔
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Hi Ruben! I've seen somewhere on Twitter people sharing successful stories about compiling Java GUI applications to the native-image. I bet there are some examples using JavaFX (and similar) that might be helpful to understand how to do the same with JOSM. At minimum, you can run the .jar file on GraalVM OpenJDK 11 with the native-image-agent to get those configuration files created for you. Then you could try to compile it to the native-image using those files (and providing all other parameter that the regular JOSM java program takes.) It doesn't guarantee the success, but if you run into some compatibility issue, you can always create GitHub issue in oracle/graal repository - GraalVM maintainers are very eager to help people. I hope it helps. Good luck and have a good day!
@RubenKelevra
@RubenKelevra 4 жыл бұрын
@@szymonstepniak thanks, I will give it another spin!
@kashyapkiran1729
@kashyapkiran1729 4 жыл бұрын
Hi Szymon , I have used graalvm native image in AWS lambda for Micronaut application. Lambda has cold start issue and java start up time even make it worse on top of that. Native image reduce the startup from 6 sec to 500 ms . But AWS java sdk 2 does not work with graalvm . I would like to see some application with AWS services.
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thanks for the insightful comment and bringing this up, Kashyap! I will be doing some Micronaut + AWS videos soon, I will take your comment into account and see if any solution to the problems you mentioned exists. Happy Friday, and talk soon!
@y.m.o6171
@y.m.o6171 4 жыл бұрын
Nice video and content. i am wondering if there is a more accurate way to calculate the time here ?
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thank you for your kind words! Regarding your question - in case of this specific application (simple HTTP server), I couldn't use the "time" command like: $ time ./gttp because the process was keep running after the server was started. Just for the sake of measuring the bootstrap time, I could add a switch to kill the server right after it was started, so the "time" command could be used. However, the goals was not to measure it very precisely, but rather show the order of magnitude. And for that purpose, the "shutdown" command works just fine. Thanks for the interesting comment, and don't hesitate to ask more questions. Have a good day!
@bhawani2k13
@bhawani2k13 4 жыл бұрын
Missed the premiere :(
@szymonstepniak
@szymonstepniak 4 жыл бұрын
I missed you there, Bhawani :( We will do better next time! :D
@jonestako4721
@jonestako4721 4 жыл бұрын
Thanks
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thank you, Jones! :)
Micronaut, GraalVM & Picocli - Build Native Java Command-Line Apps!
36:54
10 Things You Can Do With Groovy Closures!
26:08
Szymon Stepniak
Рет қаралды 19 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 28 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 17 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 4,3 МЛН
Groovy DSL scripts in 20 minutes for beginners
23:02
Szymon Stepniak
Рет қаралды 37 М.
Beginner's Guide to the Bash Terminal
1:14:37
Joe Collins (EzeeLinux)
Рет қаралды 2,3 МЛН
Jenkins Pipeline For Multiple Java Versions Using Matrix Feature
19:43
C++ vs Rust: which is faster?
21:15
fasterthanlime
Рет қаралды 407 М.
IntelliJ IDEA. Writing Tests with Spock
36:24
IntelliJ IDEA, a JetBrains IDE
Рет қаралды 53 М.
So You Think You Know Git - FOSDEM 2024
47:00
GitButler
Рет қаралды 1,3 МЛН
Gradle tutorial for complete beginners
24:48
Tom Gregory Tech
Рет қаралды 235 М.
Introduction to Groovy and Gradle
34:37
Daniel Lew
Рет қаралды 34 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 28 МЛН