Given a dummy Rails app with large number of scaffold-generated objects (Code LOC: 18849) and hundred gems (sample taken from https://github.com/discourse/discourse/blob/master/Gemfile) tried to measure performance hit for static assets. Newelic in development mode helped to figure it out thoroughly.
The problem is a middleware responsible for Ruby classes reload slows serving static assets down. Profiling with Newrelic shows the following results (88% spent on Reloader middleware):

siege benchmark results (siege -b http://localhost:3000/assets/application.js):
Transaction rate: 2.60 trans/sec
Concurrency: 11.87
I tried to skip this middleware for static assets based on condition expression (correct me if I'm wrong) env['PATH_INFO'].include?(Rails.application.config.assets.prefix) the results suprised me a bit:

siege benchmark results (siege -b http://localhost:3000/assets/application.js):
Transaction rate: 16.13 trans/sec
Concurrency: 11.82
Having some change in application.js doesn't require rails server to restart, changes reloaded on-fly as usual, the difference is no callbacks chain and no clears dependencies for static assets anymore.
This change makes a diffference in development mode when serve static assets without Nginx. Please let me know what you think, patch is available as gist for a moment: https://gist.github.com/mikhailov/7e6d925044327a87db4f
Increase LOC from 18K to 27K followed by slowness of response for non-patched middleware. It seems the complexity is O(n) compare to O(1) for code with the patch.
Given a dummy Rails app with large number of scaffold-generated objects (Code LOC: 18849) and hundred gems (sample taken from https://github.com/discourse/discourse/blob/master/Gemfile) tried to measure performance hit for static assets. Newelic in development mode helped to figure it out thoroughly.
The problem is a middleware responsible for Ruby classes reload slows serving static assets down. Profiling with Newrelic shows the following results (88% spent on Reloader middleware):
siege benchmark results (siege -b http://localhost:3000/assets/application.js):
I tried to skip this middleware for static assets based on condition expression (correct me if I'm wrong) env['PATH_INFO'].include?(Rails.application.config.assets.prefix) the results suprised me a bit:
siege benchmark results (siege -b http://localhost:3000/assets/application.js):
Having some change in application.js doesn't require rails server to restart, changes reloaded on-fly as usual, the difference is no callbacks chain and no clears dependencies for static assets anymore.
This change makes a diffference in development mode when serve static assets without Nginx. Please let me know what you think, patch is available as gist for a moment: https://gist.github.com/mikhailov/7e6d925044327a87db4f
Increase LOC from 18K to 27K followed by slowness of response for non-patched middleware. It seems the complexity is O(n) compare to O(1) for code with the patch.