JRuby startup very slow

Hello,

I have two major problems with Rails console within Netbeans 6.5 beta
on my Mac PPC system 10.4.11, java 5.

I - It takes a huge amount of time to fire the Rails console.
(as if takes an even more huge amount of time to fire Netbeans,
create any project, especially ruby ones, and use rake tasks and
migrations).
But outside of Netbeans, it is almost immediate, so maybe there is
something in the way which slows down Netbeans.

I’ve made some tests:

A - from inside Netbean:
1 - After 12 seconds, I get this line:
Loading development environment (Rails 2.1.0)

2 - After 36 seconds (that is: 36 - 12 = 24 seconds to load), I get
those lines:
JRuby limited openssl loaded. gem install jruby-openssl for full
support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL

3 -After 43 seconds (that is: 43 - 36 = 7 seconds to load), I get
this line:

B - From the terminal, using the JRuby inside Netbeans:
Same as A, except step 3:

After 42 seconds (that is: 42 - 36 = 6 seconds to load), I get this
line:

C - From the terminal, using MRI JRuby installed in /usr/local/bin

Step 1: 1 second
Not step 2
Step 3: 7 seconds
Total: 8 seconds

Is there any way to speed up the startup of the Rails console, some
switch to pass or so?

2 - The Rails console does not seem to take care of changes in models
after a few minutes.
It seems to freeze the code, which makes it extremely difficult to test.
I’ve also noted this kind of behaviour outside of Netbeans, but it
takes hours to do so, which is not so bad.

Is this a known issue, or is there some way to avoid this?

I’d be grateful if someone could help me solve those problems.

Cheers,
Michèle
http://micmacfr.homeunix.org

Michèle Garoche wrote:

Hello,

I have two major problems with Rails console within Netbeans 6.5 beta on
my Mac PPC system 10.4.11, java 5.

I - It takes a huge amount of time to fire the Rails console.
(as if takes an even more huge amount of time to fire Netbeans, create
any project, especially ruby ones, and use rake tasks and migrations).
But outside of Netbeans, it is almost immediate, so maybe there is
something in the way which slows down Netbeans.

Is there any way to speed up the startup of the Rails console, some
switch to pass or so?

How does this compare to normal Ruby? the PPC machines are not known for
their blazing speed, but this seems like it’s slower than it should be.
By comparison, on my Core Duo 2.16GHz machine Rails takes maybe 5-10s to
start up, with or without NetBeans.

2 - The Rails console does not seem to take care of changes in models
after a few minutes.
It seems to freeze the code, which makes it extremely difficult to test.
I’ve also noted this kind of behaviour outside of Netbeans, but it takes
hours to do so, which is not so bad.

Is this a known issue, or is there some way to avoid this?

This sounds like it could be related to your speed issues. Does it never
update or does it just take a long time?

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Le 30 août 2008 à 23:09, Charles Oliver N. a écrit :

Is there any way to speed up the startup of the Rails console,
some switch to pass or so?

How does this compare to normal Ruby?
irb is immediate (1 second or minus).

the PPC machines are not known for their blazing speed, but this
seems like it’s slower than it should be. By comparison, on my Core
Duo 2.16GHz machine Rails takes maybe 5-10s to start up, with or
without NetBeans.
I’ve only an iMac G4 1GHz.

2 - The Rails console does not seem to take care of changes in
models after a few minutes. It seems to freeze the code, which
makes it extremely difficult to test. I’ve also noted this kind of
behaviour outside of Netbeans, but it takes hours to do so, which
is not so bad. Is this a known issue, or is there some way to
avoid this?

This sounds like it could be related to your speed issues. Does it
never update or does it just take a long time?
It updates maybe one or two times, then no more within Netbeans. I’ve
solved the issue outside Netbeans with reload! every time I make a
change.

Cheers,
Michèle
http://micmacfr.homeunix.org

Michèle Garoche wrote:

How does this compare to normal Ruby?
irb is immediate (1 second or minus).

And JRuby outside of NetBeans?

This sounds like it could be related to your speed issues. Does it
never update or does it just take a long time?
It updates maybe one or two times, then no more within Netbeans. I’ve
solved the issue outside Netbeans with reload! every time I make a change.

So it works ok outside of NetBeans?

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Le 31 août 2008 à 00:27, Charles Oliver N. a écrit :

Michèle Garoche wrote:

How does this compare to normal Ruby?
irb is immediate (1 second or minus).

And JRuby outside of NetBeans?
jirb takes 8 seconds to load,

This sounds like it could be related to your speed issues. Does
it never update or does it just take a long time?
It updates maybe one or two times, then no more within Netbeans.
I’ve solved the issue outside Netbeans with reload! every time I
make a change.

So it works ok outside of NetBeans?
With reload!, yes.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Here are my (very informal) results on a Leopard Dual 2GHz PPC G5
PowerMac:30
seconds JRuby (NetBeans)
20 seconds JRuby (Terminal)
11 seconds MRI (NetBeans)
5 seconds MRI (Terminal)

And on a Leopard Intel Core 2 Duo 2GHz MacBook:
15 seconds JRuby (NetBeans)
10 seconds JRuby (Terminal)
9 seconds MRI (NetBeans)
2 seconds MRI (Terminal)

It seems as though Ruby starts faster than JRuby, the terminal is faster
than NetBeans, and Intel is better than PPC. And without the numbers to
back it up I think my Macs are faster than my Windows machine at work
:wink:

I typically use NetBeans as my editor but run the console, rake, webrick
etc. at the terminal (Cygwin on a PC). And if possible I use the MRI
during
development and test/deploy using JRuby.

Darcy.

On Sat, Aug 30, 2008 at 8:32 PM, Charles Oliver N. <

Michèle Garoche wrote:

And JRuby outside of NetBeans?
jirb takes 8 seconds to load,

So it works ok outside of NetBeans?
With reload!, yes.

Ok, it sounds like there’s something wrong with NetBeans on your system.
I’d recommend you subscribe to the NetBeans Ruby mailing list or file a
bug for this. NetBeans-related problems are out of scope for this list
unfortunately (though others may have suggestions of things to try).

http://wiki.netbeans.org/RubyCommunityInformation

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Michèle Garoche wrote:

That’s precisely the Netbeans Ruby mailing list who suggested me to
subscribe to the JRuby mailing list to ask if there could be something
to do.
Thanks for your time. Anyway, I do’nt regret to have subscribed, the
list is very interesting.

Sorry about that…but it seems like the problem is clearly
NetBeans-specific since it’s only happening when starting Ruby (JRuby or
C Ruby) from within NetBeans. There’s not a whole lot we can do about
that.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Le 31 août 2008 à 04:32, Charles Oliver N. a écrit :

scope for this list unfortunately (though others may have
suggestions of things to try).
That’s precisely the Netbeans Ruby mailing list who suggested me to
subscribe to the JRuby mailing list to ask if there could be
something to do.
Thanks for your time. Anyway, I do’nt regret to have subscribed, the
list is very interesting.

Cheers,
Michèle

Le 31 août 2008 à 05:12, Darcy S. a écrit :

9 seconds MRI (NetBeans)
2 seconds MRI (Terminal)

It seems as though Ruby starts faster than JRuby, the terminal is
faster than NetBeans, and Intel is better than PPC. And without
the numbers to back it up I think my Macs are faster than my
Windows machine at work :wink:

I typically use NetBeans as my editor but run the console, rake,
webrick etc. at the terminal (Cygwin on a PC). And if possible I
use the MRI during development and test/deploy using JRuby.
Thank you very much Darcy for your numbers, it gives me a good point
of comparison. I will follow your advise in running the different parts.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Charles Oliver N. wrote:

Michèle Garoche wrote:

And JRuby outside of NetBeans?
jirb takes 8 seconds to load,

So it works ok outside of NetBeans?
With reload!, yes.

Ok, it sounds like there’s something wrong with NetBeans on your system.

