Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted
Cloud Native Java: GraalVM
이상과 현실
김태완(taewanme@gmail.com)
Oracle	Korea	Solution	Engineering
@taewanme,	http://taewan.kim
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
자바 다양성 시대
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 2
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 3
http://www.graalvm.org/
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Why	GraalVM?
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 4
8.	Java	code	as	a	native	library
1.	High-performance	modern	Java
2.	Low-footprint,	fast-startup	Java
3.	Combine	JavaScript,	Java,	Ruby,	and	R
4.	Run	native	languages	on	the	JVM
5.	Tools	that	work	across	all	languages
6.	Extend	a	JVM-based	application
7.	Extend	a	native	application
9.	Polyglot	in	the	database
10.	Create	your	own	languagehttps://chrisseaton.com/truffleruby/tenthings/
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Why	GraalVM?
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 5
8.	Java	code	as	a	native	library
1.	High-performance	modern	Java
2.	Low-footprint,	fast-startup	Java
3.	Combine	JavaScript,	Java,	Ruby,	and	R
4.	Run	native	languages	on	the	JVM
5.	Tools	that	work	across	all	languages
6.	Extend	a	JVM-based	application
7.	Extend	a	native	application
9.	Polyglot	in	the	database
10.	Create	your	own	language
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Why	GraalVM?
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 6
8.	Java	code	as	a	native	library
1.	High-performance	modern	Java
2.	Low-footprint,	fast-startup	Java
3.	Combine	JavaScript,	Java,	Ruby,	and	R
4.	Run	native	languages	on	the	JVM
5.	Tools	that	work	across	all	languages
6.	Extend	a	JVM-based	application
7.	Extend	a	native	application
9.	Polyglot	in	the	database
10.	Create	your	own	language
IoT
Polyglot
Cloud	Native
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Why	GraalVM?
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 7
8.	Java	code	as	a	native	library
1.	High-performance	modern	Java
2.	Low-footprint,	fast-startup	Java
3.	Combine	JavaScript,	Java,	Ruby,	and	R
4.	Run	native	languages	on	the	JVM
5.	Tools	that	work	across	all	languages
6.	Extend	a	JVM-based	application
7.	Extend	a	native	application
9.	Polyglot	in	the	database
10.	Create	your	own	language
IoT
Polyglot
Cloud	Native
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Why	GraalVMè Native	Application
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 8
8.	Java	code	as	a	native	library
1.	High-performance	modern	Java
2.	Low-footprint,	fast-startup	Java
3.	Combine	JavaScript,	Java,	Ruby,	and	R
4.	Run	native	languages	on	the	JVM
5.	Tools	that	work	across	all	languages
6.	Extend	a	JVM-based	application
7.	Extend	a	native	application
9.	Polyglot	in	the	database
10.	Create	your	own	language
IoT
Polyglot
Cloud	Native
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 9
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 10
https://medium.com/graalvm/instant-netty-startup-using-
graalvm-native-image-generation-ed6f14ff7692
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM Team
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 11
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM 개발 팀:	Research
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 12
64편 이상 논문(2012	~	2019)
https://www.graalvm.org/community/publications/
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 13
8	+												+
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
dk
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 14
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 15
JIT	Compiler
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Write	Once,	Run	Anywhere
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 16
이미지 출처: https://commons.wikimedia.org/wiki/File:Java-program-execution.png
- javac compiler
- Java	code(String)	è byte[]
- java	Binary	Representation
- compact	&	small
- JIT	compiler
- byte[]	è byte[]	(machine	code)
- compact	&	small	representation
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Compiler
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 17
• AOT(Ahead-of-Time)	Compiler
• JIT (Just-In-Time)	Compiler
Static vs	Dynamic
Compiler
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
AOT 컴파일러와 Dynamic	컴파일러 공통점
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 18
AOT	
Compiler
JIT
Compiler
è Machine	Code è Machine	Code
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
AOT 컴파일러와 Dynamic	컴파일러 차이점
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 19
AOT	Compiler JIT Compiler
Source code → Native executable Source code → Bytecode →
Interpreter + JIT executable
실행전에 무겁고 복잡한 분석&최적화 수행
실행 환경 정보 수집 어려움
Static Code 최적화
공격적이고 낙관적인 최적화
실행 프로파일 정보를 활용
특정 환경 특화된 최적화
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
JIT	Compiler의 목표
빠른 컴파일 속도 & 최적화
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 20
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
JIT	Compiler
• Speculation	Without	Regret:	Reducing	Deoptimization	Meta-data	in	the	
Graal	compiler
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 21
http://ssw.jku.at/General/Staff/GD/PPPJ-2014-duboscq-29.pdf
JVM
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
HotSpot Optimization
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 22
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Optimization:	inlining
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 23
int addAll(int max){
int accum = 0;
for(int i = 0; i<max; i++) {
accum = add (accum, i);
}
return accum;
}
int add(int a, int b){return a+b;}
int addAll(int max){
int accum = 0;
for(int i = 0; i<max; i++) {
accum = accum + i;
}
return accum;
}
Optimization:	inlining
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
JVM	성능 향상
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 24
http://www.dominicgiles.com/blog/files/abdb7a96e9db63644317c62d6e40c40b-142.html
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
JVM	성능 향상 주체
• JIT	Compiler
– Profiling &
• CPU,	Memory,	Object	Tracking,	Mem
– Optimization
• 더 효율적인 코디 패턴 감지
• 더 효율적인 머신 코드 생성
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 25
http://ssw.jku.at/General/Staff/GD/PPPJ-2014-duboscq-29.pdf
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Intel	CPU의 Java	최적화
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 26
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 27
HotSpot
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
HotSpot
• Oracle	Java	JVM
• Java	SE	1.3(1999.	04)에 추가
• 개발 언어: C++
• 2개의 JIT	compiler를 포함
– C1:	client compiler
• C1	디자인:	빠른 시작
• 코드 최적화의 비중 낮춤
– C2:	server compiler
• C2	디자인:	약간 느린 시작
• 코드 최적화 비중 높임
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 28
HotSpot VM
C1 C2
Compiler	Interface
HotSpot VM
c++
c++
c++
c++
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
JVM
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 29
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
HotSpot 의 고민
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 30
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
HotSpot – Limitation
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 31
https://github.com/netroby/jdk9-
dev/blob/master/jdk/src/java.base/share/classes/jdk/internal/HotSpotIntrinsicCandidate.java
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 32
GraalVM &	Graal
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 33
8	+												+
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 34
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 35
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM Team
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 36
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM의 핵심 키워드
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 37
Graal /	JVMCI Polyglot/	Truffle Native	Image
NEW	JIT	Complier Language	Platform AOT	Compiler
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Graal !=	GraalVM
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 38
HotSpot VM
C1 C2
Compiler	Interface
OpenJDK 8
HotSpot VM
Compiler	Interface JVMCI
C1 Graal
GraalVM
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Graal
• GraalVM의 새로운 JIT	Compiler
• Hotspot의 C2	JIT	컴파일러 대체가 목표
• Java로 개발
• C2와 비교하여 20% 선능 개선 (Twitter	사례)
– Production	Scala	애플리케이션에 적용
– GraalVM CE(Community	Edition)
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 39
https://www.youtube.com/watch?v=ZbccuoaLChk
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Community	Edition
• Free
• Unsupported
• Runs	all	GraalVM languages
– Java	(+Scala),	JavaScript,	Python,	Ruby,	R
• Support	for	native	libraries	in	context	of	those	languages	too
– Tools	(debugger,	profiler,	monitor	agent)
• Basic	version	of	SubstrateVM
– Native	code	has	full	access	to	address	space
• Runs	code	in	JVM,	Node.js,	MySQL,	or	standalone
Enterprise	Edition
• Not	Free
• Supported
• Best	performance	&	size
– Graal	EE	Java	is	20%	faster	than	CE	(on	average)
– Dynamic	languages	(JS,	Python,	R,	Ruby)	2x	faster
– Smallest	footprint	– 2x	smaller	vs CE
• Native	code	memory	protection
• Debugging	tools	for	embedded	use
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 40
GraalVM 라이센스
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Scala	2.12.6	&	GraalVM
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 41
https://medium.com/graalvm/compiling-scala-faster-with-graalvm-86c5c0857fa3
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
graal compiler
• OpenJDK 9	+
• OpenJDK 10	+
• OpenJDK 11	+
• GraalVM
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 42
-XX:+UnlockExperimentalVMOptions 
-XX:+UseJVMCICompiler 
-XX:+EnableJVMCI
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
graal compiler
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 43
https://www.graalvm.org/docs/examples/java-performance-examples/
https://github.com/taewanme/graalvm_seminar_examples/tree/master/examples/e01
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
graal compiler	Demo
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 44
OpenJDK 11,	Tiered	Compiler OpenJDK 11,	Graal Compiler
https://github.com/taewanme/graalvm_seminar_examples/tree/master/examples/e01
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
graal compiler	결과
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 45
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
graal compiler	Demo:	compile	log
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 46
https://github.com/taewanme/graalvm_seminar_examples/tree/master/examples/e01
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Graal과 Twitter
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 47
https://www.youtube.com/watch?v=G-vlQaPMAxg
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM 기능과 JEP
• JEP:	JDK	Enhancement	Proposal
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 48
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 49
Native	Image
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Native	Runtime
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 50
Java
Java or node.js or R or Ruby or Python
or C/C++ User Function
SVM
dynamically
executed
native
precompiled
Graal VM on SubstrateVM
Java
Java or node.js or R or Ruby or Python
or C/C++ User Function
HotSpot
dynamically
executed
native
precompiled
Graal VM on HotSpot
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Native	Image	
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 51
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
작은 footprint,	신속한 startup
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 52
OpenJDK 11,	Graal Compiler
SubstrateVM	(SVM)
• GraalVM의 하위 프로젝트
• JVM	애플리케이션을 컴파일하여 Native	실행파일을 생성
• Ahead-of-time	compiler- 빠른 시작을 유도
• Virtual	머신이 필요 없음
• 작은 메모리로 시작
• 38Mbyte	virt.x	애플리케이션을 10MB	RAM에서 돌린 사례
• https://www.jetdrone.xyz/2018/08/10/Vertx-native-image-
10mb.html
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Native	Image	Demo
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 53
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Graal &	SubstrateVM
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 54
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
빠른 Startup:	Heap	Image
• d
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 55
https://medium.com/graalvm/isolates-and-compressed-references-more-flexible-and-
efficient-memory-management-for-graalvm-a044cc50b67e
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Substrate	VM	Java	Limitations
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 56
https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md
항목 지원
Dynamic	Class	Loading	/	Unloading Not	supported
Reflection Mostly	supported
Dynamic	Proxy Mostly	supported
Java	Native	Interface	(JNI) Mostly	supported
Unsafe	Memory	Access Mostly	supported
Static	Initializers Partially	supported
InvokeDynamic	Bytecode	and	Method	Handles Not	supported
Finalizers Not	supported
References Mostly	supported
Security	Manager Not	supported
JVMTI,	JMX,	other	native	VM	interfaces Not	supported
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Micronaut의 GraalVM 지원
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 57
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Micronaut의 GraalVM 지원
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 58
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Micronaut의 GraalVM 지원
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 59
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM 기능과 JEP
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 60
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 61
Polyglot
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Truffle
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 62
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Polyglot	Virtualization
63
Truffle	API
JavaVM Runtime
JavaScript
Interpreter
Ruby
Interpreter
R
Interprete
r
Graal
compiler
Compiled	
code	snippetCompiled	
code	snippetCompiled	
code	snippetCompiled	
code	snippetCompiled	
code	snippetCompiled	
code	snippet
JavaScript	
application
JavaScript	
libraries
Node.js
…
Ruby	
application
Ruby	gems	
&	libraries
Rails
LLVM	.bc
Interpreter
R	native	
libraries
Node.js	
native	libs
Ruby/Rails	
native	libs
Threads	/	Scheduler Filesystem Network GC	/	heap Code	cache
Java	
application
Truffle	
Polyglot	
API
eval("application/x-ruby",
"def add(a, b) a + b;
end;");
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM Ecosystem
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 64
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Ployglot Performance
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 65
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM Language	Status
Available	2017
Available	2018
Proposed	/	Prototyping
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 66
Java
C
C++
Python
C#
VB.NET
JavaScript
Assembly	language
PHP
PerlRubyVBSwift
R
Objective-C
Go
MATLAB
Delphi/Object	Pascal
PL/SQL
Scratch
Others
PROGRAMMING	LANGUAGE	POPULARITY
(TOP	20	LANGUAGES	FROM	MAY	2017	TIOBE INDEX)
Groovy
FORTRAN
Kotlin
Clojure
Scala
F#
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Java에서 다른 언어 호출
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 67
import org.graalvm.polyglot.*;
public class Sample {
public static void main(String[] args) {
try (Context context = Context.newBuilder().allowAllAccess(true).build()){
System.out.println( context.getEngine().getLanguages().keySet());
context.eval("ruby", "puts '안녕, 루비’”);
context.eval("python", "print(안녕, 파이썬')");
context.eval("js", "console.log(‘안녕, JS')");
context.eval("R", "cat(‘안녕, R')");
} catch (PolyglotException e) {
e.printStackTrace();
}
}
}
https://github.com/taewanme/graalvm_seminar_examples/tree/master/examples/e04
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
spring-r:	mvn spring-boot:run
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 68
https://github.com/taewanme/graalvm_seminar_examples/tree/master/examples/e06
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Spring-r	UI:	http://localhost:8080/load
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 69
https://github.com/taewanme/graalvm_seminar_examples/tree/master/examples/e06
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Java에서 다른 언어를 호출 (LLVM)
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 70
#include	<stdio.h>
int main(){
print(“Hello	from	graalvm!n”);
return 0;	
}
$	clang	-c	-O1	-emit-llvm hello.c
$	lli hello.bc
Hello	from	graalvm!
$
https://github.com/taewanme/graalvm_seminar_examples/tree/master/examples/e03
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
Java에서 다른 언어를 호출 (LLVM)
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 71
import	org.graalvm.polyglot.*;	
import	java.io.*;	
public	class	Sample	{	
public	static	void	main(String[]	args)	throws	Exception	{
File	f	=	new	File("hello.bc");	
Source	source	=	Source.newBuilder("llvm",	new	File("hello.bc")).build();	
try	(Context				context	=	Context.newBuilder().allowAllAccess(true).build()){	
context.eval(source).execute();	
}	
}	
}	
https://github.com/taewanme/graalvm_seminar_examples/tree/master/examples/e03
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 72
https://github.com/taewanme/graalvm_seminar_examples
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 73
GraalVM 현재
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 74
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 75
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 76
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 77
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 78
GraalVM 사례
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 79
Twitter
https://www.youtube.com/watch?v=PtgKmzgIh4c
• Twitter	VM	팀은 Graal
컴파일러를 사용하여 Scala	
기반 microservices 운영
• 메모리 할당과 성능 향상
• 성능 개선: 20%
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 80
Goldman	Sachs
https://www.youtube.com/watch?time_continue=417&v=MUECwHdr07Q
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 81
GraalVM Summary
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM의 목표: Six	degrees	of	freedom
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 82
https://commons.wikimedia.org/wiki/File:6DOF.svg
• Fast	Startup	Java	Application:	Native
• High	Performance	Java	Application
• Integrated	Polyglot	Application
• Java	as	Language	Platform
• Embedded	Java	Application
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
GraalVM, OpenJDK, Oracle	Java
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 83
Graal
Native	Image
JVMCI
JEP	243:	Java-Level	JVM	Compiler	Interface
JEP	295:	Ahead-of-Time	Compilation
JEP	317:	Experimental	Java-Based	JIT	Compiler
9	~	12
8
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
추가 자료
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 84
• http://taewan.kim/post/graalvm_seminar/ 발표 동영상
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
추가 자료
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 85
• https://github.com/taewanme/graalvm_seminar_examples
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		|
추가자료
Confidential	– Oracle	Internal/Restricted/Highly	Restricted 86
gitter.im/graalvm
Copyright	©	2019,	Oracle	and/or	its	affiliates.	All	rights	reserved.		| Confidential	– Oracle	Internal/Restricted/Highly	Restricted 87
Cloud Native Java GraalVM 이상과 현실

More Related Content

Cloud Native Java GraalVM 이상과 현실