SlideShare ist ein Scribd-Unternehmen logo
1 von 67
JRuby!
Me

• Charles Oliver Nutter
 • @headius
• Java developer since 1996
• JRuby developer since 2006
• Starting at Red Hat on Monday!
Red Hat FAQ

• Primary job still JRuby
• Expanding to help other languages
• Working with OpenJDK team
• Continuing to support EY JRuby efforts
What is JRuby?
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*
*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...
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
Getting Started

• Need a JVM...
• rvm install jruby
 • rvm install jruby-1.7.0-preview1
• Download manually
 • Unpack, edit PATH, done
Try it Out
JRuby is the best*
  Ruby runtime
The Team
JRuby Team
JRuby Team


    Charlie
JRuby Team

               Charlie                  Tom




Nick   Hiro   Marcin     Nahi   Wayne   Subbu   Douglas   Douglas
                                                           Douglas
                                                           Contribs
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
JRuby Structure
                 JRuby
          Bytecode    Core       Java
Parser
             JIT     Classes    Integ

                 JVM
                       Native
Threads     GC                  C API
                        JIT
JRuby Structure
                   JRuby
             Bytecode    Core      Java
    Parser
                JIT     Classes   Integ


JRuby team can focus on implementing JRuby.
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
We could stop working
on JRuby and it would
continue to get faster.
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
Platforms
Systems

• Best Ruby on Windows?
• Exotic platforms: zLinux, OpenVMS, AS/400
• Android’s Dalvik
• Embedded JVMs
Ruboto
Servers

• Any Java server can host Ruby
• Trinidad
 • Ruby-style CLI server atop Tomcat
• Torquebox
 • Full Ruby stack atop JBossAS
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
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
Libraries
Libraries

• 340k versioned jars in Maven central
 • Compare to 35k gems in RubyGems.org
• Vast majority have no native code
• All usable from JRuby
Midi Example
GC
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!
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
}
15
                GC time %
11.25


  7.5


 3.75


   0
        JRuby               Ruby 1.9.3
Threads
Real Parallellism

• Ruby thread = JVM thread = native thread
• One process can use all cores
• One server can handle all requests
require 'benchmark'

ary = (1..1000000).to_a

loop {
  puts Benchmark.measure {
    10.times {
      ary.each {|i|}
    }
  }
}
require 'benchmark'

ary = (1..1000000).to_a

loop {
  puts Benchmark.measure {
    (1..10).map {
      Thread.new {
        ary.each {|i|}
      }
    }.map(&:join)
  }
}
Ruby 1.9
unthreaded
Ruby 1.9    Ruby 1.9
unthreaded   threaded
Ruby 1.9    Ruby 1.9
unthreaded   threaded




  JRuby
unthreaded
Ruby 1.9    Ruby 1.9
unthreaded   threaded




  JRuby        JRuby
unthreaded   threaded
threaded_reverse

 0.8



0.65



 0.5



0.35



 0.2
       one thread   two threads     three threads   four threads
Nonlinear?

• More work means more objects
• More objects needs memory bandwidth
• No different from multi-process
Performance
Performance

• JRuby compiles Ruby to JVM bytecode
• JVM compiles bytecode to native
• Best JIT technology in the world
• Getting even better with invokedynamic
def foo
  bar
end

def bar
  baz     foo   bar   baz
end

def baz
  # ...
end
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
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
JRuby on Java 7
def foo
  bar
end

def bar
  baz     foo               bar              baz
end

def baz
  # ...
end
                Straight through dispatch path
JRuby on Java 7
def foo
  bar
end

def bar
  baz           foo       bar       baz
end

def baz
  # ...
end
          Optimizations (like inlining) can happen!
JRuby/Java 6   JRuby/Java 7
JRuby/Java 6                   JRuby/Java 7
                        Times Faster than Ruby 1.9.3
  5



3.75



 2.5



1.25



  0
       base64      richards        neural      mandelbrot     redblack
JRuby/Java 6                     JRuby/Java 7
                            Times Faster than Ruby 1.9.3
  5



3.75



 2.5

                                    1.914          1.806
                    1.538                                         1.565
1.25   1.346




  0
         base64      richards          neural      mandelbrot      redblack
JRuby/Java 6                     JRuby/Java 7
                                 Times Faster than Ruby 1.9.3
  5


                                                                4.226           4.32
3.75
                                                 3.66
                                 3.44


 2.5           2.658


                                         1.914          1.806
                         1.538                                          1.565
1.25   1.346




  0
         base64           richards          neural      mandelbrot       redblack
Tools
Profiling

• Java profilers
 • VisualVM,YourKit, NetBeans, JXInsight
• jruby [--profile | --profile.graph]
• jruby -Xreify.classes=true
• JVM command-line profilers
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
VisualVM

• CPU, memory, thread monitoring
• CPU and memory profiling
• VisualGC
• Heap analysis
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!
Thank you!

• @headius
• jruby.org
• torquebox.org

Weitere ähnliche Inhalte

Was ist angesagt?

6장 Thread Synchronization
6장 Thread Synchronization6장 Thread Synchronization
6장 Thread Synchronization김 한도
 
4장. Class Loader
4장. Class Loader4장. Class Loader
4장. Class Loader김 한도
 
3장. Garbage Collection
3장. Garbage Collection3장. Garbage Collection
3장. Garbage Collection김 한도
 
Improve extension API: C++ as better language for extension
Improve extension API: C++ as better language for extensionImprove extension API: C++ as better language for extension
Improve extension API: C++ as better language for extensionKouhei Sutou
 
1장 Java란 무엇인가.key
1장 Java란 무엇인가.key1장 Java란 무엇인가.key
1장 Java란 무엇인가.key김 한도
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage libraryAn introduction and future of Ruby coverage library
An introduction and future of Ruby coverage librarymametter
 
Polyglot Plugin Programming
Polyglot Plugin ProgrammingPolyglot Plugin Programming
Polyglot Plugin ProgrammingAtlassian
 
7장 Oracle As Datasource
7장 Oracle As Datasource7장 Oracle As Datasource
7장 Oracle As Datasource김 한도
 
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVMDiagnosing Your Application on the JVM
Diagnosing Your Application on the JVMStaffan Larsen
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011bobmcwhirter
 
DataMapper on Infinispan
DataMapper on InfinispanDataMapper on Infinispan
DataMapper on InfinispanLance Ball
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBrian Sam-Bodden
 
Parallel worlds of CRuby's GC
Parallel worlds of CRuby's GCParallel worlds of CRuby's GC
Parallel worlds of CRuby's GCNarihiro Nakamura
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friendKai Koenig
 
Testing Ember Apps
Testing Ember AppsTesting Ember Apps
Testing Ember Appsjo_liss
 
JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyelliando dias
 
Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled CucumbersJoseph Wilk
 
Java tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy devJava tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy devTomek Borek
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011Lance Ball
 

Was ist angesagt? (20)

6장 Thread Synchronization
6장 Thread Synchronization6장 Thread Synchronization
6장 Thread Synchronization
 
4장. Class Loader
4장. Class Loader4장. Class Loader
4장. Class Loader
 
3장. Garbage Collection
3장. Garbage Collection3장. Garbage Collection
3장. Garbage Collection
 
Improve extension API: C++ as better language for extension
Improve extension API: C++ as better language for extensionImprove extension API: C++ as better language for extension
Improve extension API: C++ as better language for extension
 
1장 Java란 무엇인가.key
1장 Java란 무엇인가.key1장 Java란 무엇인가.key
1장 Java란 무엇인가.key
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage libraryAn introduction and future of Ruby coverage library
An introduction and future of Ruby coverage library
 
Polyglot Plugin Programming
Polyglot Plugin ProgrammingPolyglot Plugin Programming
Polyglot Plugin Programming
 
7장 Oracle As Datasource
7장 Oracle As Datasource7장 Oracle As Datasource
7장 Oracle As Datasource
 
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVMDiagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
 
DataMapper on Infinispan
DataMapper on InfinispanDataMapper on Infinispan
DataMapper on Infinispan
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
 
Devignition 2011
Devignition 2011Devignition 2011
Devignition 2011
 
Parallel worlds of CRuby's GC
Parallel worlds of CRuby's GCParallel worlds of CRuby's GC
Parallel worlds of CRuby's GC
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
 
Testing Ember Apps
Testing Ember AppsTesting Ember Apps
Testing Ember Apps
 
JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRuby
 
Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled Cucumbers
 
Java tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy devJava tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy dev
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011
 

Ähnlich wie Euruko 2012 - JRuby

Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRubyajuckel
 
The Year of JRuby - RubyC 2018
The Year of JRuby - RubyC 2018The Year of JRuby - RubyC 2018
The Year of JRuby - RubyC 2018Charles Nutter
 
Why JRuby? - RubyConf 2012
Why JRuby? - RubyConf 2012Why JRuby? - RubyConf 2012
Why JRuby? - RubyConf 2012Charles Nutter
 
JRuby: What's Different (RORO Melbourne October 2011)
JRuby: What's Different (RORO Melbourne October 2011)JRuby: What's Different (RORO Melbourne October 2011)
JRuby: What's Different (RORO Melbourne October 2011)Charles Nutter
 
JRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyJRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyEvgeny Rahman
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Charles Nutter
 
JRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMJRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMRaimonds Simanovskis
 
GlassFish can support multiple Ruby frameworks ... really ?
GlassFish can support multiple Ruby frameworks ... really ?GlassFish can support multiple Ruby frameworks ... really ?
GlassFish can support multiple Ruby frameworks ... really ?Arun Gupta
 
Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta ThoughtWorks
 
T4T Training day - NodeJS
T4T Training day - NodeJST4T Training day - NodeJS
T4T Training day - NodeJSTim Sommer
 
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)Darshan Karandikar
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaKeith Bennett
 
JRuby - The Perfect Alternative
JRuby - The Perfect AlternativeJRuby - The Perfect Alternative
JRuby - The Perfect AlternativeRam Vijapurapu
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015Charles Nutter
 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easyroialdaag
 
Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013Charles Nutter
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesAlexandra Masterson
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes BackBurke Libbey
 

Ähnlich wie Euruko 2012 - JRuby (20)

Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
The Year of JRuby - RubyC 2018
The Year of JRuby - RubyC 2018The Year of JRuby - RubyC 2018
The Year of JRuby - RubyC 2018
 
Why JRuby? - RubyConf 2012
Why JRuby? - RubyConf 2012Why JRuby? - RubyConf 2012
Why JRuby? - RubyConf 2012
 
JRuby: What's Different (RORO Melbourne October 2011)
JRuby: What's Different (RORO Melbourne October 2011)JRuby: What's Different (RORO Melbourne October 2011)
JRuby: What's Different (RORO Melbourne October 2011)
 
JRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyJRuby - The Best of Java and Ruby
JRuby - The Best of Java and Ruby
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016
 
JRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMJRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVM
 
Day 8 - jRuby
Day 8 - jRubyDay 8 - jRuby
Day 8 - jRuby
 
JRuby: The Hard Parts
JRuby: The Hard PartsJRuby: The Hard Parts
JRuby: The Hard Parts
 
GlassFish can support multiple Ruby frameworks ... really ?
GlassFish can support multiple Ruby frameworks ... really ?GlassFish can support multiple Ruby frameworks ... really ?
GlassFish can support multiple Ruby frameworks ... really ?
 
Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta
 
T4T Training day - NodeJS
T4T Training day - NodeJST4T Training day - NodeJS
T4T Training day - NodeJS
 
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
 
JRuby - The Perfect Alternative
JRuby - The Perfect AlternativeJRuby - The Perfect Alternative
JRuby - The Perfect Alternative
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easy
 
Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter Slides
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 

Mehr von Charles Nutter

Down the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandDown the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandCharles Nutter
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMJRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMCharles Nutter
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015Charles Nutter
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaCharles Nutter
 
Open Source Software Needs You!
Open Source Software Needs You!Open Source Software Needs You!
Open Source Software Needs You!Charles Nutter
 
InvokeBinder: Fluent Programming for Method Handles
InvokeBinder: Fluent Programming for Method HandlesInvokeBinder: Fluent Programming for Method Handles
InvokeBinder: Fluent Programming for Method HandlesCharles Nutter
 
Over 9000: JRuby in 2015
Over 9000: JRuby in 2015Over 9000: JRuby in 2015
Over 9000: JRuby in 2015Charles Nutter
 
Doing Open Source the Right Way
Doing Open Source the Right WayDoing Open Source the Right Way
Doing Open Source the Right WayCharles Nutter
 
Bringing Concurrency to Ruby - RubyConf India 2014
Bringing Concurrency to Ruby - RubyConf India 2014Bringing Concurrency to Ruby - RubyConf India 2014
Bringing Concurrency to Ruby - RubyConf India 2014Charles Nutter
 
Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Charles Nutter
 
Beyond JVM - YOW! Brisbane 2013
Beyond JVM - YOW! Brisbane 2013Beyond JVM - YOW! Brisbane 2013
Beyond JVM - YOW! Brisbane 2013Charles Nutter
 
The Future of JRuby - Baruco 2013
The Future of JRuby - Baruco 2013The Future of JRuby - Baruco 2013
The Future of JRuby - Baruco 2013Charles Nutter
 
High Performance Ruby - E4E Conference 2013
High Performance Ruby - E4E Conference 2013High Performance Ruby - E4E Conference 2013
High Performance Ruby - E4E Conference 2013Charles Nutter
 
Invokedynamic in 45 Minutes
Invokedynamic in 45 MinutesInvokedynamic in 45 Minutes
Invokedynamic in 45 MinutesCharles Nutter
 
Invokedynamic: Tales from the Trenches
Invokedynamic: Tales from the TrenchesInvokedynamic: Tales from the Trenches
Invokedynamic: Tales from the TrenchesCharles Nutter
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 
High Performance Ruby - Golden Gate RubyConf 2012
High Performance Ruby - Golden Gate RubyConf 2012High Performance Ruby - Golden Gate RubyConf 2012
High Performance Ruby - Golden Gate RubyConf 2012Charles Nutter
 
InvokeDynamic - You Ain't Seen Nothin Yet
InvokeDynamic - You Ain't Seen Nothin YetInvokeDynamic - You Ain't Seen Nothin Yet
InvokeDynamic - You Ain't Seen Nothin YetCharles Nutter
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Charles Nutter
 

Mehr von Charles Nutter (20)

Down the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandDown the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM Wonderland
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMJRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVM
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
 
Open Source Software Needs You!
Open Source Software Needs You!Open Source Software Needs You!
Open Source Software Needs You!
 
InvokeBinder: Fluent Programming for Method Handles
InvokeBinder: Fluent Programming for Method HandlesInvokeBinder: Fluent Programming for Method Handles
InvokeBinder: Fluent Programming for Method Handles
 
Over 9000: JRuby in 2015
Over 9000: JRuby in 2015Over 9000: JRuby in 2015
Over 9000: JRuby in 2015
 
Doing Open Source the Right Way
Doing Open Source the Right WayDoing Open Source the Right Way
Doing Open Source the Right Way
 
Bringing Concurrency to Ruby - RubyConf India 2014
Bringing Concurrency to Ruby - RubyConf India 2014Bringing Concurrency to Ruby - RubyConf India 2014
Bringing Concurrency to Ruby - RubyConf India 2014
 
Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013
 
Beyond JVM - YOW! Brisbane 2013
Beyond JVM - YOW! Brisbane 2013Beyond JVM - YOW! Brisbane 2013
Beyond JVM - YOW! Brisbane 2013
 
Down the Rabbit Hole
Down the Rabbit HoleDown the Rabbit Hole
Down the Rabbit Hole
 
