JavaFest. Вадим Казулькин. Projects Valhalla, Loom and GraalVM

F
FestGroupFestGroup
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
NEW PROFESSIONAL
JAVA EVENT
MARCH 21ST, 2020
KYIV, UKRAINE
Vadym Kazulkin
Projects Valhalla, Loom and GraalVM
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Contact
Vadym Kazulkin, ip.labs GmbH
v.kazulkin@gmail.com
https://www.linkedin.com/in/vadymkazulkin/
@VKazulkin
Co-Org Java User Group Bonn and Serverless Bonn Meetup
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
ip.labs GmbH
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Agenda
• Project Valhalla (Inline Types)
• Project Loom (Lightweight Threads and Continuations)
• GraalVM
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Inline Types
Source: http://openjdk.java.net/projects/valhalla/
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Inline types = Value types
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Goal:
• Reboot the layout of data in memory
Source: Brian Goetz, Oracle „Evolving the Java Language” https://www.youtube.com/watch?v=A-mxj2vhVAA
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Motivation:
• Hardware has changed
• Multi-core
• The cost of cache misses has increased
Source: Brian Goetz, Oracle „Evolving the Java Language” https://www.youtube.com/watch?v=A-mxj2vhVAA
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Hardware Memory Model
Source: https://www.enterpriseai.news/2014/06/30/shared-memory-clusters-101/
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Motivation
Source: „Latency Numbers Every Programmer Should Know”
https://people.eecs.berkeley.edu/~rcs/research/interactive_latency.html
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Motivation
Source: „Latency Numbers Every Programmer Should Know”
https://people.eecs.berkeley.edu/~rcs/research/interactive_latency.html
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Storing objects in the Java Heap has its price, because storing
object’s metadata consumes additional memory for :
• flags facilitating synchronization/locking
• Identity and polymorphismus
• garbage collection
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Inline Types
Inline Type is an immutable type that is distinguishable only
by the state of its properties
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Inline Types
Immutable: an instance of an inline-type can’t change, once it’s been
created
Identity-less: inline-types of the same type with the same contents are
indistinguishable from each other
Flattenable: JVMs are allowed to flatten an inline-type inside of its
container
Source: Tobi Ajila “Welcome to LWorld: The current state of value types in Java “
https://www.youtube.com/watch?v=Xf22I16jVyE&list=LLYgjRSI2oCzI9eooyFrWR7A&index=11
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Source: „What Is Project Valhalla?” https://dzone.com/articles/what-is-project-valhalla
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Benefits:
• Reduced memory usage
• Reduced indirection
• Increased locality
Codes like a class, works like a primitive (Brian
Goetz)
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Benefit: Reduced Memory Usage
No additional memory to store object metadata, such as flags
facilitating synchronization, identity, polymorphismus and
garbage collection
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Benefit: Reduced indirection
• Since objects are stored as reference types in Java, each time
an object is accessed it must first be dereferenced, causing
additional instructions to be executed
• The flattened data associated with inline types are immediately
present in the location in which they are needed and therefore,
require no dereferencing
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Benefit: Increased locality
• Flattened value objects remove indirection which increases the
likelihood that values are adjacently stored in memory–
especially for arrays or other contiguous memory structures
such as classes (i.e. if a class contains inline type fields)
• Consequently increases the chance of cache hits, because of
hardware prefetch of the cache lines
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Inline Types
inline class Point {long x, y ;}
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Inline Types
Can
• have method and field
• implement interfaces
• use encapsulation
• be generic
Can’t
• be mutated
• be sub-classed
• be cloned
• be Enums
Source: Tobi Ajila “Welcome to LWorld: The current state of value types in Java “
https://www.youtube.com/watch?v=Xf22I16jVyE&list=LLYgjRSI2oCzI9eooyFrWR7A&index=11
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Inline Types Hierarchy
Source: Tobi Ajila “Welcome to LWorld: The current state of value types in Java “
https://www.youtube.com/watch?v=Xf22I16jVyE&list=LLYgjRSI2oCzI9eooyFrWR7A&index=11
Object
Point?
Point
Nullable Inline Type (Point or null)
Inline Type
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Inline Types Hierarchy
Source: Tobi Ajila “Welcome to LWorld: The current state of value types in Java “
https://www.youtube.com/watch?v=Xf22I16jVyE&list=LLYgjRSI2oCzI9eooyFrWR7A&index=11
Object
Point?
Point
Nullable Inline Type (Point or null)
Inline Type
Object[]
Point?[]
Point[]
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Current Status:
• Released public prototype LW2
• Can declare and use inline types (inline classes)
• No support for generics yet List<Point> // compilation error
• No support for specialized generics (Point<T>)
• No Support for migration of existing classes (like Optional)
• Memory Layout optimizations implemented
• Compiler/Virtual Machine optimizations implemented
• A lot of challenges to solve (read the article
https://www.infoq.com/news/2019/07/valhalla-openjdk-lw2-released/)
Source: Brian Goetz, Oracle „Valhalla Update” https://www.youtube.com/watch?v=1H4vmT-Va4o
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
Open Questions:
• Migration of existing classes (Option, LocaDateTime) to inline classes
• Nullity
• Equality
• GraalVM Support
• How Java type system should look like
Source: Brian Goetz, Oracle „Valhalla Update” https://www.youtube.com/watch?v=1H4vmT-Va4o
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Valhalla
How Java type system should look like ?
Source: Tobi Ajila “Welcome to LWorld: The current state of value types in Java “
https://www.youtube.com/watch?v=Xf22I16jVyE&list=LLYgjRSI2oCzI9eooyFrWR7A&index=11
Object
ValObject
Inline
Types
RefObject
References
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Lightweight Thread and Continuations
Source: http://openjdk.java.net/projects/loom
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Lightweight Threads = Fibers
Lightweight Threads = Virtual Threads in the
newest prototype?
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Motivation:
Developers currently have 2 choices to write concurrent code:
• use blocking/synchronous API, which is simple, but less scalable (number of
threads, that OS supports is far less that open and concurrent connections
required)
• asynchronous API (Spring Project Reactor, RXJava 2), which is scalable, but
complex, harder to debug and profile and limited (no asynchronous JDBC
standard in this area)
Sources: Alan Bateman, Oracle „Project Loom: Fibers and Continuations for Java” https://www.youtube.com/watch?v=vbGbXUjlRyQ
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Goal:
To write simple and scalable code
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Lightweight Thread
Lightweight thread scheduled not by the OS, but by the Java Runtime
with low memory footprint and low task-switching cost
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Continuation
Continuation is a program object, representing a computation that
may be suspended and resumed
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Continuation
package java.lang;
public class Continuation {
public Continuation (ContinuationScope scope, Runnable target)
public final void run()
public static void yield (ContinuationScope scope)
public boolean isDone()
}
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Continuations
example () {
var scope = new ContinuationScope(„Example_Scope“);
var continuation = new Continuation (scope, () -> {
out.print(„1“);
Continuation.yield(scope);
out.print(„2“);
Continuation.yield(scope);
out.print(„3“);
Continuation.yield(scope);
});
while (! continuation.isDone()) {
out.print(„ run.. “);
continuation.run();
}
}
Output: run.. 1 run.. 2 run.. 3
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Lightweight Thread & Continuations
Thread
=
Continuation + Schedular
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Schedular
Schedular executes the task on a pool of carrier threads
• java.util.concurrent.Executor API exposes the Schedular
• Default schedular is a ForJoinPool
Source: Alan Bateman, Oracle „Project Loom Update” https://www.youtube.com/watch?v=NV46KFV1m-4
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Lightweight Thread Implementation
• Currently Thread and Lightweight Thread don’t have a common
supertype
• Thread.currentThread() in context of Lightweight Thread
• Creates adaptor (Shadow Thread)
• Adaptor emulates legacy Thread API (except deprecated methods like stop,
suspend and resume)
• Thread Local becomes Lightweight Thread Local
Source: Alan Bateman, Oracle „Project Loom Update” https://www.youtube.com/watch?v=NV46KFV1m-4
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Structured Concurrency
Basic idea: Everytime that the control splits into multiple concurrent paths, we
want to guarantee that they join up again
try (var scope= ThreadScope. open()) {
scope.schedule(task1);
scope.schedule(task2);
} //blocks until task1 and task2 terminate
Sources: Nathanial J. Smith „Notes on structured concurrency, or: Go statement considered harmful”
https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/
Roman Elizarov: “Structured concurrency with Coroutines in Kotlin” https://medium.com/@elizarov/structured-concurrency-722d765aa952
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Structured Concurrency
Cancelation:
• Each Lightweight Thread has cancel status which can only be set once, which sets
the interrupt status and unparks the Lightweight Thread
• The task can poll canceled status
try (var scope= ThreadScope. open(PROPAGATE_CANCEL)) {
scope.schedule(task1);
scope.schedule(task2);
} //canceling the lightweight thread executing this code will task1 and task2
Source: Alan Bateman, Oracle „Project Loom Update” https://www.youtube.com/watch?v=NV46KFV1m-4
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Lightweight Thread
Current Status:
• Lightweight Thread currently supports:
• scheduling
• parking/unparking
• waiting for a Lightweight Thread to terminate
• Lightweight Thread -friendly APIs
• java.util.concurrent Locks
• java.net.Socket/ServerSocket (since JDK 13)
• java.nio.channels.SocketChannel and Pipes (since JDK 11)
• Thread.sleep
• JSSE implementation of TLS
• AccessControl.doPrivileged (since JDK 12)
Source: Ron Pressler, Project Loom: Helping Write Concurrent Applications on the Java Platform
https://www.youtube.com/watch?v=lIq-x_iI-kc
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Current Status:
• Implemented initial prototype with Continuation and Lightweight
Thread support
• Current prototype of Continuations and Lightweight Thread can run
existing code
• Debugger Support
Current focus on:
• Performance improvement
• Stable Lightweight Thread API
• Java Flight Recorder support
Source: Alan Bateman, Oracle „Project Loom Update” https://www.youtube.com/watch?v=NV46KFV1m-4
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Limitations:
• Can‘t yield with native frames
Further Work:
• java.net.InetAddress
• Console I/O
• File I/O
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Loom
Open Questions:
• Should the existing Thread API be completely re-examined?
• Can all existing code be run on top of Lightweight Threads?
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Polyglot GraalVM
Source: http://openjdk.java.net/projects/metropolis
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Project Metropolis
Goals:
• Low footprint ahead-of-time mode for JVM-based languages
• High performance for all languages
• Convenient language interoperability and polyglot tooling
Source: „Everything you need to know about GraalVM by Oleg Šelajev & Thomas Wuerthinger”
https://www.youtube.com/watch?v=ANN9rxYo5Hg
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
JEP 317
Experimental Java-Based JIT Compiler
Graal, a Java-based JIT compiler on the Linux/x64 platform, is the basis of the
experimental Ahead-of-Time (AOT) compiler introduced in JDK 9.
To Enable:
-XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
GraalVM
Architecture
Sources: Practical Partial Evaluation for High-Performance Dynamic Language Runtimes http://chrisseaton.com/rubytruffle/pldi17-
truffle/pldi17-truffle.pdf
„The LLVM Compiler Infrastructure“ https://llvm.org/
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
GraalVM
Benchmarks
Sources: Renaissance Suite https://renaissance.dev/
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
GraalVM
libgraal Library
Sources: „libgraal: GraalVM compiler as a precompiled GraalVM native image“
https://medium.com/graalvm/libgraal-graalvm-compiler-as-a-precompiled-graalvm-native-image-26e354bee5c
libgraal jargraal
• libgraal is a shared library, produced by GraalVM Native Image with a pre-compiled
version of the GraalVM compiler
• In Java applications on GraalVM libgraal used as the top tier Just-In-Time compiler
• libgraal improves startup
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
GraalVM
Architecture
Sources: Practical Partial Evaluation for High-Performance Dynamic Language Runtimes http://chrisseaton.com/rubytruffle/pldi17-
truffle/pldi17-truffle.pdf
„The LLVM Compiler Infrastructure“ https://llvm.org/
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
SubstrateVM
Source: Oleg Šelajev, Thomas Wuerthinger, Oracle: “Deep dive into using GraalVM for Java and JavaScript”
https://www.youtube.com/watch?v=a-XEZobXspo
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
GraalVM and SubstrateVM
Source: Oleg Selajev, Oracle : “Run Code in Any Language Anywhere with GraalVM” https://www.youtube.com/watch?v=JoDOo4FyYMU
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
GraalVM on SubstrateVM
A game changer for Java & Serverless?
Cold Start :
Source: Ajay Nair „Become a Serverless Black Belt” https://www.youtube.com/watch?v=oQFORsso2go
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
AWS Lambda cold start time
by supported language
Source: Yan Cui: https://read.acloud.guru/does-coding-language-memory-or-package-size-affect-cold-starts-of-aws-lambda-a15e26d12c76
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
GraalVM on SubstrateVM
A game changer for Java & Serverless?
Java Function compiled into a native executable using GraalVM on
SubstrateVM reduces
• “cold start” times
• memory footprint
by order of magnitude compared to running on JVM.
And both memory and execution time are cost dimension, when using
Serverless in the cloud
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
GraalVM on SubstrateVM
A game changer for Java & Serverless?
Current challenges native executable using GraalVM :
• Most Cloud Providers (AWS) doesn’t provide GraalVM as Java Runtime
out of the box, only Open JDK (e.g. AWS provides Corretto)
• Some Cloud Providers (AWS) provide Custom Runtime Option
• Docker Image with GraalVM instead of Open JDK
• Frameworks like Micronaut and Quarkus which provide tooling for generating
Custom Runtime for cloud providers
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
GraalVM Complitation Modes
Source: „Everything you need to know about GraalVM by Oleg Šelajev & Thomas Wuerthinger”
https://www.youtube.com/watch?v=ANN9rxYo5Hg
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
AOT vs JIT
Source: „Everything you need to know about GraalVM by Oleg Šelajev & Thomas Wuerthinger”
https://www.youtube.com/watch?v=ANN9rxYo5Hg
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
Support of GraalVM native images in Frameworks
• Spring Framework: working toward GraalVM native image support without
requiring additional configuration or workaround is one of the themes of
upcoming Spring Framework 5.3
• Spring Boot: Ongoing work on experimental Spring Graal Native project. Probably
ready for the 2.4 release
• Quarkus: a Kubernetes Native Java framework developed by Red Hat tailored for
GraalVM and HotSpot, crafted from best-of-breed Java libraries and standards.
• Micronaut: a modern, JVM-based, full-stack framework for building modular,
easily testable microservice and serverless applications.
Source: „GraalVM native image support“ https://github.com/spring-projects/spring-framework/wiki/GraalVM-native-image-support
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
GraalVM Current State
Source: „Everything you need to know about GraalVM by Oleg Šelajev & Thomas Wuerthinger”
https://www.youtube.com/watch?v=ANN9rxYo5Hg
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
is still an interesting and great
programming language
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
NEW PROFESSIONAL JAVA EVENT KYIV, 2020
www.iplabs.de
Thank You!
1 of 64

Recommended

JavaFX Versus HTML5 - JavaOne 2014 by
JavaFX Versus HTML5 - JavaOne 2014JavaFX Versus HTML5 - JavaOne 2014
JavaFX Versus HTML5 - JavaOne 2014Ryan Cuprak
14.9K views100 slides
JavaFX and HTML5 - Like Curds and Rice by
JavaFX and HTML5 - Like Curds and RiceJavaFX and HTML5 - Like Curds and Rice
JavaFX and HTML5 - Like Curds and RiceStephen Chin
8.2K views26 slides
[English version] JavaFX and Web Integration by
[English version] JavaFX and Web Integration[English version] JavaFX and Web Integration
[English version] JavaFX and Web IntegrationKazuchika Sekiya
3.3K views40 slides
Moving to the Client - JavaFX and HTML5 by
Moving to the Client - JavaFX and HTML5Moving to the Client - JavaFX and HTML5
Moving to the Client - JavaFX and HTML5Stephen Chin
2.8K views30 slides
blueMarine photographic workflow with Java by
blueMarine photographic workflow with JavablueMarine photographic workflow with Java
blueMarine photographic workflow with JavaFabrizio Giudici
639 views61 slides
Moving To The Client - JavaFX and HTML5 by
Moving To The Client - JavaFX and HTML5Moving To The Client - JavaFX and HTML5
Moving To The Client - JavaFX and HTML5Stephen Chin
1.9K views24 slides

More Related Content

What's hot

Moving to the Client - JavaFX and HTML5 by
Moving to the Client - JavaFX and HTML5Moving to the Client - JavaFX and HTML5
Moving to the Client - JavaFX and HTML5Stephen Chin
9.1K views25 slides
GR8Conf 2011: Adopting Grails by
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf
660 views23 slides
Developing modular Java applications by
Developing modular Java applicationsDeveloping modular Java applications
Developing modular Java applicationsJulien Dubois
11.9K views40 slides
Migrating to Java 9 Modules by
Migrating to Java 9 ModulesMigrating to Java 9 Modules
Migrating to Java 9 ModulesSander Mak (@Sander_Mak)
5.5K views60 slides
Moving to the Client - JavaFX and HTML5 (PowerPoint Version) by
Moving to the Client - JavaFX and HTML5 (PowerPoint Version)Moving to the Client - JavaFX and HTML5 (PowerPoint Version)
Moving to the Client - JavaFX and HTML5 (PowerPoint Version)Stephen Chin
2.4K views30 slides
Why jakarta ee matters (ConFoo 2021) by
Why jakarta ee matters (ConFoo 2021)Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)Ryan Cuprak
221 views62 slides

What's hot(20)

Moving to the Client - JavaFX and HTML5 by Stephen Chin
Moving to the Client - JavaFX and HTML5Moving to the Client - JavaFX and HTML5
Moving to the Client - JavaFX and HTML5
Stephen Chin9.1K views
GR8Conf 2011: Adopting Grails by GR8Conf
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
GR8Conf660 views
Developing modular Java applications by Julien Dubois
Developing modular Java applicationsDeveloping modular Java applications
Developing modular Java applications
Julien Dubois11.9K views
Moving to the Client - JavaFX and HTML5 (PowerPoint Version) by Stephen Chin
Moving to the Client - JavaFX and HTML5 (PowerPoint Version)Moving to the Client - JavaFX and HTML5 (PowerPoint Version)
Moving to the Client - JavaFX and HTML5 (PowerPoint Version)
Stephen Chin2.4K views
Why jakarta ee matters (ConFoo 2021) by Ryan Cuprak
Why jakarta ee matters (ConFoo 2021)Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)
Ryan Cuprak221 views
Modular Java applications with OSGi on Apache Karaf by Ioan Eugen Stan
Modular Java applications with OSGi on Apache KarafModular Java applications with OSGi on Apache Karaf
Modular Java applications with OSGi on Apache Karaf
Ioan Eugen Stan1.9K views
GWT – The Java Advantage by Yoav Aharoni
GWT – The Java AdvantageGWT – The Java Advantage
GWT – The Java Advantage
Yoav Aharoni1.2K views
Project Jigsaw in JDK 9: Modularity Comes To Java by C4Media
Project Jigsaw in JDK 9: Modularity Comes To JavaProject Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To Java
C4Media38.4K views
Polygot Java EE on the GraalVM by Ryan Cuprak
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
Ryan Cuprak1K views
Java APIs- The missing manual (concurrency) by Hendrik Ebbers
Java APIs- The missing manual (concurrency)Java APIs- The missing manual (concurrency)
Java APIs- The missing manual (concurrency)
Hendrik Ebbers219 views
Nadeus Education Services session on Google Apps and Google App Engine by Nadeus Education Services
Nadeus Education Services session on Google Apps and Google App EngineNadeus Education Services session on Google Apps and Google App Engine
Nadeus Education Services session on Google Apps and Google App Engine
Modularization With Project Jigsaw in JDK 9 by Simon Ritter
Modularization With Project Jigsaw in JDK 9Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9
Simon Ritter6.1K views
JavaFX 2 Using the Spring Framework by Stephen Chin
JavaFX 2 Using the Spring FrameworkJavaFX 2 Using the Spring Framework
JavaFX 2 Using the Spring Framework
Stephen Chin47.7K views

