Rails, on development mode is SLOW. Very, very slow. I run Vista, and I set config.cache_classes = true
in development.rb
... But, it's still slow and I have to restart the server after I change my code.
Rails,在开发模式下是SLOW。非常非常慢。我运行Vista,并在development.rb中设置config.cache_classes = true ...但是,它仍然很慢,我必须在更改代码后重新启动服务器。
My coworker develops Rails on a Mac and sees similar slowness.
我的同事在Mac上开发Rails并看到类似的缓慢。
My development time slows down significantly because it takes minutes to test out code changes.
我的开发时间显着减慢,因为测试代码更改需要几分钟。
Is this as good as Rails development gets? Or am I missing something that'll make it fast and my life happy?
这和Rails开发一样好吗?或者我错过了一些能让它变得快速,生活幸福的东西?
11 个解决方案
#1
-13
Andrews-MacBook-Pro:Sites askegg$ rails test
Andrews-MacBook-Pro:Sites askegg$ cd test
Andrews-MacBook-Pro:test askegg$ ./script/generate model test
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/test.rb
create test/unit/test_test.rb
create test/fixtures/tests.yml
create db/migrate
create db/migrate/20090812005217_create_tests.rb
Andrews-MacBook-Pro:test askegg$ ./script/performance/benchmarker 1000000 Test.new
user system total real
#1 25.140000 0.200000 25.340000 ( 25.549605)
Hmmm. 25 seconds to instantiate 1 million objects in development mode on a macbook pro with 12 other programs loaded. Seems OK to me.
嗯。在加载了12个其他程序的macbook pro上,在开发模式下实例化100万个对象需要25秒。对我来说似乎没问题。
#2
26
The rails-dev-boost plugin speeds up Rails development mode. I was having the same problem, and this plugin made my application very snappy (compared to few second load per page). It will run at similar speed as production!
rails-dev-boost插件加速了Rails开发模式。我遇到了同样的问题,这个插件让我的应用程序非常活泼(相比之下,每页只有少量第二次加载)。它将以与生产类似的速度运行!
http://github.com/thedarkone/rails-dev-boost
http://github.com/thedarkone/rails-dev-boost
To install it:
要安装它:
script/plugin install git://github.com/thedarkone/rails-dev-boost
#3
7
Are you talking about:
你在说:
-
Slowness starting the app (like running script/server)?
缓慢启动应用程序(如运行脚本/服务器)?
If it's the server startup, then what server are you using? From my experience webrick is slower than mongrel is slower than thin. Passenger really is the most efficient for local development (though I've never tried to get it running on windows).
如果它是服务器启动,那么你使用的服务器是什么?根据我的经验,webrick慢于mongrel慢于瘦。对于本地开发来说,乘客确实是最有效的(尽管我从来没有试过让它在Windows上运行)。
-
Slow page responses from hitting the dev server?
点击开发服务器的页面响应缓慢?
This could be inefficient database queries, too much computation in the view that could be reworked, etc. If it's running ok in production this is probably not your issue. However, the web server you run will make a difference in your speed locally as well. I think the same order for startup applies for execution as well.
这可能是效率低下的数据库查询,视图中可能会重新编写的计算量过多等。如果它在生产中运行正常,这可能不是您的问题。但是,您运行的Web服务器也会在本地产生差异。我认为启动的相同顺序也适用于执行。
-
Rake tasks taking forever to start?
耙任务永远开始?
I've had this issue as well. If you have a large project with lots of plugins (which means lots of initialization that needs to run), it can take a while to ramp up the rails environment. There are things that will probably speed it up, but there's no silver bullet. Make sure you don't have any plugins installed you are no longer using, take a careful look at your environment and initializers to make sure it's in good shape, etc.
我也遇到过这个问题。如果你有一个包含大量插件的大型项目(这意味着需要运行大量的初始化),那么可能需要一段时间来提升rails环境。有些东西可能会加速它,但没有银弹。确保您没有安装任何不再使用的插件,请仔细查看您的环境和初始化程序,以确保其处于良好状态等。
Bottom line being, stating "Rails is slow in development" doesn't really pinpoint the problem. If you can clarify what is slow, then you can get specific help to speed it up. I've worked on lots of pretty large projects that have suffered from performance issues in development as well as production. I've never had a situation that couldn't be improved if given the right attention. Pinpoint the problem and you can usually diagnose a better solution to speed things up.
最重要的是,说“Rails开发缓慢”并没有真正指出问题所在。如果您可以澄清什么是缓慢的,那么您可以获得特定的帮助来加快速度。我曾参与许多大型项目,这些项目在开发和生产方面都遇到了性能问题。如果给予正确的关注,我从未遇到过无法改善的情况。找出问题所在,您通常可以诊断出更好的解决方案来加快速度。
#4
3
faster_require
faster_require
http://github.com/rdp/faster_require
http://github.com/rdp/faster_require
might help
可能有帮助
speeds mine up significantly on windows
在窗户上显着提高了速度
also spork can be used with jruby to speed up unit tests
spork可以与jruby一起使用以加速单元测试
http://github.com/rdp/spork
#5
2
I have been running into the same issues. My app, in dev mode, keeps getting slower and slower. As an example, I create a new controller with a new action:
我一直在遇到同样的问题。在开发模式下,我的应用程序变得越来越慢。举个例子,我创建了一个带有新动作的新控制器:
def test
render :text => 'nothing'
end
In dev mode, this takes between 12-15 seconds to complete (when requesting via FF and IE). I am using mongrel (not clustered). I am on a macbook pro.
在开发模式下,这需要12-15秒才能完成(通过FF和IE请求时)。我正在使用mongrel(不是群集)。我在macbook pro上。
In prod mode this takes ~130ms.
在产品模式下,这需要约130毫秒。
There has to be a way to find out which files are being loaded per request (basic profiling) so I can try to figure out what is going on and where the bottleneck is.
必须有一种方法可以找出每个请求正在加载哪些文件(基本概要分析),这样我就可以尝试弄清楚发生了什么以及瓶颈在哪里。
FF Firebug Net shows that most of the time (11-14 seconds) are spent in WAIT state.
FF Firebug Net显示大部分时间(11-14秒)都处于WAIT状态。
Console shows:
控制台显示:
Completed in 2ms (View: 0, DB: 152)
.
。
Any ideas?
有任何想法吗?
#6
1
I arrived at this post trying to understand why I was seeing so much time between requests in development mode.
我到达这篇文章试图理解为什么我在开发模式下看到这么多时间请求。
I'm working on a modest-size application - 4000 LOC, 113 classes - and slumming it on a slow machine. More than 9/10ths of the time between requests happens while loading model code.
我正在开发一个中等规模的应用程序--4000 LOC,113个类 - 并在慢速机器上进行贫民窟。加载模型代码时,请求之间的时间超过了9/10。
Predictably, config.cache_classes = true speeds things up considerably.
可以预见的是,config.cache_classes = true可以大大提高速度。
#7
1
The best way to make development faster is installing gem
named active_reload
.
使开发更快的最佳方法是安装名为active_reload的gem。
To install this gem
, you can enter command,
要安装此gem,您可以输入命令,
gem install active_reload
gem install active_reload
And, in your rails project gemfile, add
并且,在你的rails项目gemfile中,添加
gem 'active_reload'
gem'active_reload'
Then, restart your server and you will find development mode much faster than it used to be.
然后,重新启动服务器,您将发现开发模式比以前快得多。
#8
0
I'm assuming your requests are taking seconds? (Otherwise you probably wouldn't have noticed). It has always been fast for me. Especially since I started using sinatra instead of rails :D
我假设你的请求需要几秒钟? (否则你可能不会注意到)。它对我来说一直很快。特别是因为我开始使用sinatra而不是rails:D
Oh, and I forgot to mention - I used to run rails locally, but I currently use a virtual centos server with VMWare. Both were fast
哦,我忘了提 - 我以前在本地运行rails,但我目前使用VMWare的虚拟centos服务器。两者都很快
#9
0
I set config.cache_classes = true in development.rb. It's still slow and I have to restart the server after I change my code.
我在development.rb中设置了config.cache_classes = true。它仍然很慢,我必须在更改代码后重新启动服务器。
You should not use that cache in development (especially if it is still slow when using it). Having to restart the server all the time will slow you down even more.
您不应该在开发中使用该缓存(特别是在使用它时仍然很慢)。必须始终重新启动服务器会使您的速度更慢。
Are you sure Ruby itself is slow? Not for example some DB access code that you run? Is a simple "Hello World" demo equally slow?
你确定Ruby本身很慢吗?例如,您运行的某些数据库访问代码?简单的“Hello World”演示同样慢吗?
And how slow are we talking? Page load times more than 10 seconds?
我们说话的速度有多慢?页面加载时间超过10秒?
#10
0
Setting config.cache_classes = true in development.rb will always speed up larger apps in dev mode. I like to have this line in my dev environment:
在development.rb中设置config.cache_classes = true将始终在开发模式下加速更大的应用程序。我喜欢在我的开发环境中使用这一行:
config.cache_classes = ENV["CACHE_CLASSES"] ? ENV["CACHE_CLASSES"] == "true" : false
Then you can start your server with:
然后你可以启动你的服务器:
CACHE_CLASSES=true script/server
when you want faster response time and don't mind that the classes don't reload on each request.
当你想要更快的响应时间并且不介意这些类不会在每个请求上重新加载时。
#11
0
If you're using versions 3.0 or 3.1 of Rails you can use active reload to speed up page load times condsiderably. It was rolled into Rails 3.2.
如果您使用的是Rails 3.0或3.1版,则可以使用主动重新加载来加速页面加载时间。它被卷入Rails 3.2。
#1
-13
Andrews-MacBook-Pro:Sites askegg$ rails test
Andrews-MacBook-Pro:Sites askegg$ cd test
Andrews-MacBook-Pro:test askegg$ ./script/generate model test
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/test.rb
create test/unit/test_test.rb
create test/fixtures/tests.yml
create db/migrate
create db/migrate/20090812005217_create_tests.rb
Andrews-MacBook-Pro:test askegg$ ./script/performance/benchmarker 1000000 Test.new
user system total real
#1 25.140000 0.200000 25.340000 ( 25.549605)
Hmmm. 25 seconds to instantiate 1 million objects in development mode on a macbook pro with 12 other programs loaded. Seems OK to me.
嗯。在加载了12个其他程序的macbook pro上,在开发模式下实例化100万个对象需要25秒。对我来说似乎没问题。
#2
26
The rails-dev-boost plugin speeds up Rails development mode. I was having the same problem, and this plugin made my application very snappy (compared to few second load per page). It will run at similar speed as production!
rails-dev-boost插件加速了Rails开发模式。我遇到了同样的问题,这个插件让我的应用程序非常活泼(相比之下,每页只有少量第二次加载)。它将以与生产类似的速度运行!
http://github.com/thedarkone/rails-dev-boost
http://github.com/thedarkone/rails-dev-boost
To install it:
要安装它:
script/plugin install git://github.com/thedarkone/rails-dev-boost
#3
7
Are you talking about:
你在说:
-
Slowness starting the app (like running script/server)?
缓慢启动应用程序(如运行脚本/服务器)?
If it's the server startup, then what server are you using? From my experience webrick is slower than mongrel is slower than thin. Passenger really is the most efficient for local development (though I've never tried to get it running on windows).
如果它是服务器启动,那么你使用的服务器是什么?根据我的经验,webrick慢于mongrel慢于瘦。对于本地开发来说,乘客确实是最有效的(尽管我从来没有试过让它在Windows上运行)。
-
Slow page responses from hitting the dev server?
点击开发服务器的页面响应缓慢?
This could be inefficient database queries, too much computation in the view that could be reworked, etc. If it's running ok in production this is probably not your issue. However, the web server you run will make a difference in your speed locally as well. I think the same order for startup applies for execution as well.
这可能是效率低下的数据库查询,视图中可能会重新编写的计算量过多等。如果它在生产中运行正常,这可能不是您的问题。但是,您运行的Web服务器也会在本地产生差异。我认为启动的相同顺序也适用于执行。
-
Rake tasks taking forever to start?
耙任务永远开始?
I've had this issue as well. If you have a large project with lots of plugins (which means lots of initialization that needs to run), it can take a while to ramp up the rails environment. There are things that will probably speed it up, but there's no silver bullet. Make sure you don't have any plugins installed you are no longer using, take a careful look at your environment and initializers to make sure it's in good shape, etc.
我也遇到过这个问题。如果你有一个包含大量插件的大型项目(这意味着需要运行大量的初始化),那么可能需要一段时间来提升rails环境。有些东西可能会加速它,但没有银弹。确保您没有安装任何不再使用的插件,请仔细查看您的环境和初始化程序,以确保其处于良好状态等。
Bottom line being, stating "Rails is slow in development" doesn't really pinpoint the problem. If you can clarify what is slow, then you can get specific help to speed it up. I've worked on lots of pretty large projects that have suffered from performance issues in development as well as production. I've never had a situation that couldn't be improved if given the right attention. Pinpoint the problem and you can usually diagnose a better solution to speed things up.
最重要的是,说“Rails开发缓慢”并没有真正指出问题所在。如果您可以澄清什么是缓慢的,那么您可以获得特定的帮助来加快速度。我曾参与许多大型项目,这些项目在开发和生产方面都遇到了性能问题。如果给予正确的关注,我从未遇到过无法改善的情况。找出问题所在,您通常可以诊断出更好的解决方案来加快速度。
#4
3
faster_require
faster_require
http://github.com/rdp/faster_require
http://github.com/rdp/faster_require
might help
可能有帮助
speeds mine up significantly on windows
在窗户上显着提高了速度
also spork can be used with jruby to speed up unit tests
spork可以与jruby一起使用以加速单元测试
http://github.com/rdp/spork
#5
2
I have been running into the same issues. My app, in dev mode, keeps getting slower and slower. As an example, I create a new controller with a new action:
我一直在遇到同样的问题。在开发模式下,我的应用程序变得越来越慢。举个例子,我创建了一个带有新动作的新控制器:
def test
render :text => 'nothing'
end
In dev mode, this takes between 12-15 seconds to complete (when requesting via FF and IE). I am using mongrel (not clustered). I am on a macbook pro.
在开发模式下,这需要12-15秒才能完成(通过FF和IE请求时)。我正在使用mongrel(不是群集)。我在macbook pro上。
In prod mode this takes ~130ms.
在产品模式下,这需要约130毫秒。
There has to be a way to find out which files are being loaded per request (basic profiling) so I can try to figure out what is going on and where the bottleneck is.
必须有一种方法可以找出每个请求正在加载哪些文件(基本概要分析),这样我就可以尝试弄清楚发生了什么以及瓶颈在哪里。
FF Firebug Net shows that most of the time (11-14 seconds) are spent in WAIT state.
FF Firebug Net显示大部分时间(11-14秒)都处于WAIT状态。
Console shows:
控制台显示:
Completed in 2ms (View: 0, DB: 152)
.
。
Any ideas?
有任何想法吗?
#6
1
I arrived at this post trying to understand why I was seeing so much time between requests in development mode.
我到达这篇文章试图理解为什么我在开发模式下看到这么多时间请求。
I'm working on a modest-size application - 4000 LOC, 113 classes - and slumming it on a slow machine. More than 9/10ths of the time between requests happens while loading model code.
我正在开发一个中等规模的应用程序--4000 LOC,113个类 - 并在慢速机器上进行贫民窟。加载模型代码时,请求之间的时间超过了9/10。
Predictably, config.cache_classes = true speeds things up considerably.
可以预见的是,config.cache_classes = true可以大大提高速度。
#7
1
The best way to make development faster is installing gem
named active_reload
.
使开发更快的最佳方法是安装名为active_reload的gem。
To install this gem
, you can enter command,
要安装此gem,您可以输入命令,
gem install active_reload
gem install active_reload
And, in your rails project gemfile, add
并且,在你的rails项目gemfile中,添加
gem 'active_reload'
gem'active_reload'
Then, restart your server and you will find development mode much faster than it used to be.
然后,重新启动服务器,您将发现开发模式比以前快得多。
#8
0
I'm assuming your requests are taking seconds? (Otherwise you probably wouldn't have noticed). It has always been fast for me. Especially since I started using sinatra instead of rails :D
我假设你的请求需要几秒钟? (否则你可能不会注意到)。它对我来说一直很快。特别是因为我开始使用sinatra而不是rails:D
Oh, and I forgot to mention - I used to run rails locally, but I currently use a virtual centos server with VMWare. Both were fast
哦,我忘了提 - 我以前在本地运行rails,但我目前使用VMWare的虚拟centos服务器。两者都很快
#9
0
I set config.cache_classes = true in development.rb. It's still slow and I have to restart the server after I change my code.
我在development.rb中设置了config.cache_classes = true。它仍然很慢,我必须在更改代码后重新启动服务器。
You should not use that cache in development (especially if it is still slow when using it). Having to restart the server all the time will slow you down even more.
您不应该在开发中使用该缓存(特别是在使用它时仍然很慢)。必须始终重新启动服务器会使您的速度更慢。
Are you sure Ruby itself is slow? Not for example some DB access code that you run? Is a simple "Hello World" demo equally slow?
你确定Ruby本身很慢吗?例如,您运行的某些数据库访问代码?简单的“Hello World”演示同样慢吗?
And how slow are we talking? Page load times more than 10 seconds?
我们说话的速度有多慢?页面加载时间超过10秒?
#10
0
Setting config.cache_classes = true in development.rb will always speed up larger apps in dev mode. I like to have this line in my dev environment:
在development.rb中设置config.cache_classes = true将始终在开发模式下加速更大的应用程序。我喜欢在我的开发环境中使用这一行:
config.cache_classes = ENV["CACHE_CLASSES"] ? ENV["CACHE_CLASSES"] == "true" : false
Then you can start your server with:
然后你可以启动你的服务器:
CACHE_CLASSES=true script/server
when you want faster response time and don't mind that the classes don't reload on each request.
当你想要更快的响应时间并且不介意这些类不会在每个请求上重新加载时。
#11
0
If you're using versions 3.0 or 3.1 of Rails you can use active reload to speed up page load times condsiderably. It was rolled into Rails 3.2.
如果您使用的是Rails 3.0或3.1版,则可以使用主动重新加载来加速页面加载时间。它被卷入Rails 3.2。