System.gc() is extremely expensive when calling Java code from JRuby
--------------------------------------------------------------------
Key: JRUBY-1997
URL: http://jira.codehaus.org/browse/JRUBY-1997
Project: JRuby
Issue Type: Improvement
Components: Java Integration, Performance
Affects Versions: JRuby 1.1RC1, JRuby 1.0.3
Environment: java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
Java HotSpot(TM) Server VM (build 1.5.0_13-b05, mixed mode)
Reporter: Nicos Gollan
Priority: Minor
Calling Sysetem.gc() becomes an extremely expensive operation when calling Java
code from JRuby. The sample code below takes 3.3s when run as native Java code
and 33s when run in trunk from the Ruby stub.
{code:title=TortureTest.java|borderStyle=solid}
public class TortureTest {
private int numruns;
public TortureTest( int nr ) {
numruns = nr;
}
public void run() {
long ct = System.currentTimeMillis();
for( int r=0; r<numruns; ++r ) {
for( int i=0; i<1000; ++i ) {
System.gc();
String s = new String( "Krabooble!" );
}
}
System.out.println( "Time spent in benchamrking loop: " +
(System.currentTimeMillis()-ct) + "ms" );
}
public static void main( String args[] ) {
TortureTest tt = new TortureTest(1);
tt.run();
}
}
{code}
{code:title=gc-test.rb}
#! /usr/bin/env jruby
require 'java'
import 'TortureTest'
demo = TortureTest.new(1);
demo.run
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
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