Similar to JavaFest. Вадим Казулькин. Projects Valhalla, Loom and GraalVM

Projects Valhalla and Loom at IT Tage 2021 by
Projects Valhalla and Loom at IT Tage 2021Projects Valhalla and Loom at IT Tage 2021
Projects Valhalla and Loom at IT Tage 2021Vadym Kazulkin
378 views53 slides
Highlights from Java 10-13 and Future of Java at JCON 2019 by Alukhanov and K... by
Highlights from Java 10-13 and Future of Java at JCON 2019 by Alukhanov and K...Highlights from Java 10-13 and Future of Java at JCON 2019 by Alukhanov and K...
Highlights from Java 10-13 and Future of Java at JCON 2019 by Alukhanov and K...Vadym Kazulkin
351 views62 slides
Projects Valhalla, Loom and GraalVM at JUG Mainz by
Projects Valhalla, Loom and GraalVM at JUG MainzProjects Valhalla, Loom and GraalVM at JUG Mainz
Projects Valhalla, Loom and GraalVM at JUG MainzVadym Kazulkin
57 views78 slides
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad... by
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...Vadym Kazulkin
410 views66 slides
Projects Valhalla, Loom and GraalVM at JCon 2020 by
Projects Valhalla, Loom and GraalVM at JCon 2020Projects Valhalla, Loom and GraalVM at JCon 2020
Projects Valhalla, Loom and GraalVM at JCon 2020Vadym Kazulkin
70 views67 slides
Lecture 8 - Qooxdoo - Rap Course At The University Of Szeged by
Lecture 8 - Qooxdoo - Rap Course At The University Of SzegedLecture 8 - Qooxdoo - Rap Course At The University Of Szeged
Lecture 8 - Qooxdoo - Rap Course At The University Of SzegedFabian Jakobs
1.9K views51 slides

