JRuby startup very slow on Win7

View: New views
7 Messages — Rating Filter:   Alert me  

JRuby startup very slow on Win7

by Peter Ritchie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is it normal that printing "1" requires more than five second? Sorry my
english.

I am new to ruby, currently I use PHP and Perl in Windows, but I don't
like PHP and Perl is not 100% compatible to Windows (nor Ruby, as I
see). I have found JRuby which claimed itself fully cross-platform. I
tried it, but it starts very-very slow. I have AMD 64 3000+, 1 Gb DDR,
Windows7, Java 6u17.

I have created a simple test (as I seen here:
http://www.ruby-forum.com/topic/164191): I runned the programs ten times
and get the average run time. Here are the results (in seconds):

0.1 perl -e "print 1"
0.1 ruby-1.9 -e "puts 1"
0.2 php -r "print(1);"
0.5 ruby-1.8 -e "puts 1"
1.9 jruby-1.2.0 -e "puts 1"
2.1 jruby-1.3.1 -e "puts 1"
5.6 jruby-1.4 -e "puts 1"
5.3 jruby-1.4 --1.9 -e "puts 1"


*********************************************
Content of t:\benchmark.rb
*********************************************
require 'benchmark'

def fib_ruby(n)
   if n < 2
     n
   else
     fib_ruby(n - 2) + fib_ruby(n - 1)
   end
end

TIMES = (ARGV[0] || 5).to_i
N = (ARGV[1] || 30).to_i
TIMES.times {
   puts Benchmark.measure { fib_ruby(N) }
}
*********************************************
c:\Programs\ruby\bin\ruby.exe t:\benchmark.rb
*********************************************
  4.172000   0.000000   4.172000 (  4.934000)
  4.265000   0.000000   4.265000 (  5.245000)
  4.203000   0.000000   4.203000 (  5.141000)
  4.250000   0.000000   4.250000 (  4.943000)
  4.141000   0.000000   4.141000 (  4.924000)
*********************************************
t:\ruby-1.9\bin\ruby.exe t:\benchmark.rb
*********************************************
  2.328000   0.000000   2.328000 (  2.992187)
  2.391000   0.000000   2.391000 (  2.759766)
  2.328000   0.000000   2.328000 (  2.704102)
  2.375000   0.000000   2.375000 (  2.836914)
  2.406000   0.000000   2.406000 (  2.768555)
*********************************************
t:\jruby-1.2.0\bin\jruby.bat t:\benchmark.rb
*********************************************
  1.340000   0.000000   1.340000 (  1.259000)
  1.176000   0.000000   1.176000 (  1.178000)
  1.167000   0.000000   1.167000 (  1.167000)
  1.193000   0.000000   1.193000 (  1.193000)
  1.177000   0.000000   1.177000 (  1.176000)
*********************************************
t:\jruby-1.3.1\bin\jruby.bat t:\benchmark.rb
*********************************************
  1.409000   0.000000   1.409000 (  1.305000)
  1.218000   0.000000   1.218000 (  1.217000)
  1.210000   0.000000   1.210000 (  1.209000)
  1.181000   0.000000   1.181000 (  1.181000)
  1.191000   0.000000   1.191000 (  1.191000)
*********************************************
c:\Programs\jruby-1.4\bin\jruby.exe t:\benchmark.rb
*********************************************
  1.303000   0.000000   1.303000 (  1.302000)
  1.289000   0.000000   1.289000 (  1.290000)
  1.280000   0.000000   1.280000 (  1.281000)
  1.296000   0.000000   1.296000 (  1.296000)
  1.263000   0.000000   1.263000 (  1.263000)
*********************************************
c:\Programs\jruby-1.4\bin\jruby.exe --1.9 t:\benchmark.rb
*********************************************
  3.260000   0.000000   3.260000 (  3.261000)
  3.224000   0.000000   3.224000 (  3.224000)
  3.212000   0.000000   3.212000 (  3.212000)
  3.155000   0.000000   3.155000 (  3.153000)
  3.231000   0.000000   3.231000 (  3.232000)
--
Posted via http://www.ruby-forum.com/.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: JRuby startup very slow on Win7

by Rob Heittman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The Java virtual machine can take a while to start up, as it's doing quite a lot (like booting a small virtual computer every time you start it).  This is no problem for long running programs like a web server, but you will certainly notice it when you run a short script like "puts 1" from the command line.  All JVM based languages have this startup time issue.  This is the trade off for running inside the portable JVM environment.

I think the problem would be less severe if you had more memory available.  I notice much worse Java startup times at only 1Gb in Windows.  At 2Gb it still is not instantaneous, but it seldom needs to reallocate and swap in order to get the JVM running.  Understand that even on a server machine with many GB of memory and powerful CPU, "jruby -e 'puts 1'" still takes a second or so, while "ruby -e 'puts 1'" takes only a few ms.

- Rob

On Fri, Nov 6, 2009 at 11:16 AM, Máté Farkas <lists@...> wrote:
Is it normal that printing "1" requires more than five second? Sorry my
english.
 

Re: JRuby startup very slow on Win7

by Vladimir Sizikov-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi  Máté,

Your results are very atypical. I also run JRuby every day on Windows
7, and JRuby's startup is around 0.5 sec for me, which is not that bad
for JVM-based language.

Please double check that you don't have %RUBYOPT% set, and you don't
load rubygems by default.

Your fib benchmark shows pretty good numbers for JRuby, compared to MRI. :)

Thanks,
  --Vladimir

On Fri, Nov 6, 2009 at 5:16 PM, Máté Farkas <lists@...> wrote:
> Is it normal that printing "1" requires more than five second? Sorry my
> english.
>
> I am new to ruby, currently I use PHP and Perl in Windows, but I don't
> like PHP and Perl is not 100% compatible to Windows (nor Ruby, as I
> see). I have found JRuby which claimed itself fully cross-platform. I
> tried it, but it starts very-very slow. I have AMD 64 3000+, 1 Gb DDR,
> Windows7, Java 6u17.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: JRuby startup very slow on Win7

by Peter Ritchie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Vladimir Sizikov wrote:
> Please double check that you don't have %RUBYOPT% set, and you don't
> load rubygems by default.
Dear Vladimir!

Thanks, I deleted this value and it's startup is 1.8 sec now.
I didn't checked anything, just installed it and I did would like to try
(and learn) Ruby, but I became terrified. (Sorry my english)

Thank you for your help again!

Best Wishes,
Máté (from Hungary)
--
Posted via http://www.ruby-forum.com/.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: JRuby startup very slow on Win7

by Rob Heittman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That's a huge win.  Awesome tip.

On Nov 6, 2009, at 11:56 AM, Vladimir Sizikov <vsizikov@...>  
wrote:

> Please double check that you don't have %RUBYOPT% set, and you don't
> load rubygems by default.
>
> Your fib benchmark shows pretty good numbers for JRuby, compared to  
> MRI. :)
>
> Thanks,
>  --Vladimir
>
> On Fri, Nov 6, 2009 at 5:16 PM, Máté Farkas <lists@...> w
> rote:
>> Is it normal that printing "1" requires more than five second?  
>> Sorry my
>> english.
>>
>> I am new to ruby, currently I use PHP and Perl in Windows, but I  
>> don't
>> like PHP and Perl is not 100% compatible to Windows (nor Ruby, as I
>> see). I have found JRuby which claimed itself fully cross-platform. I
>> tried it, but it starts very-very slow. I have AMD 64 3000+, 1 Gb  
>> DDR,
>> Windows7, Java 6u17.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: JRuby startup very slow on Win7

by gin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Cheers for that, Vladimir.

Mate, did you set that RUBYOPT explicitly or was it set by default by
Windows installer?
IMHO, if it causes unexpected delays, should we have it off by
default? Or, have some more direct way to turn it off? For example,
--fast option or a new startup script 'jruby-lite' which would
optimise for one liners and simple scripts.

I guess the other idea for better startup performance: NailGun
(http://kenai.com/projects/jruby/pages/JRubyWithNailgun)
Have only checked with 1.3, but most probably works with 1.4 too:
$jruby --ng-server
Then
$jruby --ng
should be lightning fast.

Also, -that default- JRUBY_HOME setting- caused me some grief on
Windows, when running on Eclipse OSGI (an extra ~15sec delay, fixed by
explicitly setting it).

Good luck,
Gergo

2009/11/6 Rob Heittman <rob.heittman@...>:

> That's a huge win.  Awesome tip.
>
> On Nov 6, 2009, at 11:56 AM, Vladimir Sizikov <vsizikov@...> wrote:
>
>> Please double check that you don't have %RUBYOPT% set, and you don't
>> load rubygems by default.
>>
>> Your fib benchmark shows pretty good numbers for JRuby, compared to MRI.
>> :)
>>
>> Thanks,
>>  --Vladimir
>>
>> On Fri, Nov 6, 2009 at 5:16 PM, Máté Farkas <lists@...> wrote:
>>>
>>> Is it normal that printing "1" requires more than five second? Sorry my
>>> english.
>>>
>>> I am new to ruby, currently I use PHP and Perl in Windows, but I don't
>>> like PHP and Perl is not 100% compatible to Windows (nor Ruby, as I
>>> see). I have found JRuby which claimed itself fully cross-platform. I
>>> tried it, but it starts very-very slow. I have AMD 64 3000+, 1 Gb DDR,
>>> Windows7, Java 6u17.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>   http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: JRuby startup very slow on Win7

by Peter Ritchie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

G N wrote:
> Mate, did you set that RUBYOPT explicitly or was it set by default by
> Windows installer?
I setted nothing, I am newbie. :)

> I guess the other idea for better startup performance: NailGun
> Have only checked with 1.3, but most probably works with 1.4 too:
With NailGun JRuby crashes if I started it from console ("cmd") or from
a batch script. (SocketException: Connection reset) It starts up in 1.0
second if I run it from a Perl script.
--
Posted via http://www.ruby-forum.com/.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email