The Future of JRuby - Baruco 2013
The Future of JRuby - Baruco 2013The Future of JRuby - Baruco 2013
The Future of JRuby - Baruco 2013
 
High Performance Ruby - E4E Conference 2013
High Performance Ruby - E4E Conference 2013High Performance Ruby - E4E Conference 2013
High Performance Ruby - E4E Conference 2013
 
Invokedynamic in 45 Minutes
Invokedynamic in 45 MinutesInvokedynamic in 45 Minutes
Invokedynamic in 45 Minutes
 
Invokedynamic: Tales from the Trenches
Invokedynamic: Tales from the TrenchesInvokedynamic: Tales from the Trenches
Invokedynamic: Tales from the Trenches
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
High Performance Ruby - Golden Gate RubyConf 2012
High Performance Ruby - Golden Gate RubyConf 2012High Performance Ruby - Golden Gate RubyConf 2012
High Performance Ruby - Golden Gate RubyConf 2012
 
InvokeDynamic - You Ain't Seen Nothin Yet
InvokeDynamic - You Ain't Seen Nothin YetInvokeDynamic - You Ain't Seen Nothin Yet
InvokeDynamic - You Ain't Seen Nothin Yet
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
 

Kürzlich hochgeladen

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Kürzlich hochgeladen (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

Euruko 2012 - 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
  • 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
  • 10. JRuby is the best* Ruby runtime
  • 13. JRuby Team Charlie
  • 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
  • 22. Systems • Best Ruby on Windows? • Exotic platforms: zLinux, OpenVMS, AS/400 • Android’s Dalvik • Embedded JVMs
  • 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
  • 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.
  • 30.
  • 32. GC
  • 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 }
  • 35. 15 GC time % 11.25 7.5 3.75 0 JRuby Ruby 1.9.3
  • 37. Real Parallellism • Ruby thread = JVM thread = native thread • One process can use all cores • One server can handle all requests
  • 38. require 'benchmark' ary = (1..1000000).to_a loop {   puts Benchmark.measure {     10.times {       ary.each {|i|}     }   } }
  • 39. require 'benchmark' ary = (1..1000000).to_a loop {   puts Benchmark.measure {     (1..10).map {       Thread.new {         ary.each {|i|}       }     }.map(&:join)   } }
  • 40.
  • 42. Ruby 1.9 Ruby 1.9 unthreaded threaded
  • 43. Ruby 1.9 Ruby 1.9 unthreaded threaded JRuby unthreaded
  • 44. Ruby 1.9 Ruby 1.9 unthreaded threaded JRuby JRuby unthreaded threaded
  • 45. threaded_reverse 0.8 0.65 0.5 0.35 0.2 one thread two threads three threads four threads
  • 46. Nonlinear? • More work means more objects • More objects needs memory bandwidth • No different from multi-process
  • 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!
  • 54.
  • 55. JRuby/Java 6 JRuby/Java 7
  • 56. JRuby/Java 6 JRuby/Java 7 Times Faster than Ruby 1.9.3 5 3.75 2.5 1.25 0 base64 richards neural mandelbrot redblack
  • 57. JRuby/Java 6 JRuby/Java 7 Times Faster than Ruby 1.9.3 5 3.75 2.5 1.914 1.806 1.538 1.565 1.25 1.346 0 base64 richards neural mandelbrot redblack
  • 58. JRuby/Java 6 JRuby/Java 7 Times Faster than Ruby 1.9.3 5 4.226 4.32 3.75 3.66 3.44 2.5 2.658 1.914 1.806 1.538 1.565 1.25 1.346 0 base64 richards neural mandelbrot redblack
  • 59.
  • 60. Tools
  • 61. Profiling • Java profilers • VisualVM,YourKit, NetBeans, JXInsight • jruby [--profile | --profile.graph] • jruby -Xreify.classes=true • JVM command-line profilers
  • 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!
  • 67. Thank you! • @headius • jruby.org • torquebox.org

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n