Similar to JavaFest. Вадим Казулькин. Projects Valhalla, Loom and GraalVM(20)

Projects Valhalla and Loom at IT Tage 2021 by Vadym Kazulkin
Projects Valhalla and Loom at IT Tage 2021Projects Valhalla and Loom at IT Tage 2021
Projects Valhalla and Loom at IT Tage 2021
Vadym Kazulkin378 views
Highlights from Java 10-13 and Future of Java at JCON 2019 by Alukhanov and K... by Vadym Kazulkin
Highlights from Java 10-13 and Future of Java at JCON 2019 by Alukhanov and K...Highlights from Java 10-13 and Future of Java at JCON 2019 by Alukhanov and K...
Highlights from Java 10-13 and Future of Java at JCON 2019 by Alukhanov and K...
Vadym Kazulkin351 views
Projects Valhalla, Loom and GraalVM at JUG Mainz by Vadym Kazulkin
Projects Valhalla, Loom and GraalVM at JUG MainzProjects Valhalla, Loom and GraalVM at JUG Mainz
Projects Valhalla, Loom and GraalVM at JUG Mainz
Vadym Kazulkin57 views
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad... by Vadym Kazulkin
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Vadym Kazulkin410 views
Projects Valhalla, Loom and GraalVM at JCon 2020 by Vadym Kazulkin
Projects Valhalla, Loom and GraalVM at JCon 2020Projects Valhalla, Loom and GraalVM at JCon 2020
Projects Valhalla, Loom and GraalVM at JCon 2020
Vadym Kazulkin70 views
Lecture 8 - Qooxdoo - Rap Course At The University Of Szeged by Fabian Jakobs
Lecture 8 - Qooxdoo - Rap Course At The University Of SzegedLecture 8 - Qooxdoo - Rap Course At The University Of Szeged
Lecture 8 - Qooxdoo - Rap Course At The University Of Szeged
Fabian Jakobs1.9K views
Java in a world of containers by Docker, Inc.
Java in a world of containersJava in a world of containers
Java in a world of containers
Docker, Inc.1.7K views
Java in a World of Containers - DockerCon 2018 by Arun Gupta
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018
Arun Gupta2.3K views
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor... by Vadym Kazulkin
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
Vadym Kazulkin79 views
Trends and future of java by Csaba Toth
Trends and future of javaTrends and future of java
Trends and future of java
Csaba Toth905 views
Cannibalising The Google App Engine by catherinewall
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
catherinewall3.9K views
Java Course 15: Ant, Scripting, Spring, Hibernate by Anton Keks
Java Course 15: Ant, Scripting, Spring, HibernateJava Course 15: Ant, Scripting, Spring, Hibernate
Java Course 15: Ant, Scripting, Spring, Hibernate
Anton Keks1.9K views
Jenkins advance topic by Kalkey
Jenkins advance topicJenkins advance topic
Jenkins advance topic
Kalkey70 views
Eclipse MicroProfile 과 Microservice Java framework – Helidon by Oracle Korea
Eclipse MicroProfile 과 Microservice Java framework – HelidonEclipse MicroProfile 과 Microservice Java framework – Helidon
Eclipse MicroProfile 과 Microservice Java framework – Helidon
Oracle Korea509 views
Devfest09 Cschalk Gwt by Chris Schalk
Devfest09 Cschalk GwtDevfest09 Cschalk Gwt
Devfest09 Cschalk Gwt
Chris Schalk649 views
Exploiting Deserialization Vulnerabilities in Java by CODE WHITE GmbH
Exploiting Deserialization Vulnerabilities in JavaExploiting Deserialization Vulnerabilities in Java
Exploiting Deserialization Vulnerabilities in Java
CODE WHITE GmbH34.2K views
Developing Java Web Applications by hchen1
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
hchen116.4K views
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010 by JUG Lausanne
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
JUG Lausanne1K views

More from FestGroup

