Ruby on Rails Sunday, January 2, 2011

Using ruby-prof I captured the CPU time of the startup of my 3.0.3
Rails app (https://gist.github.com/762764):

ruby-1.8.7-p330 (Total CPU: 8.573606)

%self total self wait child calls name
20.99 8.50 1.80 0.00 8.49 1898 Kernel#require
10.16 0.87 0.87 0.00 0.00 17128 Module#constants
6.71 0.82 0.58 0.00 0.25 3691 Array#select
6.22 8.00 0.53 0.00 7.95 58841 Array#each
4.16 1.85 0.36 0.00 1.66 14214 Array#map

ruby-1.9.2-p136 (Total CPU 16.794391)

%self total self wait child calls name
39.93 16.47 6.71 0.00 16.46 1904 Kernel#require
3.85 2.51 0.65 0.00 2.23 14252 Array#map
3.61 0.61 0.61 0.00 0.00 594435 Symbol#to_s
3.23 15.68 0.54 0.00 15.59 41201 Array#each
2.38 0.40 0.40 0.00 0.00 2855 Module#constants

Looks like require is 1/2 speed and that evaluating array blocks(?)
has slowed down considerably. I saw chatter about require being an
issue in 1.9.1 but the issue was closed.

Doesn't seem to be a Rails issue as much as a Ruby issue.

I have the same issue wrt using autotest. My tests take 3x the time to
run with 1.9.2.

-cpr


On Jan 2, 8:17 am, Colin Law <clan...@googlemail.com> wrote:
> On 2 January 2011 01:57, gezope <gez...@gmail.com> wrote:
>
> > Hi Colin and all,
>
> > I had exactly the same here: 1GB RAM, Ubuntu, RVM with Ruby1.9 and
> > Rails - and it's terribly slow comparing with the elder Ruby and Rails
> > combo. Did you figured out anything?
>
> > Also how did you speed up your server running? I already use Thin
> > locally, and found it"s faster then Webrick, but still have to wait a
> > lot after loading. Any trick?
>
> I use mongrel.  The server startup time is not really an issue for me
> in development as starting the server is not something that happens
> repeatedly.  I don't know whether the response time once the server is
> up and running is significantly different between 1.9.2 and 1.8.7, I
> had not noticed an obvious difference.  It is the test cycle time
> particularly that is a pain.  I use autotest and when I make a change
> I have to wait while the tests get underway, which is tedious.
>
> Colin
>
>
>
>
>
>
>
>
>
> > Thanks,
> > Zoli
>
> > On 2010 dec. 30, 20:32, Conrad Taylor <conra...@gmail.com> wrote:
> >> On Thu, Dec 30, 2010 at 7:59 AM, Colin Law <clan...@googlemail.com> wrote:
> >> > On 29 December 2010 23:18, Conrad Taylor <conra...@gmail.com> wrote:
> >> > > ...
> >> > > Colin, do you have a sample application?  Next, it really depends
> >> > > on your overall system and Rails app configuration.  For example,
> >> > > if you don't have enough RAM, your system move data from memory
> >> > > to the disk and vice-versa.  This is a huge performance hit.  Can you
> >> > > provide more information?
>
> >> > I have 1GByte RAM and while running the test it shows less than half
> >> > used and the disk is not rattling.  The processor shows 100%
> >> > utilisation whilst the test is running, with rake being the process
> >> > using most of it.
>
> >> > I have tried making a new rails 3.0.3 app
> >> > rails new testruby
> >> > then using rvm to switch between 1.8.7 p302 and 1.9.2 p136
>
> >> > On each ruby I ran
> >> > time rake db:migrate
> >> > a couple of times to let the disk cache settle out then for 1.8.7 I got
> >> > real    0m2.111s
> >> > user    0m1.804s
> >> > sys     0m0.220s
>
> >> > and on 1.9.2
> >> > real    0m4.098s
> >> > user    0m3.512s
> >> > sys     0m0.424s
>
> >> > I also tried rake test and got, on 1.8.7
> >> > real    0m3.615s
> >> > user    0m3.104s
> >> > sys     0m0.316s
>
> >> > and on 1.9.2
> >> > real    0m6.487s
> >> > user    0m5.320s
> >> > sys     0m0.684s
>
> >> > It seems as if 1.9.2 takes about twice as long for some reason.
>
> >> > Colin
>
> >> Colin, do you have a test case that I can run locally?  Or can you
> >> tell me the specifics?  Next, I'm not sure that 1 GB RAM is sufficient
> >> because other resources outside the actual application uses the RAM.
> >> For example, on my slower machine, iMac, with 4 GB Ram, the RAM
> >> utilization for some common applications are as follows:
>
> >> Safari 5       ~554.0 MB
> >> Textmate      ~96.1 MB
> >> Terminal       ~14.0 MB
> >> Chrome        ~199.6 MB
> >> Firefox         ~128.2 MB
> >> and so on
>
> >> Note:  The above doesn't include any of the OS specific processes but
> >> you can see that this adds up.  Also, most modern OS will reserve RAM
> >> for its use that cannot be used by the end user.  Just something to keep
> >> in mind.
>
> >> Lastly, in regards to running spec, I tend to use Ruby Spork gem because
> >> anytime you do 'rake spec', the Rails framework needs to be loaded before
> >> the application specific code can be executed.  This is also true when
> >> running
> >> 'rake db:migrate'
>
> >> Good luck,
>
> >> -Conrad
>
> >> > --
> >> > You received this message because you are subscribed to the Google Groups
> >> > "Ruby on Rails: Talk" group.
> >> > To post to this group, send email to rubyonrails-talk@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >> > rubyonrails-talk+unsubscribe@googlegroups.com<rubyonrails-talk%2Bunsubscrib e@googlegroups.com>
> >> > .
> >> > For more options, visit this group at
> >> >http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> > To post to this group, send email to rubyonrails-talk@googlegroups.com.
> > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment