BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

JRuby Roundup: JRuby-Prof Allows Fast Profiling, JRuby::Synchronized for Automatic Synchronization

by Werner Schuster on Mar 24, 2010 |

JRuby-Prof is a new JRuby specific profiler by Daniel Lucraft. While there are many mature profilers for Java available, JRuby's mixed execution mode makes their output hard to read; some JRuby code is interpreted, some JRuby hot spots are JIT compiled to bytecode. With a Java profiler, JRuby's internal methods will show up in the profiles, hogging all the top spots in the profile output, when the user actually only wants to know how often which Ruby methods are invoked.

JRuby-prof uses JRuby's hooks to get information about events like method invocation, etc. Hooks are a more efficient way of implementing a profiler, at least compared to the simple method of set_trace_func, where a callback function is called before a line is executed.

JRuby-prof is available as a Gem:

jruby -S gem install jruby-prof 

The source code for JRuby-prof is available at GitHub.

A new addition to JRuby is the JRuby::Synchronized module. Charles Nutter explains the idea behind JRuby::Synchronized on the jruby-user list:

After talking with MenTaLguY on IRC about adding some concurrent collections to JRuby, we came up with a new feature for people to try out:
require 'jruby/synchronized'
class MyClass include JRuby::Synchronized ...

or
obj.extend JRuby::Synchronized

the effect of including or extending this new module is that all method calls against that class's object (or against that now-singleton object) will act like they're wrapped in a Java synchronized block. No two threads will be able to execute methods against those objects at the same time (on a per-object basis, obviously).

It's an experiment with providing concurrency tools for JRuby - what others would you like to see?

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Not all Java Profilers are equal by William Louth

"With a Java profiler, JRuby's internal methods will show up in the profiles, hogging all the top spots in the profile output, when the user actually only wants to know how often which Ruby methods are invoked."

This is not entirely true. There are Java profiling (metering) solutions Ruby/JRuby aware.

williamlouth.wordpress.com/2009/08/05/the-faste...

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT