Your SlideShare is downloading. ×
Euruko 2012 - JRuby
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Euruko 2012 - JRuby

3,227
views

Published on

JRuby is Ruby for the JVM, right? But what does that really mean? What do you get out of the deal? …

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.

Published in: Technology

0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,227
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
15
Comments
0
Likes
7
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. JRuby!
    • 2. Me• Charles Oliver Nutter • @headius• Java developer since 1996• JRuby developer since 2006• Starting at Red Hat on Monday!
    • 3. Red Hat FAQ• Primary job still JRuby• Expanding to help other languages• Working with OpenJDK team• Continuing to support EY JRuby efforts
    • 4. What is JRuby?
    • 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
    • 9. Try it Out
    • 10. JRuby is the best* Ruby runtime
    • 11. The Team
    • 12. JRuby Team
    • 13. JRuby Team Charlie
    • 14. JRuby Team Charlie TomNick Hiro Marcin Nahi Wayne Subbu Douglas Douglas Douglas Contribs
    • 15. JRuby Team Charlie TomNick 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 JavaParser JIT Classes Integ JVM NativeThreads GC C API JIT
    • 17. JRuby Structure JRuby Bytecode Core Java Parser JIT Classes IntegJRuby 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 workingon JRuby and it wouldcontinue 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
    • 21. Platforms
    • 22. Systems• Best Ruby on Windows?• Exotic platforms: zLinux, OpenVMS, AS/400• Android’s Dalvik• Embedded JVMs
    • 23. Ruboto
    • 24. Servers• Any Java server can host Ruby• Trinidad • Ruby-style CLI server atop Tomcat• Torquebox • Full Ruby stack atop JBossAS
    • 25. Torquebox• Rack-compatible • Server management• Database connectivity • Clustering• Background daemons • In and out-process cache• Scheduled jobs • Web sockets• Messaging • Authentication• Asynchronous tasks • XA Transactions
    • 26. Torquebox• Rack-compatible • Server management• Database connectivity • Clustering• All R Background daemons • In and out-process cache• Scheduled jobs uby • Web sockets• Messaging APIs • Authentication• Asynchronous tasks • ! XA Transactions
    • 27. Libraries
    • 28. Libraries• 340k versioned jars in Maven central • Compare to 35k gems in RubyGems.org• Vast majority have no native code• All usable from JRuby
    • 29. Midi Example
    • 30. GC
    • 31. 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!
    • 32. class Simple  attr_accessor :nextendtop = Simple.newputs 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}
    • 33. 15 GC time %11.25 7.5 3.75 0 JRuby Ruby 1.9.3
    • 34. Threads
    • 35. Real Parallellism• Ruby thread = JVM thread = native thread• One process can use all cores• One server can handle all requests
    • 36. require benchmarkary = (1..1000000).to_aloop {  puts Benchmark.measure {    10.times {      ary.each {|i|}    }  }}
    • 37. require benchmarkary = (1..1000000).to_aloop {  puts Benchmark.measure {    (1..10).map {      Thread.new {        ary.each {|i|}      }    }.map(&:join)  }}
    • 38. Ruby 1.9unthreaded
    • 39. Ruby 1.9 Ruby 1.9unthreaded threaded
    • 40. Ruby 1.9 Ruby 1.9unthreaded threaded JRubyunthreaded
    • 41. Ruby 1.9 Ruby 1.9unthreaded threaded JRuby JRubyunthreaded threaded
    • 42. threaded_reverse 0.80.65 0.50.35 0.2 one thread two threads three threads four threads
    • 43. Nonlinear?• More work means more objects• More objects needs memory bandwidth• No different from multi-process
    • 44. Performance
    • 45. Performance• JRuby compiles Ruby to JVM bytecode• JVM compiles bytecode to native• Best JIT technology in the world• Getting even better with invokedynamic
    • 46. def foo barenddef bar baz foo bar bazenddef baz # ...end
    • 47. JRuby on Java 5/6def foo barenddef bar JRuby JRuby baz foo call bar call bazend logic logicdef baz # ...end Kills many JVM optimizations
    • 48. JRuby on Java 7def foo bar X Xenddef bar JRuby JRuby baz foo call bar call bazend logic logicdef baz # ...end Dynamic call logic built into JVM
    • 49. JRuby on Java 7def foo barenddef bar baz foo bar bazenddef baz # ...end Straight through dispatch path
    • 50. JRuby on Java 7def foo barenddef bar baz foo bar bazenddef baz # ...end Optimizations (like inlining) can happen!
    • 51. JRuby/Java 6 JRuby/Java 7
    • 52. JRuby/Java 6 JRuby/Java 7 Times Faster than Ruby 1.9.3 53.75 2.51.25 0 base64 richards neural mandelbrot redblack
    • 53. JRuby/Java 6 JRuby/Java 7 Times Faster than Ruby 1.9.3 53.75 2.5 1.914 1.806 1.538 1.5651.25 1.346 0 base64 richards neural mandelbrot redblack
    • 54. JRuby/Java 6 JRuby/Java 7 Times Faster than Ruby 1.9.3 5 4.226 4.323.75 3.66 3.44 2.5 2.658 1.914 1.806 1.538 1.5651.25 1.346 0 base64 richards neural mandelbrot redblack
    • 55. Tools
    • 56. Profiling• Java profilers • VisualVM,YourKit, NetBeans, JXInsight• jruby [--profile | --profile.graph]• jruby -Xreify.classes=true• JVM command-line profilers
    • 57. 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
    • 58. VisualVM• CPU, memory, thread monitoring• CPU and memory profiling• VisualGC• Heap analysis
    • 59. 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!
    • 60. Thank you!• @headius• jruby.org• torquebox.org