JRuby is Ruby for the JVM, right? But what does that really mean? What do you get out of the deal?
We'll explore what makes JRuby unique among Ruby implementations, and why the JVM is a Rubyist's dream come true. Using JRuby means you have the best GC, real threads, easy and scalable deployment, high performance, no-compile cross-platform libraries, and the best monitoring and profiling tools of any VM. And you get it all without leaving Ruby behind. If you're not using JRuby already, this talk will convince you to give it a try.
5. Ruby on JVM
• Core classes and runtime in Java
• Moving parts to Ruby over time
• Standard command line
• 1.8 and 1.9 compatible
• 1.9 default in JRuby 1.7
• Drop in replacement for MRI*
6. *caveats
• Weak low-level UNIX stuff
• Improving over time
• Poor C extension support
• Not maintained...off by default in 1.7
• Some features differ or unavailable
• ObjectSpace, trace funcs, callcc...
7. JRuby 1.7 (preview)
• Ruby 1.9.3 mode by default
• Many 1.9 compat fixes
• Numerous perf improvements
• Java 7 invokedynamic support
• Beginning of new optimizing compiler
8. Getting Started
• Need a JVM...
• rvm install jruby
• rvm install jruby-1.7.0-preview1
• Download manually
• Unpack, edit PATH, done
14. JRuby Team
Charlie Tom
Nick Hiro Marcin Nahi Wayne Subbu Douglas Douglas
Douglas
Contribs
15. JRuby Team
Charlie Tom
Nick Hiro Marcin Nahi Wayne Subbu Douglas Douglas
Douglas
Contribs
Douglas
Douglas Douglas
Douglas Douglas
Douglas Douglas
Other
Douglas
OpenJDK Android J9
JVMs
16. JRuby Structure
JRuby
Bytecode Core Java
Parser
JIT Classes Integ
JVM
Native
Threads GC C API
JIT
17. JRuby Structure
JRuby
Bytecode Core Java
Parser
JIT Classes Integ
JRuby team can focus on implementing JRuby.
18. JRuby Team Doesn’t
Have to Work On*
• Memory allocation • Native JIT
• Garbage collectors • Tooling
• Native threading • Server environments
• Cross-platform • Native extensions
• Mobile/Embedded VMs
19. We could stop working
on JRuby and it would
continue to get faster.
20. Google Summer
of Code
• JRuby accepted as an organization
• Eight students!
• Shoes, Krypt, evented IO, fibers, Ruboto,
IR dumping, IR to Dalvik, benchmarking
• Three more from C42
33. JVM GC
• Wide array of options
• Generation size, worker threads,
concurrency, tenuring...
• Many GCs to choose from
• Scales up to massive heaps
• Best GCs in the world!
34. class Simple
attr_accessor :next
end
top = Simple.new
puts Benchmark.measure {
outer = 10
total = 100000
per = 100
outer.times do
total.times do
per.times { Simple.new }
s = Simple.new
top.next = s
top = s
end
end
}
48. Performance
• JRuby compiles Ruby to JVM bytecode
• JVM compiles bytecode to native
• Best JIT technology in the world
• Getting even better with invokedynamic
49. def foo
bar
end
def bar
baz foo bar baz
end
def baz
# ...
end
50. JRuby on Java 5/6
def foo
bar
end
def bar JRuby JRuby
baz foo call bar call baz
end logic logic
def baz
# ...
end
Kills many JVM optimizations
51. JRuby on Java 7
def foo
bar
X X
end
def bar JRuby JRuby
baz foo call bar call baz
end logic logic
def baz
# ...
end
Dynamic call logic built into JVM
52. JRuby on Java 7
def foo
bar
end
def bar
baz foo bar baz
end
def baz
# ...
end
Straight through dispatch path
53. JRuby on Java 7
def foo
bar
end
def bar
baz foo bar baz
end
def baz
# ...
end
Optimizations (like inlining) can happen!
62. Monitoring
• Java Management Extensions (JMX)
• Gems available for clients and servers
• jconsole and VisualVM
• Most servers provide additional tools
• New Relic, etc have JVM support
63. VisualVM
• CPU, memory, thread monitoring
• CPU and memory profiling
• VisualGC
• Heap analysis
64.
65.
66. Your Turn
• Try your apps on JRuby and tell us
• Turn on JRuby in @travisci
• Let us know what you think of JRuby
• Help us make JRuby even better!