Ruby Logo is Copyright (c) 2006, Yukihiro Matsumoto. It is licensed under the terms of the Creative Commons Attribution-ShareAlike 2.5 agreement.
JRuby+Truffle
Why its important to optimise the tricky parts
Chris Seaton
Research Manager
Oracle Labs
2 June 2016
JRuby
JITs by emitting JVM bytecode
VM in Java
Core library mostly in Java
Rubinius
JITs by emitting LLVM IR
VM in C++
Core library mostly in Ruby
JIT
JIT
Hotspot
JIT
JIT
U U Node Transitions
Uninitialized Integer
U
U U I
S D
AST Interpreter
Uninitialized Nodes String Double
G
Generic
U U Node Transitions I G
Uninitialized Integer
U
U U I I I
S D
AST Interpreter AST Interpreter
Uninitialized Nodes String Double Rewritten Nodes
G
Generic
I G I G
Uninitialized Integer I I
I I I
D
AST Interpreter
Double Compiled Code
Rewritten Nodes
Generic
U U Node Transitions I G I G
Uninitialized Integer I I
U
U U I I I
S D
AST Interpreter AST Interpreter
String Double Compiled Code
Uninitialized Nodes Rewritten Nodes
G
Generic
I G I G D
I I
I I I
03/06/2016 Copyright 2016, Oracle and/or its affiliates. All rights reserved. |
Node Rewriting to Update Recompilation using
G Profiling Feedback G Partial Evaluation
G
I G D G D G
I D
I I D
03/06/2016 Copyright 2016, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential Internal/Restricted/Highly Restricted
Deoptimization Node Rewriting to Update Recompilation using
to AST Interpreter G Profiling Feedback G Partial Evaluation
G G
I G I G D G D G
I I I D
I I I D
03/06/2016 Copyright 2016, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential Internal/Restricted/Highly Restricted
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 60
Frequently executed call
BigInteger
int
BigInteger
int
BigInteger
int
Truffle Java
Graal
JVMCI
(JVM Compiler Interface)
Hotspot C++
Graal
Hotspot Java 9
U U Node Transitions I G I
Uninitialized Integer I
U
U U I I I
S D
AST Interpreter AST Interpreter
String Double Compi
Uninitialized Nodes Rewritten Nodes
G
Generic
Node Transitions I G I G
Uninitialized Integer I I
U
I I I
S D
AST Interpreter
String Double Compiled Code
Rewritten Nodes
G
Generic
T. Wrthinger, C. Wimmer, A. W, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon,
and M. Wolczko. One VM to rule them all. In Proceedings of Onward!, 2013.
puts min(2, 8)
puts t3[0]
puts t1
puts t1
puts t1
puts t1
puts t1
puts 2
puts t1
puts t1
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 100
t1 = (a <=> b) < 0 ? a : b
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 101
puts (a <=> b) < 0 ? a : b
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 102
A deliberately extreme example
Node
psd_native_util_clamp
FIX2INT
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 126
cmyk_to_rgb
psd_native_util_clamp
FIX2INT
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 127
C Extension Performance for psd_native and oily_png
35
20
15
10
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 136
Safe Harbor Statement
The preceding is intended to provide some insight into a line of research in Oracle Labs. It
is intended for information purposes only, and may not be incorporated into any contract.
It is not a commitment to deliver any material, code, or functionality, and should not be
relied upon in making purchasing decisions. Oracle reserves the right to alter its
development plans and practices at any time, and the development, release, and timing
of any features or functionality described in connection with any Oracle product or
service remains at the sole discretion of Oracle. Any views expressed in this presentation
are my own and do not necessarily reflect the views of Oracle.