Performance problem wrapping a java library in jruby - twice as bad as jruby 1.6.2 ----------------------------------------------------------------------------------
Key: JRUBY-6003 URL: https://jira.codehaus.org/browse/JRUBY-6003 Project: JRuby Issue Type: Bug Components: Performance Affects Versions: JRuby 1.7 Environment: jruby 1.7.0.dev (ruby-1.8.7-p330) (2011-08-15 401bb15) (OpenJDK Client VM 1.7.0) [linux-i386-java] Patch open java - "1.7.0" Java(TM) SE Runtime Environment (build 1.7.0-b147) OpenJDK Server VM (build 22.0-b01-internal, mixed mode) ubuntu 10.10 linux kernel: 2.6.35-28-generic-pae (i686). Reporter: Andreas Ronge The following performance test is about twice as slow as in jruby 1.6.2. The performance test calculates the total size of all the files in the given folder and subfolders by using the Java graph database Neo4j library. {code:xml} include Java require "jars/neo4j-kernel-1.2-1.2.M03.jar" require "jars/geronimo-jta_1.1_spec-1.1.1.jar" DB_PATH = "tmp/neo4j" DynamicRelationshipType = org.neo4j.graphdb.DynamicRelationshipType Direction = org.neo4j.graphdb.Direction class RubyTraversal attr_reader :traversed def initialize @db = org.neo4j.kernel.EmbeddedGraphDatabase.new(DB_PATH) end def visit_ref_node @traversed = 1 rel = @db.getReferenceNode().getSingleRelationship(DynamicRelationshipType.withName("root"), Direction::OUTGOING) root = rel.getEndNode visit_folder(root) end def visit_folder(folder) size = 0 @traversed += 1 folder.getRelationships(DynamicRelationshipType.withName("folder")).each do |rel| size += visit_file(rel.getOtherNode(folder)) end folder.getRelationships(DynamicRelationshipType.withName("parent_folder"), Direction::INCOMING).each do |rel| size += visit_folder(rel.getOtherNode(folder)) end size end def visit_file(file) @traversed += 1 file.getProperty("size") end end trav = RubyTraversal.new TIMES = 10 total_time = 0 TIMES.times.each do |i| start_time = Time.now size = trav.visit_ref_node delta = Time.now - start_time puts "#{i+1} -- traversed #{trav.traversed} nodes #{size} bytes, in #{delta} seconds" total_time += delta end trav.shutdown {code} How to reproduce this performance test * git clone http://github.com/andreasronge/neo4j-perf.git * cd neo4j-perf * bundle * rake create The rake task will ask for a folder where from to create an database containing >= 400.000 files and sub folders * rake jruby # will start the performance test running the script below with flags: -J-Xms2048m -J-Xmx2048m -J-Xmn512m Notice, I have also tried running it with -J-XX:CompileCommand=dontinline,org.jruby.runtime.invokedynamic.InvokeDynamicSupport::invocationFallback flags but it did not change anything. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email