JavaFest. Барух Садогурский. DevOps для разработчиков (или против них?!) by
JavaFest. Барух Садогурский. DevOps для разработчиков (или против них?!)JavaFest. Барух Садогурский. DevOps для разработчиков (или против них?!)
JavaFest. Барух Садогурский. DevOps для разработчиков (или против них?!)FestGroup
235 views113 slides
JavaFest. Виктор Полищук. Legacy: как победить в гонке by
JavaFest. Виктор Полищук. Legacy: как победить в гонкеJavaFest. Виктор Полищук. Legacy: как победить в гонке
JavaFest. Виктор Полищук. Legacy: как победить в гонкеFestGroup
199 views62 slides
JavaFest. Cedrick Lunven. Build APIS with SpringBoot - REST, GRPC, GRAPHQL wh... by
JavaFest. Cedrick Lunven. Build APIS with SpringBoot - REST, GRPC, GRAPHQL wh...JavaFest. Cedrick Lunven. Build APIS with SpringBoot - REST, GRPC, GRAPHQL wh...
JavaFest. Cedrick Lunven. Build APIS with SpringBoot - REST, GRPC, GRAPHQL wh...FestGroup
283 views55 slides
JavaFest. Philipp Krenn. Scale Elasticsearch for Your Java Applications by
JavaFest. Philipp Krenn. Scale Elasticsearch for Your Java ApplicationsJavaFest. Philipp Krenn. Scale Elasticsearch for Your Java Applications
JavaFest. Philipp Krenn. Scale Elasticsearch for Your Java ApplicationsFestGroup
175 views54 slides
JavaFest. Grzegorz Piwowarek. Hazelcast - Hitchhiker’s Guide by
JavaFest. Grzegorz Piwowarek. Hazelcast - Hitchhiker’s GuideJavaFest. Grzegorz Piwowarek. Hazelcast - Hitchhiker’s Guide
JavaFest. Grzegorz Piwowarek. Hazelcast - Hitchhiker’s GuideFestGroup
122 views61 slides
JavaFest. Денис Макогон. 6 заблуждений относительно современной Java by
JavaFest. Денис Макогон. 6 заблуждений относительно современной JavaJavaFest. Денис Макогон. 6 заблуждений относительно современной Java
JavaFest. Денис Макогон. 6 заблуждений относительно современной JavaFestGroup
176 views44 slides

More from FestGroup(10)

JavaFest. Барух Садогурский. DevOps для разработчиков (или против них?!) by FestGroup
JavaFest. Барух Садогурский. DevOps для разработчиков (или против них?!)JavaFest. Барух Садогурский. DevOps для разработчиков (или против них?!)
JavaFest. Барух Садогурский. DevOps для разработчиков (или против них?!)
FestGroup235 views
JavaFest. Виктор Полищук. Legacy: как победить в гонке by FestGroup
JavaFest. Виктор Полищук. Legacy: как победить в гонкеJavaFest. Виктор Полищук. Legacy: как победить в гонке
JavaFest. Виктор Полищук. Legacy: как победить в гонке
FestGroup199 views
JavaFest. Cedrick Lunven. Build APIS with SpringBoot - REST, GRPC, GRAPHQL wh... by FestGroup
JavaFest. Cedrick Lunven. Build APIS with SpringBoot - REST, GRPC, GRAPHQL wh...JavaFest. Cedrick Lunven. Build APIS with SpringBoot - REST, GRPC, GRAPHQL wh...
JavaFest. Cedrick Lunven. Build APIS with SpringBoot - REST, GRPC, GRAPHQL wh...
FestGroup283 views
JavaFest. Philipp Krenn. Scale Elasticsearch for Your Java Applications by FestGroup
JavaFest. Philipp Krenn. Scale Elasticsearch for Your Java ApplicationsJavaFest. Philipp Krenn. Scale Elasticsearch for Your Java Applications
JavaFest. Philipp Krenn. Scale Elasticsearch for Your Java Applications
FestGroup175 views
JavaFest. Grzegorz Piwowarek. Hazelcast - Hitchhiker’s Guide by FestGroup
JavaFest. Grzegorz Piwowarek. Hazelcast - Hitchhiker’s GuideJavaFest. Grzegorz Piwowarek. Hazelcast - Hitchhiker’s Guide
JavaFest. Grzegorz Piwowarek. Hazelcast - Hitchhiker’s Guide
FestGroup122 views
JavaFest. Денис Макогон. 6 заблуждений относительно современной Java by FestGroup
JavaFest. Денис Макогон. 6 заблуждений относительно современной JavaJavaFest. Денис Макогон. 6 заблуждений относительно современной Java
JavaFest. Денис Макогон. 6 заблуждений относительно современной Java
FestGroup176 views
JavaFest. Taras Boychuk. There is always a choice. Spring Data JDBC vs. Hiber... by FestGroup
JavaFest. Taras Boychuk. There is always a choice. Spring Data JDBC vs. Hiber...JavaFest. Taras Boychuk. There is always a choice. Spring Data JDBC vs. Hiber...
JavaFest. Taras Boychuk. There is always a choice. Spring Data JDBC vs. Hiber...
FestGroup183 views
JavaFest. Антон Лемешко. Model-Driven Development in the Open Java Universe by FestGroup
JavaFest. Антон Лемешко. Model-Driven Development in the Open Java UniverseJavaFest. Антон Лемешко. Model-Driven Development in the Open Java Universe
JavaFest. Антон Лемешко. Model-Driven Development in the Open Java Universe
FestGroup132 views
JavaFest. Дмитрий Сергеев. Data processing with Kafka Streams and Spring Fram... by FestGroup
JavaFest. Дмитрий Сергеев. Data processing with Kafka Streams and Spring Fram...JavaFest. Дмитрий Сергеев. Data processing with Kafka Streams and Spring Fram...
JavaFest. Дмитрий Сергеев. Data processing with Kafka Streams and Spring Fram...
FestGroup225 views
JavaFest. Nanne Baars. Web application security for developers by FestGroup
JavaFest. Nanne Baars. Web application security for developersJavaFest. Nanne Baars. Web application security for developers
JavaFest. Nanne Baars. Web application security for developers
FestGroup212 views

Recently uploaded

Psychology KS4 by
Psychology KS4Psychology KS4
Psychology KS4WestHatch
84 views4 slides
Class 10 English notes 23-24.pptx by
Class 10 English notes 23-24.pptxClass 10 English notes 23-24.pptx
Class 10 English notes 23-24.pptxTARIQ KHAN
131 views53 slides
UWP OA Week Presentation (1).pptx by
UWP OA Week Presentation (1).pptxUWP OA Week Presentation (1).pptx
UWP OA Week Presentation (1).pptxJisc
88 views11 slides
Ch. 7 Political Participation and Elections.pptx by
Ch. 7 Political Participation and Elections.pptxCh. 7 Political Participation and Elections.pptx
Ch. 7 Political Participation and Elections.pptxRommel Regala
97 views11 slides
The Open Access Community Framework (OACF) 2023 (1).pptx by
The Open Access Community Framework (OACF) 2023 (1).pptxThe Open Access Community Framework (OACF) 2023 (1).pptx
The Open Access Community Framework (OACF) 2023 (1).pptxJisc
110 views7 slides
Education and Diversity.pptx by
Education and Diversity.pptxEducation and Diversity.pptx
Education and Diversity.pptxDrHafizKosar
173 views16 slides

Recently uploaded(20)

Psychology KS4 by WestHatch
Psychology KS4Psychology KS4
Psychology KS4
WestHatch84 views
Class 10 English notes 23-24.pptx by TARIQ KHAN
Class 10 English notes 23-24.pptxClass 10 English notes 23-24.pptx
Class 10 English notes 23-24.pptx
TARIQ KHAN131 views
UWP OA Week Presentation (1).pptx by Jisc
UWP OA Week Presentation (1).pptxUWP OA Week Presentation (1).pptx
UWP OA Week Presentation (1).pptx
Jisc88 views
Ch. 7 Political Participation and Elections.pptx by Rommel Regala
Ch. 7 Political Participation and Elections.pptxCh. 7 Political Participation and Elections.pptx
Ch. 7 Political Participation and Elections.pptx
Rommel Regala97 views
The Open Access Community Framework (OACF) 2023 (1).pptx by Jisc
The Open Access Community Framework (OACF) 2023 (1).pptxThe Open Access Community Framework (OACF) 2023 (1).pptx
The Open Access Community Framework (OACF) 2023 (1).pptx
Jisc110 views
Education and Diversity.pptx by DrHafizKosar
Education and Diversity.pptxEducation and Diversity.pptx
Education and Diversity.pptx
DrHafizKosar173 views
Classification of crude drugs.pptx by GayatriPatra14
Classification of crude drugs.pptxClassification of crude drugs.pptx
Classification of crude drugs.pptx
GayatriPatra1486 views
11.30.23 Poverty and Inequality in America.pptx by mary850239
11.30.23 Poverty and Inequality in America.pptx11.30.23 Poverty and Inequality in America.pptx
11.30.23 Poverty and Inequality in America.pptx
mary850239160 views
The Accursed House by Émile Gaboriau by DivyaSheta
The Accursed House  by Émile GaboriauThe Accursed House  by Émile Gaboriau
The Accursed House by Émile Gaboriau
DivyaSheta201 views
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx by ISSIP
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptxEIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx
ISSIP369 views
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively by PECB
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
PECB 585 views
Scope of Biochemistry.pptx by shoba shoba
Scope of Biochemistry.pptxScope of Biochemistry.pptx
Scope of Biochemistry.pptx
shoba shoba133 views
Create a Structure in VBNet.pptx by Breach_P
Create a Structure in VBNet.pptxCreate a Structure in VBNet.pptx
Create a Structure in VBNet.pptx
Breach_P75 views
JiscOAWeek_LAIR_slides_October2023.pptx by Jisc
JiscOAWeek_LAIR_slides_October2023.pptxJiscOAWeek_LAIR_slides_October2023.pptx
JiscOAWeek_LAIR_slides_October2023.pptx
Jisc96 views
When Sex Gets Complicated: Porn, Affairs, & Cybersex by Marlene Maheu
When Sex Gets Complicated: Porn, Affairs, & CybersexWhen Sex Gets Complicated: Porn, Affairs, & Cybersex
When Sex Gets Complicated: Porn, Affairs, & Cybersex
Marlene Maheu67 views
Are we onboard yet University of Sussex.pptx by Jisc
Are we onboard yet University of Sussex.pptxAre we onboard yet University of Sussex.pptx
Are we onboard yet University of Sussex.pptx
Jisc96 views
Psychology KS5 by WestHatch
Psychology KS5Psychology KS5
Psychology KS5
WestHatch93 views

JavaFest. Вадим Казулькин. Projects Valhalla, Loom and GraalVM

  • 1. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 NEW PROFESSIONAL JAVA EVENT MARCH 21ST, 2020 KYIV, UKRAINE Vadym Kazulkin Projects Valhalla, Loom and GraalVM
  • 2. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Contact Vadym Kazulkin, ip.labs GmbH v.kazulkin@gmail.com https://www.linkedin.com/in/vadymkazulkin/ @VKazulkin Co-Org Java User Group Bonn and Serverless Bonn Meetup
  • 3. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 ip.labs GmbH
  • 4. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Agenda • Project Valhalla (Inline Types) • Project Loom (Lightweight Threads and Continuations) • GraalVM
  • 5. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Inline Types Source: http://openjdk.java.net/projects/valhalla/
  • 6. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Inline types = Value types
  • 7. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Goal: • Reboot the layout of data in memory Source: Brian Goetz, Oracle „Evolving the Java Language” https://www.youtube.com/watch?v=A-mxj2vhVAA
  • 8. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Motivation: • Hardware has changed • Multi-core • The cost of cache misses has increased Source: Brian Goetz, Oracle „Evolving the Java Language” https://www.youtube.com/watch?v=A-mxj2vhVAA
  • 9. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Hardware Memory Model Source: https://www.enterpriseai.news/2014/06/30/shared-memory-clusters-101/
  • 10. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Motivation Source: „Latency Numbers Every Programmer Should Know” https://people.eecs.berkeley.edu/~rcs/research/interactive_latency.html
  • 11. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Motivation Source: „Latency Numbers Every Programmer Should Know” https://people.eecs.berkeley.edu/~rcs/research/interactive_latency.html
  • 12. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Storing objects in the Java Heap has its price, because storing object’s metadata consumes additional memory for : • flags facilitating synchronization/locking • Identity and polymorphismus • garbage collection
  • 13. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Inline Types Inline Type is an immutable type that is distinguishable only by the state of its properties
  • 14. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Inline Types Immutable: an instance of an inline-type can’t change, once it’s been created Identity-less: inline-types of the same type with the same contents are indistinguishable from each other Flattenable: JVMs are allowed to flatten an inline-type inside of its container Source: Tobi Ajila “Welcome to LWorld: The current state of value types in Java “ https://www.youtube.com/watch?v=Xf22I16jVyE&list=LLYgjRSI2oCzI9eooyFrWR7A&index=11
  • 15. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Source: „What Is Project Valhalla?” https://dzone.com/articles/what-is-project-valhalla
  • 16. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Benefits: • Reduced memory usage • Reduced indirection • Increased locality Codes like a class, works like a primitive (Brian Goetz)
  • 17. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Benefit: Reduced Memory Usage No additional memory to store object metadata, such as flags facilitating synchronization, identity, polymorphismus and garbage collection
  • 18. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Benefit: Reduced indirection • Since objects are stored as reference types in Java, each time an object is accessed it must first be dereferenced, causing additional instructions to be executed • The flattened data associated with inline types are immediately present in the location in which they are needed and therefore, require no dereferencing
  • 19. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Benefit: Increased locality • Flattened value objects remove indirection which increases the likelihood that values are adjacently stored in memory– especially for arrays or other contiguous memory structures such as classes (i.e. if a class contains inline type fields) • Consequently increases the chance of cache hits, because of hardware prefetch of the cache lines
  • 20. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Inline Types inline class Point {long x, y ;}
  • 21. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Inline Types Can • have method and field • implement interfaces • use encapsulation • be generic Can’t • be mutated • be sub-classed • be cloned • be Enums Source: Tobi Ajila “Welcome to LWorld: The current state of value types in Java “ https://www.youtube.com/watch?v=Xf22I16jVyE&list=LLYgjRSI2oCzI9eooyFrWR7A&index=11
  • 22. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Inline Types Hierarchy Source: Tobi Ajila “Welcome to LWorld: The current state of value types in Java “ https://www.youtube.com/watch?v=Xf22I16jVyE&list=LLYgjRSI2oCzI9eooyFrWR7A&index=11 Object Point? Point Nullable Inline Type (Point or null) Inline Type
  • 23. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Inline Types Hierarchy Source: Tobi Ajila “Welcome to LWorld: The current state of value types in Java “ https://www.youtube.com/watch?v=Xf22I16jVyE&list=LLYgjRSI2oCzI9eooyFrWR7A&index=11 Object Point? Point Nullable Inline Type (Point or null) Inline Type Object[] Point?[] Point[]
  • 24. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Current Status: • Released public prototype LW2 • Can declare and use inline types (inline classes) • No support for generics yet List<Point> // compilation error • No support for specialized generics (Point<T>) • No Support for migration of existing classes (like Optional) • Memory Layout optimizations implemented • Compiler/Virtual Machine optimizations implemented • A lot of challenges to solve (read the article https://www.infoq.com/news/2019/07/valhalla-openjdk-lw2-released/) Source: Brian Goetz, Oracle „Valhalla Update” https://www.youtube.com/watch?v=1H4vmT-Va4o
  • 25. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla Open Questions: • Migration of existing classes (Option, LocaDateTime) to inline classes • Nullity • Equality • GraalVM Support • How Java type system should look like Source: Brian Goetz, Oracle „Valhalla Update” https://www.youtube.com/watch?v=1H4vmT-Va4o
  • 26. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Valhalla How Java type system should look like ? Source: Tobi Ajila “Welcome to LWorld: The current state of value types in Java “ https://www.youtube.com/watch?v=Xf22I16jVyE&list=LLYgjRSI2oCzI9eooyFrWR7A&index=11 Object ValObject Inline Types RefObject References
  • 27. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Lightweight Thread and Continuations Source: http://openjdk.java.net/projects/loom
  • 28. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Lightweight Threads = Fibers Lightweight Threads = Virtual Threads in the newest prototype?
  • 29. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Motivation: Developers currently have 2 choices to write concurrent code: • use blocking/synchronous API, which is simple, but less scalable (number of threads, that OS supports is far less that open and concurrent connections required) • asynchronous API (Spring Project Reactor, RXJava 2), which is scalable, but complex, harder to debug and profile and limited (no asynchronous JDBC standard in this area) Sources: Alan Bateman, Oracle „Project Loom: Fibers and Continuations for Java” https://www.youtube.com/watch?v=vbGbXUjlRyQ
  • 30. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Goal: To write simple and scalable code
  • 31. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Lightweight Thread Lightweight thread scheduled not by the OS, but by the Java Runtime with low memory footprint and low task-switching cost
  • 32. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Continuation Continuation is a program object, representing a computation that may be suspended and resumed
  • 33. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Continuation package java.lang; public class Continuation { public Continuation (ContinuationScope scope, Runnable target) public final void run() public static void yield (ContinuationScope scope) public boolean isDone() }
  • 34. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Continuations example () { var scope = new ContinuationScope(„Example_Scope“); var continuation = new Continuation (scope, () -> { out.print(„1“); Continuation.yield(scope); out.print(„2“); Continuation.yield(scope); out.print(„3“); Continuation.yield(scope); }); while (! continuation.isDone()) { out.print(„ run.. “); continuation.run(); } } Output: run.. 1 run.. 2 run.. 3
  • 35. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Lightweight Thread & Continuations Thread = Continuation + Schedular
  • 36. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Schedular Schedular executes the task on a pool of carrier threads • java.util.concurrent.Executor API exposes the Schedular • Default schedular is a ForJoinPool Source: Alan Bateman, Oracle „Project Loom Update” https://www.youtube.com/watch?v=NV46KFV1m-4
  • 37. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Lightweight Thread Implementation • Currently Thread and Lightweight Thread don’t have a common supertype • Thread.currentThread() in context of Lightweight Thread • Creates adaptor (Shadow Thread) • Adaptor emulates legacy Thread API (except deprecated methods like stop, suspend and resume) • Thread Local becomes Lightweight Thread Local Source: Alan Bateman, Oracle „Project Loom Update” https://www.youtube.com/watch?v=NV46KFV1m-4
  • 38. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Structured Concurrency Basic idea: Everytime that the control splits into multiple concurrent paths, we want to guarantee that they join up again try (var scope= ThreadScope. open()) { scope.schedule(task1); scope.schedule(task2); } //blocks until task1 and task2 terminate Sources: Nathanial J. Smith „Notes on structured concurrency, or: Go statement considered harmful” https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ Roman Elizarov: “Structured concurrency with Coroutines in Kotlin” https://medium.com/@elizarov/structured-concurrency-722d765aa952
  • 39. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Structured Concurrency Cancelation: • Each Lightweight Thread has cancel status which can only be set once, which sets the interrupt status and unparks the Lightweight Thread • The task can poll canceled status try (var scope= ThreadScope. open(PROPAGATE_CANCEL)) { scope.schedule(task1); scope.schedule(task2); } //canceling the lightweight thread executing this code will task1 and task2 Source: Alan Bateman, Oracle „Project Loom Update” https://www.youtube.com/watch?v=NV46KFV1m-4
  • 40. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Lightweight Thread Current Status: • Lightweight Thread currently supports: • scheduling • parking/unparking • waiting for a Lightweight Thread to terminate • Lightweight Thread -friendly APIs • java.util.concurrent Locks • java.net.Socket/ServerSocket (since JDK 13) • java.nio.channels.SocketChannel and Pipes (since JDK 11) • Thread.sleep • JSSE implementation of TLS • AccessControl.doPrivileged (since JDK 12) Source: Ron Pressler, Project Loom: Helping Write Concurrent Applications on the Java Platform https://www.youtube.com/watch?v=lIq-x_iI-kc
  • 41. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Current Status: • Implemented initial prototype with Continuation and Lightweight Thread support • Current prototype of Continuations and Lightweight Thread can run existing code • Debugger Support Current focus on: • Performance improvement • Stable Lightweight Thread API • Java Flight Recorder support Source: Alan Bateman, Oracle „Project Loom Update” https://www.youtube.com/watch?v=NV46KFV1m-4
  • 42. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Limitations: • Can‘t yield with native frames Further Work: • java.net.InetAddress • Console I/O • File I/O
  • 43. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Loom Open Questions: • Should the existing Thread API be completely re-examined? • Can all existing code be run on top of Lightweight Threads?
  • 44. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Polyglot GraalVM Source: http://openjdk.java.net/projects/metropolis
  • 45. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Project Metropolis Goals: • Low footprint ahead-of-time mode for JVM-based languages • High performance for all languages • Convenient language interoperability and polyglot tooling Source: „Everything you need to know about GraalVM by Oleg Šelajev & Thomas Wuerthinger” https://www.youtube.com/watch?v=ANN9rxYo5Hg
  • 46. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 JEP 317 Experimental Java-Based JIT Compiler Graal, a Java-based JIT compiler on the Linux/x64 platform, is the basis of the experimental Ahead-of-Time (AOT) compiler introduced in JDK 9. To Enable: -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler
  • 47. NEW PROFESSIONAL JAVA EVENT KYIV, 2020
  • 48. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 GraalVM Architecture Sources: Practical Partial Evaluation for High-Performance Dynamic Language Runtimes http://chrisseaton.com/rubytruffle/pldi17- truffle/pldi17-truffle.pdf „The LLVM Compiler Infrastructure“ https://llvm.org/
  • 49. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 GraalVM Benchmarks Sources: Renaissance Suite https://renaissance.dev/
  • 50. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 GraalVM libgraal Library Sources: „libgraal: GraalVM compiler as a precompiled GraalVM native image“ https://medium.com/graalvm/libgraal-graalvm-compiler-as-a-precompiled-graalvm-native-image-26e354bee5c libgraal jargraal • libgraal is a shared library, produced by GraalVM Native Image with a pre-compiled version of the GraalVM compiler • In Java applications on GraalVM libgraal used as the top tier Just-In-Time compiler • libgraal improves startup
  • 51. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 GraalVM Architecture Sources: Practical Partial Evaluation for High-Performance Dynamic Language Runtimes http://chrisseaton.com/rubytruffle/pldi17- truffle/pldi17-truffle.pdf „The LLVM Compiler Infrastructure“ https://llvm.org/
  • 52. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 SubstrateVM Source: Oleg Šelajev, Thomas Wuerthinger, Oracle: “Deep dive into using GraalVM for Java and JavaScript” https://www.youtube.com/watch?v=a-XEZobXspo
  • 53. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 GraalVM and SubstrateVM Source: Oleg Selajev, Oracle : “Run Code in Any Language Anywhere with GraalVM” https://www.youtube.com/watch?v=JoDOo4FyYMU
  • 54. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 GraalVM on SubstrateVM A game changer for Java & Serverless? Cold Start : Source: Ajay Nair „Become a Serverless Black Belt” https://www.youtube.com/watch?v=oQFORsso2go
  • 55. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 AWS Lambda cold start time by supported language Source: Yan Cui: https://read.acloud.guru/does-coding-language-memory-or-package-size-affect-cold-starts-of-aws-lambda-a15e26d12c76
  • 56. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 GraalVM on SubstrateVM A game changer for Java & Serverless? Java Function compiled into a native executable using GraalVM on SubstrateVM reduces • “cold start” times • memory footprint by order of magnitude compared to running on JVM. And both memory and execution time are cost dimension, when using Serverless in the cloud
  • 57. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 GraalVM on SubstrateVM A game changer for Java & Serverless? Current challenges native executable using GraalVM : • Most Cloud Providers (AWS) doesn’t provide GraalVM as Java Runtime out of the box, only Open JDK (e.g. AWS provides Corretto) • Some Cloud Providers (AWS) provide Custom Runtime Option • Docker Image with GraalVM instead of Open JDK • Frameworks like Micronaut and Quarkus which provide tooling for generating Custom Runtime for cloud providers
  • 58. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 GraalVM Complitation Modes Source: „Everything you need to know about GraalVM by Oleg Šelajev & Thomas Wuerthinger” https://www.youtube.com/watch?v=ANN9rxYo5Hg
  • 59. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 AOT vs JIT Source: „Everything you need to know about GraalVM by Oleg Šelajev & Thomas Wuerthinger” https://www.youtube.com/watch?v=ANN9rxYo5Hg
  • 60. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 Support of GraalVM native images in Frameworks • Spring Framework: working toward GraalVM native image support without requiring additional configuration or workaround is one of the themes of upcoming Spring Framework 5.3 • Spring Boot: Ongoing work on experimental Spring Graal Native project. Probably ready for the 2.4 release • Quarkus: a Kubernetes Native Java framework developed by Red Hat tailored for GraalVM and HotSpot, crafted from best-of-breed Java libraries and standards. • Micronaut: a modern, JVM-based, full-stack framework for building modular, easily testable microservice and serverless applications. Source: „GraalVM native image support“ https://github.com/spring-projects/spring-framework/wiki/GraalVM-native-image-support
  • 61. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 GraalVM Current State Source: „Everything you need to know about GraalVM by Oleg Šelajev & Thomas Wuerthinger” https://www.youtube.com/watch?v=ANN9rxYo5Hg
  • 62. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 is still an interesting and great programming language
  • 63. NEW PROFESSIONAL JAVA EVENT KYIV, 2020
  • 64. NEW PROFESSIONAL JAVA EVENT KYIV, 2020 www.iplabs.de Thank You!