[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

why does ruby load rails so slow?

Roger Pack

5/28/2009 1:52:00 PM

Question. Currently with rails startup time in linux for me is like 6s,
in windows like...20s, but regardless, anybody know just why this is
taking so long (I'm pretty sure it's cpu bound--curious if anyone's
investigated this).
Anyone know any tricks to load things quicker?
Thanks much.
-=r
--
Posted via http://www.ruby-....

8 Answers

pjb

5/28/2009 2:18:00 PM

0

Roger Pack <rogerpack2005@gmail.com> writes:

> Question. Currently with rails startup time in linux for me is like 6s,
> in windows like...20s, but regardless, anybody know just why this is
> taking so long (I'm pretty sure it's cpu bound--curious if anyone's
> investigated this).
> Anyone know any tricks to load things quicker?

There are two tricks:

- compile each source file into a "binary" fast loading file, and then
load them.

- load everything, then save the memory image. Next time, boot ruby
with that saved memory image, instead of an empty one.


There's also a third option:

- compile the program to a native executable.


Ooops! These options are not available to Matzacred Lisp, only in
implementations of Common Lisp, Scheme, Smalltalk, etc.



Well, theorically there's nothing that would prevent you to implement
either option in Ruby, but the fact that it's written in C instead of
Ruby. If it was written in Ruby, as a Ruby programmer you could do
something about it. Otherwise you'll have to find a C programmer and
motivate him to work on it...

There's already a Ruby parser written in Ruby, perhaps it would be
time to implement a Ruby compiler in Ruby.

--
__Pascal Bourguignon__

Gregory Brown

5/28/2009 2:30:00 PM

0

On Thu, May 28, 2009 at 9:52 AM, Roger Pack <rogerpack2005@gmail.com> wrote:
> Question. Currently with rails startup time in linux for me is like 6s,
> in windows like...20s, but regardless, anybody know just why this is
> taking so long (I'm pretty sure it's cpu bound--curious if anyone's
> investigated this).
> Anyone know any tricks to load things quicker?

Probably a better question for the Rails list. But...

Are you talking about a bare rails app, or something with a bunch of
plugins and gems being loaded?
You should look at what your plugins are doing, they may churn heavily
at startup if they're loading lots of things.

-greg

Brian Candler

5/28/2009 3:58:00 PM

0

Roger Pack wrote:
> Question. Currently with rails startup time in linux for me is like 6s,
> in windows like...20s, but regardless, anybody know just why this is
> taking so long (I'm pretty sure it's cpu bound--curious if anyone's
> investigated this).
> Anyone know any tricks to load things quicker?

You could try this, which I knocked together last week:
http://github.com/candler...

It's for Linux only. Basically, it starts a Ruby interpreter and loads
in all the libraries demanded by your application (gems and all, if
they're declared in config/environment.rb). Then each time you want a
new Rails process, you can just fork the preloaded one, using a slightly
different command to normal:

frake # run tests
fautotest # background testing
fconsole # interactive console
fruby script/server # web server

I find it speeds things up hugely on my old Thinkpad X30 laptop.

Regards,

Brian.
--
Posted via http://www.ruby-....

Roger Pack

5/28/2009 4:51:00 PM

0

> I find it speeds things up hugely on my old Thinkpad X30 laptop.

Man I wish I'd had that back when I was using my old macbook PPC :)

-=r
--
Posted via http://www.ruby-....

Luis Lavena

5/28/2009 5:22:00 PM

0

On May 28, 10:52 am, Roger Pack <rogerpack2...@gmail.com> wrote:
> Question. Currently with rails startup time in linux for me is like 6s,
> in windows like...20s, but regardless, anybody know just why this is
> taking so long (I'm pretty sure it's cpu bound--curious if anyone's
> investigated this).
> Anyone know any tricks to load things quicker?
> Thanks much.

There is a huge IO problem with Ruby on how deal with Windows API IO
stuff.

I did ran some test between bare C doing IO with lot of files and
folders and compare it with ruby. There are so many functions called
just to reach the native API that make things slow.

Don't have to much time now to invest on fixing this, sorry.

--
Luis Lavena

Roger Pack

5/28/2009 6:22:00 PM

0


> I did ran some test between bare C doing IO with lot of files and
> folders and compare it with ruby. There are so many functions called
> just to reach the native API that make things slow.
>
> Don't have to much time now to invest on fixing this, sorry.

Oh I wasn't complaining about the speed on windows (though it is
slower). I was mostly wondering about ruby itself being so slow to load
rails :)

-=r
--
Posted via http://www.ruby-....

Charles Oliver Nutter

5/28/2009 7:23:00 PM

0

Roger Pack wrote:
> Question. Currently with rails startup time in linux for me is like 6s,
> in windows like...20s, but regardless, anybody know just why this is
> taking so long (I'm pretty sure it's cpu bound--curious if anyone's
> investigated this).
> Anyone know any tricks to load things quicker?
> Thanks much.

One reason I found was that things like script/console actually start
rails *twice*...once to boot the console script, and then another time
to spin up a new Ruby process running IRB.

I filed a bug on it against Rails, but I don't think it's been accepted yet.

- Charlie

Brian Candler

5/28/2009 7:33:00 PM

0

Roger Pack wrote:
>
>> I did ran some test between bare C doing IO with lot of files and
>> folders and compare it with ruby. There are so many functions called
>> just to reach the native API that make things slow.
>>
>> Don't have to much time now to invest on fixing this, sorry.
>
> Oh I wasn't complaining about the speed on windows (though it is
> slower). I was mostly wondering about ruby itself being so slow to load
> rails :)

It's mainly because there there's so darn much of it (try 'puts
$LOADED_FEATURES' from within script/console)
--
Posted via http://www.ruby-....