BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

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

| by Werner Schuster Follow 2 Followers on Mar 24, 2010. Estimated reading time: 1 minute |

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?

Rate this Article

Adoption Stage
Style

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

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT