great simple example of speedup using Java threads in JRuby

65 views
Skip to first unread message

Stephen Bannasch

unread,
Mar 9, 2012, 11:38:08 AM3/9/12
to educ...@googlegroups.com
Rodrigo Rosenfeld Rosas <rr.r...@gmail.com> put up an interesting post where he describes trying to parse lots of large html
files using Groovy, and then how much easier it was in JRuby using Nokogiri.

How NokoGiri and JRuby saved my week
http://rosenfeld.herokuapp.com/en/articles/ruby-rails/2012-03-04-how-nokogiri-and-jruby-saved-my-week

I'm not at all surprised that he found using NokoGiri and JRuby much easier for his particular problem -- but was particularly
interested in how simple the code was in JRuby for using multiple threads:

https://gist.github.com/2003503

MRI, the C version of Ruby still uses a GIL (Global Interpreter Lock) which limits how effective using threads can be.

The threads in JRuby are based on Java threads and as long as the code can be run in parallel then it's easy to get all the
cores on your computer working on the problem.

Matt Zukowski

unread,
Mar 9, 2012, 12:10:27 PM3/9/12
to educ...@googlegroups.com
Stephen, incidentally we recently packaged up Rollcall in a WAR file (using Warbler + JRuby). Might be a good chance to give it another try?


There's a SQL file there with a full schema too, since running migrations out of the WAR would be tricky. YOu'll also have to go inside and edit config/database.yml and config/environments/produciton.rb if you intend on integrating with Ejabberd or Prosody.

I'm surprised how easy this was (basically just had to switch the database driver to jdbcmysql). The one big catch is, the PUT and DELETE requests we're using for some of the REST API functionality don't work. There seems to be a security restriction in the servlet container that disables those HTTP methods, and for the life of me I can't figure out how to turn it off. Not sure if it's our Tomcat or if it's the jruby-rack container (might be the latter, since we tried everything possible to turn off the 'readonly' option in tomcat's config).

Anyway, if nothing else this might be a quick and easy way to at least play around with it a bit (not that it's anything fancy -- just a simple user/group/run management system with optional integration with an XMPP server).



--
You received this message because you are subscribed to the Google Groups "Educoder" group.
To post to this group, send email to educ...@googlegroups.com.
To unsubscribe from this group, send email to educoder+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/educoder?hl=en.


Reply all
Reply to author
Forward
0 new messages