If I understand it correctly, Michèle workarounded the slow
./script/console start-up with calling ‘reload!’ from withing running
Rails console. The initial, and main, Michèle’s problem was slow
start-up of the console with or without NetBeans. If my assumptions are
right this purely JRuby issue, IDE unrelated.

m.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Michèle Garoche wrote:

iruby -S rails -d mysql blog takes 49 seconds to complete in the terminal.
jruby -S rake db:create also 49 seconds
jruby -S rake db:migrate also 49 seconds

Ok, it sounds more like this is a JVM issue then on PPC. 49 seconds is
an extremely long time. My system (which is admittedly faster) takes
about 5 seconds on the low end and 10 seconds on the high end for
creating a new app. MRI on the same machine takes about 4.7 seconds
consistently.

Could you time jruby -e “puts 1” and post your results? Run it a few
times in sequence (like five times) and post all numbers. Your machine
sounds like a possible worst-case for JRuby startup, so I’d like to work
with you to improve it.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Le 1 sept. 2008 à 20:21, Martin K. a écrit :

If I understand it correctly, Michèle workarounded the slow ./
script/console start-up with calling ‘reload!’ from withing running
Rails console. The initial, and main, Michèle’s problem was slow
start-up of the console with or without NetBeans. If my assumptions
are right this purely JRuby issue, IDE unrelated.
I’ve just installed jruby 1.1.4 to see if it is faster.
And I have run it outside of Netbeans.

iruby -S rails -d mysql blog takes 49 seconds to complete in the
terminal.
jruby -S rake db:create also 49 seconds
jruby -S rake db:migrate also 49 seconds

Cheers,
Michèle
http://micmacfr.homeunix.org



Le 2 sept. 2008 à 13:59, Charles Oliver N. a écrit :

seconds consistently.

Could you time jruby -e “puts 1” and post your results? Run it a
few times in sequence (like five times) and post all numbers. Your
machine sounds like a possible worst-case for JRuby startup, so I’d
like to work with you to improve it.
Thank you very much for that.

I’ve put it in a shell script:

date
jruby -e “puts 1”
, hope that does not change the result of timing too much.

[toto:~]% jrubytest
Mar sep 2 18:10:17 CEST 2008
1
Mar sep 2 18:10:21 CEST 2008
1
Mar sep 2 18:10:24 CEST 2008
1
Mar sep 2 18:10:27 CEST 2008
1
Mar sep 2 18:10:30 CEST 2008
1
Mar sep 2 18:10:33 CEST 2008

Cheers,
Michèle
http://micmacfr.homeunix.org

Le 2 sept. 2008 à 18:21, Charles Oliver N. a écrit :

Mar sep 2 18:10:27 CEST 2008
1
Mar sep 2 18:10:30 CEST 2008
1
Mar sep 2 18:10:33 CEST 2008

Three seconds isn’t great, but it’s not terrible. Do you have JRuby
sources?
No, I’ve just downloaded the binary. Should I download the sources
and run the benchmarks?

May I ask how long it takes C Ruby to run these commands as well?
In ruby 1.8.7 (2008-08-11 patchlevel 72) [powerpc-darwin8.11.0], same
test running 10 times to see a difference in times:
[toto:~]% rubytest
Mar sep 2 18:48:44 CEST 2008
1
Mar sep 2 18:48:44 CEST 2008
1
Mar sep 2 18:48:44 CEST 2008
1
Mar sep 2 18:48:44 CEST 2008
1
Mar sep 2 18:48:44 CEST 2008
1
Mar sep 2 18:48:45 CEST 2008
1
Mar sep 2 18:48:45 CEST 2008
1
Mar sep 2 18:48:45 CEST 2008
1
Mar sep 2 18:48:45 CEST 2008
1
Mar sep 2 18:48:45 CEST 2008
1
Mar sep 2 18:48:45 CEST 2008

In jruby 1.1.4, test with the command below:

jruby -S rails -d mysql blog1
cd blog1
jruby -S rake db:create
jruby -S rake db:migrate

[toto]% jrubytest1
Mar sep 2 18:55:52 CEST 2008
create
… (here I cut the details)
create log/test.log
Mar sep 2 18:56:18 CEST 2008
Mar sep 2 18:56:18 CEST 2008
(in /PortefeuillePartage/Ruby/09/blog1)
Mar sep 2 18:57:03 CEST 2008
(in /PortefeuillePartage/Ruby/09/blog1)
Mar sep 2 18:57:48 CEST 2008

Result:
26 seconds for rails -d mysql blog1
42 seconds for db:create
45 seconds for db:migrate

Cheers,
Michèle
http://micmacfr.homeunix.org

Michèle Garoche wrote:

1
Mar sep 2 18:10:27 CEST 2008
1
Mar sep 2 18:10:30 CEST 2008
1
Mar sep 2 18:10:33 CEST 2008

Three seconds isn’t great, but it’s not terrible. Do you have JRuby
sources? There’s some benchmarks in there you might try running, like
bench_full_startup, which adds in some nontrivial libraries.

My startup for this test is about 0.6s, so your system is running
roughly 5 times slower to start up JRuby. Now the PPC processers are
slow, but they shouldn’t be that slow. However if this ratio carries
over to Rails, it’s easy to see how my 10 second startup becomes 50
seconds on your machine.

May I ask how long it takes C Ruby to run these commands as well?

jruby -S rails -d mysql blog
jruby -S rake db:create
jruby -S rake db:migrate

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Michèle Garoche wrote:

1
No, I’ve just downloaded the binary. Should I download the sources and
Mar sep 2 18:48:44 CEST 2008
1
Mar sep 2 18:48:45 CEST 2008
1
Mar sep 2 18:48:45 CEST 2008
1
Mar sep 2 18:48:45 CEST 2008

Hmm, ok, so C Ruby is almost instantaneous for the “puts 1” test. Of
course there’s more we can do here but cold start on super-short scripts
will never approach C Ruby’s time.

A JRuby flag for you to try: -J-Djruby.reflection=true

It may speed up startup slightly. Also, I wonder if the JVM you’re
running on supports the bootclasspath flag, which is where we saved a
lot of startup time. And there’s the class data sharing. Do you see the
following when you run java -X


-Xbootclasspath:<directories and zip/jar files separated by :>
set search path for bootstrap classes and
resources
-Xbootclasspath/a:<directories and zip/jar files separated by :>
append to end of bootstrap class path
-Xbootclasspath/p:<directories and zip/jar files separated by :>
prepend in front of bootstrap class path

-Xshare:off do not attempt to use shared class data
-Xshare:auto use shared class data if possible (default)
-Xshare:on require using shared class data, otherwise fail.

Result:
26 seconds for rails -d mysql blog1
42 seconds for db:create
45 seconds for db:migrate

So these numbers aren’t actually a whole lot different on MRI from JRuby
then? The Rails command is faster with MRI, but they’re all taking quite
a while to run.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Michèle Garoche wrote:

A JRuby flag for you to try: -J-Djruby.reflection=true
Test rails blog, db create, db migrate with JRuby and the reflection
flag to true:

Result:
29 seconds for rails -d mysql blog
46 seconds for db:create
49 seconds for db:migrate

As I suspected, not much improvement.

It may speed up startup slightly. Also, I wonder if the JVM you’re
running on supports the bootclasspath flag, which is where we saved a
lot of startup time. And there’s the class data sharing. Do you see
the following when you run java -X
Yes, I see those flags.

Ok, darn. That would have been a simple explanation for startup
slowness.

I’m very sorry, I had not understand correctly your query, those numbers
were for jruby 1.1.4.

Result:
10 seconds for rails -d mysql blog
15 seconds for db:create
14 seconds for db:migrate

Ok, so about 2-4x longer in JRuby. That’s unfortunate.

