Salenda
GraalVM

with Groovy & Kotlin
Alberto De Ávila Hernández
A B O U T M E
✴ Team Lead at Salenda
✴ Groovy & Grails dev
✴ Atlassian certified
@alberto_deavila
DISCLAIMER
Goals
G O A L S
✴ Increase our JVM performance
✴ Future of JVM
✴ Programming languagues interoperability
✴ System independence
✴ Serverless
@alberto_deavila
✴ GraalVM & features
✴ Show me more code
✴ Limits using GraalVM
✴ Future
S U M M A RY
@alberto_deavila
GraalVM
@alberto_deavila
first... what is Graal?
G R A A L
@alberto_deavila
A dynamic just-in-time compiler that
improves efficiency and speed
G R A A L
@alberto_deavila
A (JIT) compiler for Java transforms
bytecode to machine code
G R A A L
@alberto_deavila Source: https://www.dynatrace.com/news/blog/new-ways-introducing-compiled-code-java-9/
G R A A LV M A R Q U I T E C T U R E
@alberto_deavila Source: https://res.infoq.com/presentations/polyglot-jvm-graal/en/slides/sl13.jpg
@alberto_deavila
then... what is GraalVM?
G R A A LV M
@alberto_deavila
Ecosystem and shared runtime offering
performance advantages to multiples
languages
G R A A LV M
@alberto_deavila Source: https://www.graalvm.org/docs/
S U P P O R T E D L A N G U A G E S
@alberto_deavila
✴ Native support: 



✴ Support with installations: Ruby, Python, R
✴ JVM languages: Groovy, Kotlin, Java...
✴ LLVM: C, C++
✴ Javascript
✴ Graal: the JIT compiler
✴ Graal Polyglot APIs: API to combine
programming languages
✴ Graal SDK: embedding Graal and configure
native images
✴ Oracle HotSpot JVM
G R A A LV M
@alberto_deavila
@alberto_deavila
License
✴ Community edition: free to use
✴ Enterprise edition: Oracle support
G R A A L L I C E N S E
@alberto_deavila
@alberto_deavila
Features
✴ Interoperate with other languages
✴ Includes consoles for JS, R...
✴ Create compiled native images
✴ Run code faster & efficiently
✴ Tools to monitor, debug, and profile code
G R A A LV M F E AT U R E S
@alberto_deavila
@alberto_deavila
Interoperability
@alberto_deavila
How can we achieve that?
@alberto_deavila
Truffle
✴ Framework
✴ Allow to create languages interpreters
✴ Based on annotations
✴ Contains common things across any
language
G R A A LV M T R U F F L E
@alberto_deavila
G R A A LV M T R U F F L E
@alberto_deavila Source: https://res.infoq.com/presentations/polyglot-jvm-graal/en/slides/sl13.jpg
G R A A LV M I N T E R O P E R A B I L I T Y
@alberto_deavila
JS RubyPython
Source: https://www.graalvm.org/docs/reference-manual/polyglot/
G R A A LV M I N T E R O P E R A B I L I T Y
@alberto_deavila
JS RubyPython
Source: https://www.graalvm.org/docs/reference-manual/polyglot/
G R A A LV M I N T E R O P E R A B I L I T Y
@alberto_deavila
JS RubyPython
Source: https://www.graalvm.org/docs/reference-manual/polyglot/
G R A A LV M I N T E R O P E R A B I L I T Y
@alberto_deavila
Node with R
Source: https://docs.google.com/presentation/d/1cBuq4rjaNTOMJOOeGvqnI2TJjWH2VBId7NtVVhXWJkY/edit#slide=id.g495524223b_0_179
✴ Use the appropiate languague for any task
✴ Use libraries from differents languagues
✴ Create apps combining languages
✴ One environment for all requirements
G R A A LV M I N T E R O P E R A B I L I T Y
@alberto_deavila
@alberto_deavila
Native images
✴ Self-contained executable
✴ Fast startup
✴ Low memory consumption
✴ Can generate binary library
✴ Useful for lambdas, containers or command
line
G R A A LV M N AT I V E I M A G E S
@alberto_deavila
G R A A LV M N AT I V E I M A G E S
@alberto_deavila
GraalVM can generate native images BUT
not yet cross platform
Source: https://github.com/oracle/graal/issues/407
@alberto_deavila
Ahead-of-time compilation
✴ Analyze statically all code
✴ Compile reachable code
✴ Generates native code
✴ Package it with SubstrateVM
G R A A LV M A O T C
@alberto_deavila
✴ Framework subset of JVM
✴ No JIT
✴ No optimization
✴ No Graal neither any related with bytecode
✴ Just runtime: GC, threads, I/O, ...
G R A A LV M S U B S T R AT E V M
@alberto_deavila
G R A A LV M N AT I V E I M A G E S
@alberto_deavila Source: https://twitter.com/cstancu/status/1103413247305166849
@alberto_deavila
Performance
✴ Depends on code optimizations
✴ Native images startup time is very fast
✴ Each languague has different perfomance
G R A A LV M P E R F O R M A N C E
@alberto_deavila
G R A A LV M P E R F O R M A N C E
@alberto_deavila Source: https://lafo.ssw.uni-linz.ac.at/pub/papers/2016_PLDI_Truffle.pdf
G R A A LV M P E R F O R M A N C E
@alberto_deavila Source: https://2017.jokerconf.com/en/2017/talks/3qdblcadmqy0me2uuieqaq/
Twitter performance using Graal
@alberto_deavila
Tools
✴ Use one debugger for all languages, like
chrome-dev-tools
✴ VisualVM to show stats about other
languages
G R A A LV M T O O L S
@alberto_deavila
G R A A LV M T O O L S
@alberto_deavila Source: https://github.com/chrisseaton/graalvm-ten-things#5-tools-that-work-across-all-languages
G R A A LV M T O O L S
@alberto_deavila Source: https://github.com/chrisseaton/graalvm-ten-things#5-tools-that-work-across-all-languages
Show me more code
@alberto_deavila
Setup
✴ Download manually
✴ Use SDKman
✴ Docker
G R A A LV M S E T U P
@alberto_deavila
@alberto_deavila
SDKMAN!
✴ Install SDKMAN!
✴ Download GraalVM
G R A A LV M S E T U P W I T H S D K M A N !
@alberto_deavila
@alberto_deavila
Factorial
Limitations
✴ Evaluate static code at compile time
✴ No dynamic code
✴ Some strange exceptions appears
✴ Take long time to generate executable
✴ Only for Mac/Linux/Win 64 bits
L I M I TAT I O N S
@alberto_deavila
@alberto_deavila
Kotlin
K O T L I N L I M I TAT I O N S
@alberto_deavila Source: https://github.com/oracle/graal/issues/366#issuecomment-383547970
✴ Almost all features work
✴ Some bugs / features to work, like:
✴ Does not support compilation of non-
reducible loops
@alberto_deavila
Groovy
✴ Sometimes requires lot of changes / rewrite
✴ No metaprogramming
✴ Closures requires manual config
✴ Grape doesn't work on standalone native
images
G R O O V Y L I M I TAT I O N S
@alberto_deavila
L I M I TAT I O N S
@alberto_deavila Source: https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md
Future
F U T U R E
@alberto_deavila
✴ More languages and tools will be available
✴ Apps with many languages working
✴ A native image compatible with all OS
✴ Better perfomance
✴ ...
M O R E I N F O
@alberto_deavila
✴ Offial Doc
✴ List of resources for Graal and related topics
✴ Videos and presentations
✴ Top 10 things to do with GraalVM
✴ Kotlin performance with GraalVM
We are hiring Groovy Devs!
Email me at:
aavila@adaptavist.com
Thank you!

Graalvm with Groovy and Kotlin - Madrid GUG 2019

  • 1.
    Salenda GraalVM
 with Groovy &Kotlin Alberto De Ávila Hernández
  • 2.
    A B OU T M E ✴ Team Lead at Salenda ✴ Groovy & Grails dev ✴ Atlassian certified @alberto_deavila
  • 3.
  • 4.
  • 5.
    G O AL S ✴ Increase our JVM performance ✴ Future of JVM ✴ Programming languagues interoperability ✴ System independence ✴ Serverless @alberto_deavila
  • 6.
    ✴ GraalVM &features ✴ Show me more code ✴ Limits using GraalVM ✴ Future S U M M A RY @alberto_deavila
  • 7.
  • 8.
  • 9.
    G R AA L @alberto_deavila A dynamic just-in-time compiler that improves efficiency and speed
  • 10.
    G R AA L @alberto_deavila A (JIT) compiler for Java transforms bytecode to machine code
  • 11.
    G R AA L @alberto_deavila Source: https://www.dynatrace.com/news/blog/new-ways-introducing-compiled-code-java-9/
  • 12.
    G R AA LV M A R Q U I T E C T U R E @alberto_deavila Source: https://res.infoq.com/presentations/polyglot-jvm-graal/en/slides/sl13.jpg
  • 13.
  • 14.
    G R AA LV M @alberto_deavila Ecosystem and shared runtime offering performance advantages to multiples languages
  • 15.
    G R AA LV M @alberto_deavila Source: https://www.graalvm.org/docs/
  • 16.
    S U PP O R T E D L A N G U A G E S @alberto_deavila ✴ Native support: 
 
 ✴ Support with installations: Ruby, Python, R ✴ JVM languages: Groovy, Kotlin, Java... ✴ LLVM: C, C++ ✴ Javascript
  • 17.
    ✴ Graal: theJIT compiler ✴ Graal Polyglot APIs: API to combine programming languages ✴ Graal SDK: embedding Graal and configure native images ✴ Oracle HotSpot JVM G R A A LV M @alberto_deavila
  • 18.
  • 19.
    ✴ Community edition:free to use ✴ Enterprise edition: Oracle support G R A A L L I C E N S E @alberto_deavila
  • 20.
  • 21.
    ✴ Interoperate withother languages ✴ Includes consoles for JS, R... ✴ Create compiled native images ✴ Run code faster & efficiently ✴ Tools to monitor, debug, and profile code G R A A LV M F E AT U R E S @alberto_deavila
  • 22.
  • 23.
  • 24.
  • 25.
    ✴ Framework ✴ Allowto create languages interpreters ✴ Based on annotations ✴ Contains common things across any language G R A A LV M T R U F F L E @alberto_deavila
  • 26.
    G R AA LV M T R U F F L E @alberto_deavila Source: https://res.infoq.com/presentations/polyglot-jvm-graal/en/slides/sl13.jpg
  • 27.
    G R AA LV M I N T E R O P E R A B I L I T Y @alberto_deavila JS RubyPython Source: https://www.graalvm.org/docs/reference-manual/polyglot/
  • 28.
    G R AA LV M I N T E R O P E R A B I L I T Y @alberto_deavila JS RubyPython Source: https://www.graalvm.org/docs/reference-manual/polyglot/
  • 29.
    G R AA LV M I N T E R O P E R A B I L I T Y @alberto_deavila JS RubyPython Source: https://www.graalvm.org/docs/reference-manual/polyglot/
  • 30.
    G R AA LV M I N T E R O P E R A B I L I T Y @alberto_deavila Node with R Source: https://docs.google.com/presentation/d/1cBuq4rjaNTOMJOOeGvqnI2TJjWH2VBId7NtVVhXWJkY/edit#slide=id.g495524223b_0_179
  • 31.
    ✴ Use theappropiate languague for any task ✴ Use libraries from differents languagues ✴ Create apps combining languages ✴ One environment for all requirements G R A A LV M I N T E R O P E R A B I L I T Y @alberto_deavila
  • 32.
  • 33.
    ✴ Self-contained executable ✴Fast startup ✴ Low memory consumption ✴ Can generate binary library ✴ Useful for lambdas, containers or command line G R A A LV M N AT I V E I M A G E S @alberto_deavila
  • 34.
    G R AA LV M N AT I V E I M A G E S @alberto_deavila GraalVM can generate native images BUT not yet cross platform Source: https://github.com/oracle/graal/issues/407
  • 35.
  • 36.
    ✴ Analyze staticallyall code ✴ Compile reachable code ✴ Generates native code ✴ Package it with SubstrateVM G R A A LV M A O T C @alberto_deavila
  • 37.
    ✴ Framework subsetof JVM ✴ No JIT ✴ No optimization ✴ No Graal neither any related with bytecode ✴ Just runtime: GC, threads, I/O, ... G R A A LV M S U B S T R AT E V M @alberto_deavila
  • 38.
    G R AA LV M N AT I V E I M A G E S @alberto_deavila Source: https://twitter.com/cstancu/status/1103413247305166849
  • 39.
  • 40.
    ✴ Depends oncode optimizations ✴ Native images startup time is very fast ✴ Each languague has different perfomance G R A A LV M P E R F O R M A N C E @alberto_deavila
  • 41.
    G R AA LV M P E R F O R M A N C E @alberto_deavila Source: https://lafo.ssw.uni-linz.ac.at/pub/papers/2016_PLDI_Truffle.pdf
  • 42.
    G R AA LV M P E R F O R M A N C E @alberto_deavila Source: https://2017.jokerconf.com/en/2017/talks/3qdblcadmqy0me2uuieqaq/ Twitter performance using Graal
  • 43.
  • 44.
    ✴ Use onedebugger for all languages, like chrome-dev-tools ✴ VisualVM to show stats about other languages G R A A LV M T O O L S @alberto_deavila
  • 45.
    G R AA LV M T O O L S @alberto_deavila Source: https://github.com/chrisseaton/graalvm-ten-things#5-tools-that-work-across-all-languages
  • 46.
    G R AA LV M T O O L S @alberto_deavila Source: https://github.com/chrisseaton/graalvm-ten-things#5-tools-that-work-across-all-languages
  • 47.
  • 48.
  • 49.
    ✴ Download manually ✴Use SDKman ✴ Docker G R A A LV M S E T U P @alberto_deavila
  • 50.
  • 51.
    ✴ Install SDKMAN! ✴Download GraalVM G R A A LV M S E T U P W I T H S D K M A N ! @alberto_deavila
  • 52.
  • 53.
  • 54.
    ✴ Evaluate staticcode at compile time ✴ No dynamic code ✴ Some strange exceptions appears ✴ Take long time to generate executable ✴ Only for Mac/Linux/Win 64 bits L I M I TAT I O N S @alberto_deavila
  • 55.
  • 56.
    K O TL I N L I M I TAT I O N S @alberto_deavila Source: https://github.com/oracle/graal/issues/366#issuecomment-383547970 ✴ Almost all features work ✴ Some bugs / features to work, like: ✴ Does not support compilation of non- reducible loops
  • 57.
  • 58.
    ✴ Sometimes requireslot of changes / rewrite ✴ No metaprogramming ✴ Closures requires manual config ✴ Grape doesn't work on standalone native images G R O O V Y L I M I TAT I O N S @alberto_deavila
  • 59.
    L I MI TAT I O N S @alberto_deavila Source: https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md
  • 60.
  • 61.
    F U TU R E @alberto_deavila ✴ More languages and tools will be available ✴ Apps with many languages working ✴ A native image compatible with all OS ✴ Better perfomance ✴ ...
  • 62.
    M O RE I N F O @alberto_deavila ✴ Offial Doc ✴ List of resources for Graal and related topics ✴ Videos and presentations ✴ Top 10 things to do with GraalVM ✴ Kotlin performance with GraalVM
  • 64.
    We are hiringGroovy Devs! Email me at: aavila@adaptavist.com
  • 65.