Presentation is loading. Please wait.

Presentation is loading. Please wait.

JRuby State of the Art! Except where otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution-Share Alike 3.0.

Similar presentations


Presentation on theme: "JRuby State of the Art! Except where otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution-Share Alike 3.0."— Presentation transcript:

1 JRuby State of the Art! Except where otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License (

2 The JRuby Guys Tom Enebo and Charles Oliver Nutter
tom_enebo and headius on Twitter 4-6 years as JRuby devs 2.5 years at Sun Microsystems 12+ years as Java devs Working from home (Minneapolis area)

3 Basic Facts JRuby 1.2.0 or JRuby 1.3.0RC1 Ruby 1.8.6 or 1.9.1 compat
--1.9 flag to use 1.9 mode Rubygems, Rake, Rspec preinstalled Simple install Download bin tarball Unpack Put bin/ dir in PATH

4 Why Ruby on JVM Best memory management Dynamic optimizations
Reliable native threads Vast numbers of libraries Interop with Java, Scala, Rhino (JS), Jython, … Ubiquitous Why not?

5 JRuby and the JVM AST (interpreter) App code Java calls JRuby Runtime
Parser Ruby stdlib Compiler Core classes (String, etc) Precompiled code .class loading Bytecode Java calls

6 Performance JRuby compiles Ruby to JVM bytecode
JVM compiles bytecode to native Native code is optimized, inlined Fastest production-ready implementation

7 The Magic of Hotspot Vector v = new Vector(3); // Thread-safe list
.... reset(v); // Called many times void reset(Vector v) { for (int i = 0; i < v.size(); i++) { v.set(i) = 0; }

8 Hotspot: Method inlining
Inline void reset(Vector v) { fast_guard(v) { for (int I = 0; I < lock { arr.length }; i++) { lock { arr[i] = 0; } }

9 Hotspot: Simple Optz Unroll Loop void reset(Vector v) {
fast_guard(v) { lock { arr[0] = 0; } lock { arr[1] = 0; } lock { arr[2] = 0; } }

10 Hotspot: Lock Coarsening
Coarsen Locks void reset(Vector v) { fast_guard(v) { lock { arr[0] = 0; arr[1] = 0; arr[2] = 0; }

11 Hotspot: ArrayCopyStub
Contiguous Array replaced by Array Copy Stub void reset(Vector v) { fast_guard(v) { lock { arrayCopyStub(v, [0,0,0]) }

12 Future JVM Work “invokedynamic”
New features in Java 7 for dynamic languages Fast dynamic calls...as fast as Java JRuby support by June Multi-language VM “Da Vinci Machine” Optimized tail calls Continuations Fixnums, value types Faster, faster, always faster!

13 Threading Only production-ready impl with real threads
Ruby threads 1:1 native threads Scale across cores, no forks necessary One JRuby server process for an entire site

14 Simple Rails App Simple 1 controller, 1 model, 1 view app
Send 1000 reqs with concurrency 10 (ab) GlassFish v2

15 Better Deployment The GlassFish gem gem install glassfish
Run 'glassfish' in app dir Fast HTTP serving + load balancing One process per application Apache, nginx: just use mod_proxy

16 Ruby 1.9 Support Probably 80-90% complete
IO, Enumerable, some encoding stuff missing IRB works, RubyGems works Lack of Rubyspecs for 1.9 Number one way you could help

17 FFI Foreign Function Interface Call C functions directly from Ruby
Portable, unlike extensions Most extensions just wrap a library Started in Rubinius JRuby added support in 1.1.4 JRuby team: Ruby FFI gem gem install ffi

18 require 'ffi' module POSIX extend FFI::Library # not usually necessary since libc is always linked ffi_lib 'c' attach_function :getuid, :getuid, [], :uint attach_function :getpid, :getpid, [], :uint end puts "Process #{POSIX.getpid}, user #{POSIX.getuid}"

19 Who Uses JRuby?

20 Making the connection Sun's Project Kenai
A web platform of best-of-breed integrated collaborative “services” Source code management Subversion, Git, Mercurial Issue/bug tracking Jira, Bugzilla Discussions (mailing lists & forums) Wiki, feeds and aggregators Content management & publishing Building the Web, Using the Web Sun's Project Kenai

21 Sun's Kenai on JRuby Rails picked: Quick Development
Rapid Changes based on Customer feedback Sun does more than just Java (the language) JRuby picked: Fits Sun software stack better (Java, Glassfish) Wanted to demonstrate how JRuby can scale

22 Game Designers Gravitor (http://tinyurl.com/gravitor) A “real” game!
JRuby for game logic Java for graphics library Packaged as Mac, Windows app King Pong Ruby wrapping JMonkeyEngine

23 Mission-Critical Apps
Oslo's Gardermoen Airport Refueling service JRuby wrapping SWT, touchscreen libraries Completed user acceptance, in production soon

24 ThoughtWorks Mingle on JRuby
Agile Project Management and Team Collaboration Tool Reasons for JRuby on Rails: No Cross Platform SVN library for Ruby Bundling of installation (installer) Security (encrypting source code) Memory profile Avoiding process proliferation

25 Oracle Mix on JRuby Idea collaboration tool for customers/employees
JRuby on Rails: Agile: 5 developers 6 weeks for all development Concise: LOC: 2887, Test LOC: 3691 Needed to integrate in Oracles environment Java, Oracle DB Same group is now writing second application with JRuby on Rails

26 Trisano Open Source Infectious Disease Reporting System
Battling Swine Flu as we speak JRuby on Rails reasons: Ease of deployment Every enterprise on the planet runs Java Development team has a Java heritage Roadmap for the project is extensive and they wanted the fall back language to be Java rather than C.

27 JRuby on Google App Engine
GAE deploys WAR files Warbler + jruby-rack DataMapper wrapper for BigTable Automatic up/down scaling JRuby includes fixes for GAE Updates for related projects coming soon Talk tomorrow at 11:45AM

28 JRuby on GAE Hackathon! Fun Fun Fun!

29 Open Q/A Ask anything, we'll answer or demo
No question is too dumb/simple/obvious Catch us later if we run out of time


Download ppt "JRuby State of the Art! Except where otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution-Share Alike 3.0."

Similar presentations


Ads by Google