Martin Boßlet created JRUBY-6437:
------------------------------------

             Summary: IOInputStream Performance Regression
                 Key: JRUBY-6437
                 URL: https://jira.codehaus.org/browse/JRUBY-6437
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.6.5, JRuby 1.7
            Reporter: Martin Boßlet
         Attachments: certificate.cer

The following code

@JRubyMethod(meta = true)
public static IRubyObject test(ThreadContext ctx, IRubyObject recv, IRubyObject 
value) {
    try {
        Ruby rt = ctx.getRuntime();
        InputStream in = new IOInputStream(value);
        byte[] buf = new byte[8192];
        int read;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
            
        while ((read = in.read(buf)) != -1) {
            baos.write(buf, 0, read);
        }
        return rt.newString(new ByteList(baos.toByteArray(), false));
    } catch(Exception e) {
        throw ctx.getRuntime().newRuntimeError(e.getMessage());
    }
}

runs noticeably slower in JRuby trunk than on JRuby 1.6.5.1. Here's my
benchmarks:

$ jruby -v
jruby 1.7.0.dev (ruby-1.8.7-p357) (2012-01-21 0d0c764) (Java HotSpot(TM) 64-Bit 
Server VM 1.7.0_02) [linux-amd64-java]
$ jruby --1.9 -Ilib test/scratch.rb 
       user     system      total        real
File.new  8.331000   0.000000   8.331000 (  8.331000)
File.open  6.291000   0.000000   6.291000 (  6.291000)
File.open(..., 'rb')  6.502000   0.000000   6.502000 (  6.502000)

$ jruby -v
jruby 1.6.5.1 (ruby-1.8.7-p330) (2011-12-27 1bf37c2) (Java HotSpot(TM) 64-Bit 
Server VM 1.7.0_02) [linux-amd64-java]
$ jruby --1.9 -Ilib test/scratch.rb 
      user     system      total        real
File.new  6.802000   0.000000   6.802000 (  6.801000)
File.open  5.253000   0.000000   5.253000 (  5.253000)
File.open(..., 'rb')  5.145000   0.000000   5.145000 (  5.146000)

where the IO object was created using

File.new(File.expand_path("certificate.cer", File.dirname(__FILE__)))
File.open(File.expand_path("certificate.cer", File.dirname(__FILE__)))
File.open(File.expand_path("certificate.cer", File.dirname(__FILE__)), "rb")

for the corresponding lines.

I also attached the "certificate.cer". Due to the small size of the file,
IOInputStream#read is essentially only called twice in the while
loop.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.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


Reply via email to