0

The problem

All of the sudden my rails app started to take about 60 seconds serving the initial request and sequential requests if something was changed in assets.

What did I try

There is a lot of answers on SO regarding "rails, render, slow", but none of them helped, because problem seems to be in different area.

Then I tried to rollback gem versions to older point, where this problem didn't exist. No luck. I didn't update anything in the system(rvm, homebrew), so there was nothing to rollback to.

Then I installed ruby-prof profiler and saw that rails spent all the time executing V8::C::String#Utf8Value, but I can't get anything from it.

Diagnostic info

I use OSX Mavericks.

server log:

Started GET "/" for 127.0.0.1 at 2014-04-08 05:30:49 +0200 Processing by HomeController#index as HTML User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1 Rendered home/index.html.erb within layouts/application (64211.8ms) Completed 200 OK in 64248ms (Views: 64218.0ms | ActiveRecord: 2.1ms)

profiler log(scroll horizontally):

 %total   %self      total       self       wait      child            calls    Name
--------------------------------------------------------------------------------
                     61.042      0.000      0.000     61.042              2/2      V8::Conversion::Fundamental#to_ruby
  87.50%   0.00%     61.042      0.000      0.000     61.042                2      V8::Conversion::NativeString#to_ruby
                     61.042     61.042      0.000      0.000              2/2      V8::C::String#Utf8Value
--------------------------------------------------------------------------------
                     61.042     61.042      0.000      0.000              2/2      V8::Conversion::NativeString#to_ruby
  87.50%  87.50%     61.042     61.042      0.000      0.000                2      V8::C::String#Utf8Value
--------------------------------------------------------------------------------
                      8.528      0.000      0.000      8.528              4/4      Proc#call
  12.22%   0.00%      8.528      0.000      0.000      8.528                4      V8::Error::Try#try
                      8.528      0.000      0.000      8.528              4/4      <Module::V8::C>#TryCatch
--------------------------------------------------------------------------------
Anri
  • 6,175
  • 3
  • 37
  • 61
  • ok, so putting `config.assets.js_compressor = nil` in `development.rb` resolves this issue obviously. For production it's not so important since it only increases deploy duration a bit. But still.. weird. Or maybe it is normal for rails, and I just reached critical mass of assets number. – Anri Apr 08 '14 at 04:20
  • Might be the server performance is degraded.If you are looking to speed up the server then i would say to prefer this gem https://github.com/thedarkone/rails-dev-boost – Pavan Apr 08 '14 at 04:44
  • @Pavan tried, it's not that. – Anri Apr 08 '14 at 04:47
  • This seems to be an answer http://stackoverflow.com/questions/9573818/rubyracer-v8-binding-for-ruby-performs-really-slow not very promising though - string copy between ruby and v8 is slow. – Anri Apr 08 '14 at 04:47
  • Its just a tip.Anyways you got your answer right. – Pavan Apr 08 '14 at 04:51

0 Answers0