开发者

How to reduce ratio of user time to sys time for Rails 3 commands in Linux

开发者 https://www.devze.com 2023-02-17 19:08 出处:网络
I\'m currently running Rails 3 on Ubuntu Linux and I\'m getting what seems like really long response times for simple commands.For instance if I call db:rollback to drops a tiny table of 4 columns and

I'm currently running Rails 3 on Ubuntu Linux and I'm getting what seems like really long response times for simple commands. For instance if I call db:rollback to drops a tiny table of 4 columns and 0 rows takes ~30 seconds.

paul@paul-laptop:~/rails_projects/foglift$ time rake db:rollback
(in /home/paul/rails_projects/foglift)
==  CreateResults: reverting ==================================================
-- drop_table(:results)
   -> 0.0013s
==  CreateResults: reverted (0.0014s) =========================================


real    0m27.946s
user    0m26.570s
sys     0m1.284s

The high ratio of User time开发者_开发知识库 to Sys time is what's bothering me. Is there away to diagnose or troubleshoot this?

Any help would be most appreciated.

Thanks! Paul


You really won't be able to change this very much. This is a result of using an interpreted language and a powerful/flexible framework for web development.

When you run the command the ruby interpreter has to be loaded along with the rails environment and your application before it can run the rollback. It is similar to starting up the Rails server and then running the rollback.

This may be painful when building, but there are advantages as well. Your migrations can contain logic utilizing classes from your app to make the right decisions of how to execute the migrations. Long term maintainability is by far the greater good here.

Also, DB models usually don't change frequently, the power is more important than super speed.

0

精彩评论

暂无评论...
验证码 换一张
取 消