应该是一个简单的渲染几乎需要一分钟

时间:2014-09-19 15:35:54

标签: ruby-on-rails performance ruby-on-rails-4 strace

我在我的开发环境中使用passenger start,但thinwebbrickpuma具有相同的结果。在运行Ubuntu 14.04的开发机器上,这个问题似乎也是一致的。在制作中,我根本没有这个问题。 Ruby版本为2.1.32.1.2(同时尝试过)。使用Rails 4.1.6(并尝试了4.1.5)。

正在呈现的登录页面相当简单和小巧。只是一个用于设计会话控制器以登录的表单。我运行strace passenger start以查看永远需要的内容。关于可能导致这种情况的任何想法?

请求缓慢

Started GET "/users/sign_in" for 10.0.2.2 at 2014-09-19 11:26:24 -0400
Processing by Devise::SessionsController#new as HTML
"", 8192)                       = 0
sched_yield()                           = 0
close(9)                                = 0
socket(PF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 9
fcntl(9, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
fstat(9, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
fstat(9, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
connect(9, {sa_family=AF_INET, sin_port=htons(3000), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
fstat(9, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
fstat(9, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
fstat(9, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
read(9,   Rendered devise/sessions/new.html.erb within layouts/application (52237.4ms)
  Rendered layouts/_navigation_links.html.erb (1.5ms)
  Rendered layouts/_navigation.html.erb (2.6ms)
  Rendered layouts/_messages.html.erb (0.2ms)
Completed 200 OK in 52250ms (Views: 52246.2ms | ActiveRecord: 0.0ms)
浏览器上的

F5,它会快速响应

Started GET "/users/sign_in" for 10.0.2.2 at 2014-09-19 11:27:35 -0400
Processing by Devise::SessionsController#new as HTML
  Rendered devise/sessions/new.html.erb within layouts/application (3.7ms)
  Rendered layouts/_navigation_links.html.erb (0.7ms)
  Rendered layouts/_navigation.html.erb (1.4ms)
  Rendered layouts/_messages.html.erb (0.2ms)
Completed 200 OK in 852ms (Views: 849.3ms | ActiveRecord: 0.0ms)
浏览器上的

F5并且它再次缓慢响应

Started GET "/users/sign_in" for 10.0.2.2 at 2014-09-19 11:27:40 -0400
Processing by Devise::SessionsController#new as HTML
"", 8192)                       = 0
close(9)                                = 0
socket(PF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 9
fcntl(9, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
fstat(9, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
fstat(9, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
connect(9, {sa_family=AF_INET, sin_port=htons(3000), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
fstat(9, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
fstat(9, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
fstat(9, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
read(9,   Rendered devise/sessions/new.html.erb within layouts/application (52214.5ms)
  Rendered layouts/_navigation_links.html.erb (2.0ms)
  Rendered layouts/_navigation.html.erb (3.6ms)
  Rendered layouts/_messages.html.erb (0.1ms)
Completed 200 OK in 53057ms (Views: 53053.3ms | ActiveRecord: 0.0ms)
浏览器上的

F5,它会再次快速响应

Started GET "/users/sign_in" for 10.0.2.2 at 2014-09-19 11:29:30 -0400
Processing by Devise::SessionsController#new as HTML
  Rendered devise/sessions/new.html.erb within layouts/application (3.1ms)
  Rendered layouts/_navigation_links.html.erb (0.4ms)
  Rendered layouts/_navigation.html.erb (1.1ms)
  Rendered layouts/_messages.html.erb (0.1ms)
Completed 200 OK in 769ms (Views: 767.2ms | ActiveRecord: 0.0ms)

修改

所以我运行strace -f passenger start来查看fork进程,看起来我的所有宝石都消失了。但是,该应用程序工作。真奇怪。

[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/rdoc-4.1.2/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/rails_layout-1.0.22/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/quiet_assets-1.0.3/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/pundit-0.3.0/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/public_activity-1.4.2/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/prawn-templates-0.0.3/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/prawn-1.2.1/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/pdf-reader-1.3.3/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/ttfunk-1.2.2/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/ruby-rc4-0.1.5/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/pdf-core-0.2.5/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/extensions/x86_64-linux/2.1.0/passenger-4.0.50/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/passenger-4.0.50/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/extensions/x86_64-linux/2.1.0/mysql2-0.3.16/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/mysql2-0.3.16/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/mini_magick-3.8.1/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  2300] open("/home/kobaltz/.rvm/gems/ruby-2.1.3/gems/subexec-0.2.3/lib/arel/nodes/grouping.rb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

1 个答案:

答案 0 :(得分:0)

关闭config.assets.debug可能会加快渲染速度

config.assets.debug = false