On Wed, Sep 5, 2012 at 12:16 PM, Richie Vos <ric
...@groupon.com> wrote:
> From my testing, one thing to look out for is the time between Rails spent
> overall on a request and the time Rails reports in the logs it worked on
> the request can be quite different. Specifically, rails doesn't account for
> time spent before the controller code runs (metals and so forth) as part of
> it's response time.
> We are using Tomcat, and when comparing the response times Rails said to
> what Tomcat said, we saw drastically different numbers. I recommend
> sticking a metal at the top of your middleware stack to get more accurate
> numbers. Something like:
> # app/metals/request_timer.rb
> class RequestTimer
> def initialize(app)
> @app = app
> end
> def call(env)
> begin
> rack_response = nil
> response_time = Benchmark.ms do
> rack_response = @app.call(env)
> end
> rack_response
> ensure
> Rails.logger.info("Request actually took: #{response_time.to_i}ms")
> # ActionController::Dispatcher usually does this, but we're outside
> of its
> # control here
> Rails.logger.flush if Rails.logger.respond_to?(:flush)
> end
> end
> end
> # config/application.rb
> module YourApplication
> class Application < Rails::Application
> #...
> config.middleware.insert(0, "RequestTimer")
> end
> end
> You can then move this middleware up and down the stack to find where
> time's being lost (change the insert location). This may help track down
> the JRuby-Rack missing time.
> You said you're only doing 1 request at a time, but if you're not, watch
> out for your config/database.yml's pool_size and wait_timeout settings.
> Those can drastically affect your performance if you're using threaded
> requests (eg config.threadsafe! and a threaded app server). This may help
> track down the extra ActiveRecord time.
> Does your massive amounts of memory usage stabilize over time? And what
> type of garbage/memory (PermGen?). Might be worth hooking up something like
> JConsole to track that one down.
> On Wed, Sep 5, 2012 at 12:46 PM, Andre Zelenkovas <li...@ruby-forum.com>wrote:
>> Hello
>> I have a typical CRUD Ruby on Rails app with a fairly complex model and
>> the performance in JRuby is 6 times slower than MRI considering median
>> response times. I'm running 30 minute tests with a single-threaded
>> client to ensure runtimes are warmed up. I've tried both Webrick,
>> warbler on JBoss and Torquebox, to no avail. I'm reaching out to the
>> forum hoping for some tips.
>> Issue/fact summary:
>> JRuby-Rack seems to take up to 150ms just to dispatch the request into
>> the controller.
>> ActiveRecord activity is much slower on JRuby (by a factor of 10
>> sometimes.)
>> JSON generation is actually faster in JRuby than MRI.
>> Tried jruby.compile.mode=FORCE and jruby.frameless.mode = true.
>> Frameless mode seems to improve performance to about 5%.
>> YAML serialization is slower than JSON serialization in JRuby but the
>> same in MRI.
>> JRuby runtimes are using massive amounts of memory (up to 40 MB of
>> garbage per request.)
>> I've tested with a single runtime in JRuby with 2 GB max heap and 512 MB
>> max perm size.
>> Any tips are appreciated.
>> Thanks
>> Andre
>> --
>> Posted via http://www.ruby-forum.com/.
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>> http://xircles.codehaus.org/manage_email