I did a little poking around on forums and blogs and it sounds like the
PPC Apple JDK is just slow in general. That’s not going to be easy for
us to work around, since we’re very dependent on the JVM doing a good
job optimizing. Maybe you could send back numbers for both JRuby and
Ruby running the following benchmark? If it’s the same performance ratio
as startup, we might simply be stuck with the situation as-is for now.

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) }
}

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Le 2 sept. 2008 à 20:42, Charles Oliver N. a écrit :

numbers were for jruby 1.1.4.
easy for us to work around, since we’re very dependent on the JVM
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) }
}
Test with ruby MRI:
ruby benchmarktest.rb
31.850000 0.570000 32.420000 ( 35.743777)
32.040000 0.560000 32.600000 ( 35.975186)
32.080000 0.600000 32.680000 ( 37.247626)
32.310000 0.690000 33.000000 ( 44.140337)
32.240000 0.660000 32.900000 ( 41.398945)

Test with JRuby:
jruby benchmarktest.rb
4.482000 0.000000 4.482000 ( 4.481732)
4.806000 0.000000 4.806000 ( 4.808206)
4.126000 0.000000 4.126000 ( 4.126475)
4.936000 0.000000 4.936000 ( 4.935951)
4.429000 0.000000 4.429000 ( 4.428669)

Test with JRuby and reflection flag to true:
jruby -J-Djruby.reflection=true benchmarktest.rb
9.463000 0.000000 9.463000 ( 9.461788)
9.150000 0.000000 9.150000 ( 9.152795)
9.034000 0.000000 9.034000 ( 9.033466)
9.041000 0.000000 9.041000 ( 9.041358)
9.063000 0.000000 9.063000 ( 9.063378)

Thanks for your patience.

Cheers,
Michèle
http://micmacfr.homeunix.org

Le 2 sept. 2008 à 19:41, Charles Oliver N. a écrit :

Mar sep 2 18:10:24 CEST 2008
and run the benchmarks?
1
Mar sep 2 18:48:45 CEST 2008
1
Mar sep 2 18:48:45 CEST 2008

Hmm, ok, so C Ruby is almost instantaneous for the “puts 1” test.
Of course there’s more we can do here but cold start on super-short
scripts will never approach C Ruby’s time.

A JRuby flag for you to try: -J-Djruby.reflection=true
Test rails blog, db create, db migrate with JRuby and the reflection
flag to true:
Mar sep 2 20:24:10 CEST 2008
create

Mar sep 2 20:24:39 CEST 2008
Mar sep 2 20:24:39 CEST 2008
(in /PortefeuillePartage/Ruby/09/blog)
Mar sep 2 20:25:26 CEST 2008
(in /PortefeuillePartage/Ruby/09/blog)
Mar sep 2 20:26:17 CEST 2008

Result:
29 seconds for rails -d mysql blog
46 seconds for db:create
49 seconds for db:migrate

-Xbootclasspath/a:<directories and zip/jar files separated by :>
                  append to end of bootstrap class path
-Xbootclasspath/p:<directories and zip/jar files separated by :>
                  prepend in front of bootstrap class path


-Xshare:off do not attempt to use shared class data
-Xshare:auto use shared class data if possible (default)
-Xshare:on require using shared class data, otherwise fail.
Yes, I see those flags.

Result: 26 seconds for rails -d mysql blog1
42 seconds for db:create
45 seconds for db:migrate

So these numbers aren’t actually a whole lot different on MRI from
JRuby then? The Rails command is faster with MRI, but they’re all
taking quite a while to run.
I’m very sorry, I had not understand correctly your query, those
numbers were for jruby 1.1.4.

Now the same test for ruby MRI:
Mar sep 2 20:14:14 CEST 2008
create

Mar sep 2 20:14:24 CEST 2008
Mar sep 2 20:14:24 CEST 2008
(in /PortefeuillePartage/Ruby/09/blog)
Mar sep 2 20:14:39 CEST 2008
(in /PortefeuillePartage/Ruby/09/blog)
Mar sep 2 20:14:53 CEST 2008

Result:
10 seconds for rails -d mysql blog
15 seconds for db:create
14 seconds for db:migrate

Cheers,
Michèle
http://micmacfr.homeunix.org