Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rack Middleware Should Only be Used in Development #172

Closed
yfeldblum opened this issue Sep 21, 2011 · 1 comment
Closed

Rack Middleware Should Only be Used in Development #172

yfeldblum opened this issue Sep 21, 2011 · 1 comment

Comments

@yfeldblum
Copy link

Rack Middleware Should Only be Used in Development, because it doesn't do much of anything in any environment except development.

Note that the real check for whether the Rack middleware is needed should actually be !Rails.configuration.cache_classes rather than Rails.env.development?. But I'm going to continue using "development" as shorthand....

In development, we want to recompile these files (or at least check them for recompilation) because they could need to be recompiled. But in test/production, the application's stylesheet files don't change. Neither do their dependencies, sub-dependencies, etc. In test/production, if the stylesheet files changed, it's because a new version of the application was deployed and so some of the code was most likely changed as well - in which case the application as a whole will be restarted anyway and the check for recompilation will be done in an initializer. And if the stylesheets' dependencies and sub-dependencies changed, it's because we re-ran bundle install with a newly-deployed version of the application.

Indeed, as Aaron Patterson pointed out, having that one extra middleware can subtly impact performance, especially on performance-critical requests. The reason is that the majority of each request will be spent in a situation where there is an extra frame on the stack, subtly impacting the GC. Obviously the effect is more pronounced if there are twice as many frames on the stack vs. if there is simply one more frame on the stack. But nevertheless test/production don't need the Rack middleware, and could see a subtle performance boost without it.

@nex3
Copy link
Contributor

nex3 commented Nov 24, 2011

I agree in principle, but in practice this is tricky. Currently, Sass will always re-compile if necessary on the first request, even in production. We can't make any changes that would break anyone who's relying on that behavior.

Since Sass is integrated directly into Rails 3.1, I think fixing this isn't worth the effort, so I'm closing it.

@nex3 nex3 closed this as completed Nov 24, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants