我需要能够确定为什么视图渲染速度很慢。
在第一台服务器上,它会像这样渲染/设置:
Completed 200 OK in 106ms (Views: 79.6ms | ActiveRecord: 19.8ms)
但是在另一台服务器上:
Completed 200 OK in 8670ms (Views: 8559.7ms | ActiveRecord: 83.7ms)
这是完整的调试日志:
Started GET "/settings" for 24.135.248.215 at 2017-05-14 12:03:08 +0200
Processing by SettingsController#index as HTML
SQL (6.9ms) UPDATE `tokens` SET `tokens`.`updated_on` = '2017-05-14 12:03:08' WHERE `tokens`.`user_id` = 1 AND `tokens`.`value` = 'a84ab330b53c2becd16dee761ef3048bdb664834' AND `tokens`.`action` = 'session'
(0.6ms) SELECT MAX(`settings`.`updated_on`) FROM `settings`
User Load (1.0ms) SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`status` = 1 AND `users`.`id` = 1 LIMIT 1
Current user: admin (id=1)
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'commit_update_keywords' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'welcome_text' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'text_formatting' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'per_page_options' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'search_results_per_page' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'activity_days_default' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'host_name' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'protocol' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.9ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'cache_formatted_text' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (3.1ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'wiki_compression' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (1.0ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'feeds_limit' ORDER BY `settings`.`id` DESC LIMIT 1
Rendered settings/_general.html.erb (419.7ms)
Setting Load (0.8ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'force_default_language_for_anonymous' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (1.0ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'start_of_week' ORDER BY `settings`.`id` DESC LIMIT 1
UserPreference Load (0.7ms) SELECT `user_preferences`.* FROM `user_preferences` WHERE `user_preferences`.`user_id` = 1 LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'date_format' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (3.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'time_format' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'user_format' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'thumbnails_enabled' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'thumbnails_size' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'new_item_menu_tab' ORDER BY `settings`.`id` DESC LIMIT 1
Rendered settings/_display.html.erb (868.7ms)
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'login_required' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (1.1ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'autologin' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (1.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'self_registration' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'unsubscribe' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'password_min_length' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'password_max_age' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'lost_password' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'max_additional_emails' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'openid' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'default_users_hide_mail' ORDER BY `settings`.`id` DESC LIMIT 1
Rendered settings/_authentication.html.erb (1338.9ms)
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'rest_api_enabled' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'jsonp_enabled' ORDER BY `settings`.`id` DESC LIMIT 1
Rendered settings/_api.html.erb (82.0ms)
Setting Load (1.3ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'default_projects_public' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'default_projects_modules' ORDER BY `settings`.`id` DESC LIMIT 1
Tracker Load (1.0ms) SELECT `trackers`.* FROM `trackers` ORDER BY `trackers`.`position` ASC
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'default_projects_tracker_ids' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'sequential_project_identifiers' ORDER BY `settings`.`id` DESC LIMIT 1
Role Load (0.7ms) SELECT `roles`.* FROM `roles` WHERE `roles`.`builtin` = 0 ORDER BY `roles`.`position` ASC
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'new_project_user_role_id' ORDER BY `settings`.`id` DESC LIMIT 1
Rendered settings/_projects.html.erb (546.8ms)
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'cross_project_issue_relations' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.8ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'link_copied_issue' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.8ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'cross_project_subtasks' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'issue_group_assignment' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'default_issue_start_date_to_creation_date' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'display_subprojects_issues' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.8ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'issue_done_ratio' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'non_working_week_days' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.8ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'issues_export_limit' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'gantt_items_limit' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'parent_issue_dates' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.8ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'parent_issue_priority' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.8ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'parent_issue_done_ratio' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'issue_list_default_columns' ORDER BY `settings`.`id` DESC LIMIT 1
IssueCustomField Load (0.6ms) SELECT `custom_fields`.* FROM `custom_fields` WHERE `custom_fields`.`type` IN ('IssueCustomField')
Tracker Load (2.4ms) SELECT DISTINCT `trackers`.* FROM `trackers` INNER JOIN `projects_trackers` ON `projects_trackers`.`tracker_id` = `trackers`.`id` INNER JOIN `projects` ON `projects`.`id` = `projects_trackers`.`project_id` WHERE (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='issue_tracking')) ORDER BY `trackers`.`position` ASC
Rendered queries/_columns.html.erb (669.8ms)
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'issue_list_default_totals' ORDER BY `settings`.`id` DESC LIMIT 1
CACHE (0.0ms) SELECT `custom_fields`.* FROM `custom_fields` WHERE `custom_fields`.`type` IN ('IssueCustomField')
CACHE (0.0ms) SELECT DISTINCT `trackers`.* FROM `trackers` INNER JOIN `projects_trackers` ON `projects_trackers`.`tracker_id` = `trackers`.`id` INNER JOIN `projects` ON `projects`.`id` = `projects_trackers`.`project_id` WHERE (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='issue_tracking')) ORDER BY `trackers`.`position` ASC
Rendered settings/_issues.html.erb (1922.1ms)
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'attachment_max_size' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'attachment_extensions_allowed' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.8ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'attachment_extensions_denied' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'file_max_size_displayed' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'diff_max_lines_displayed' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'repositories_encodings' ORDER BY `settings`.`id` DESC LIMIT 1
Rendered settings/_attachments.html.erb (369.8ms)
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'mail_from' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'bcc_recipients' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'plain_text_mail' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'default_notification_option' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'notified_events' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'emails_header' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'emails_footer' ORDER BY `settings`.`id` DESC LIMIT 1
Rendered settings/_notifications.html.erb (739.1ms)
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'mail_handler_body_delimiters' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'mail_handler_excluded_filenames' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'mail_handler_api_enabled' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'mail_handler_api_key' ORDER BY `settings`.`id` DESC LIMIT 1
Rendered settings/_mail_handler.html.erb (252.3ms)
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'enabled_scm' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'autofetch_changesets' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.7ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'sys_api_enabled' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'sys_api_key' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'repository_log_display_limit' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'commit_ref_keywords' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'commit_cross_project_ref' ORDER BY `settings`.`id` DESC LIMIT 1
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'commit_logtime_enabled' ORDER BY `settings`.`id` DESC LIMIT 1
TimeEntryActivity Load (0.9ms) SELECT `enumerations`.* FROM `enumerations` WHERE `enumerations`.`type` IN ('TimeEntryActivity') AND `enumerations`.`project_id` IS NULL AND `enumerations`.`active` = 1 ORDER BY `enumerations`.`position` ASC
Setting Load (0.6ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'commit_logtime_activity_id' ORDER BY `settings`.`id` DESC LIMIT 1
CACHE (0.0ms) SELECT `trackers`.* FROM `trackers` ORDER BY `trackers`.`position` ASC
IssueStatus Load (3.8ms) SELECT `issue_statuses`.* FROM `issue_statuses` ORDER BY `issue_statuses`.`position` ASC
Rendered settings/_repositories.html.erb (775.2ms)
Rendered common/_tabs.html.erb (7662.4ms)
Rendered settings/edit.html.erb within layouts/admin (7755.6ms)
Rendered admin/_menu.html.erb (375.6ms)
SQL (0.8ms) SELECT `members`.`id` AS t0_r0, `members`.`user_id` AS t0_r1, `members`.`project_id` AS t0_r2, `members`.`created_on` AS t0_r3, `members`.`mail_notification` AS t0_r4, `members`.`dmsf_mail_notification` AS t0_r5, `members`.`title_format` AS t0_r6, `projects`.`id` AS t1_r0, `projects`.`name` AS t1_r1, `projects`.`description` AS t1_r2, `projects`.`homepage` AS t1_r3, `projects`.`is_public` AS t1_r4, `projects`.`parent_id` AS t1_r5, `projects`.`created_on` AS t1_r6, `projects`.`updated_on` AS t1_r7, `projects`.`identifier` AS t1_r8, `projects`.`status` AS t1_r9, `projects`.`lft` AS t1_r10, `projects`.`rgt` AS t1_r11, `projects`.`inherit_members` AS t1_r12, `projects`.`default_version_id` AS t1_r13, `projects`.`dmsf_description` AS t1_r14, `projects`.`dmsf_notification` AS t1_r15 FROM `members` INNER JOIN `projects` ON `projects`.`id` = `members`.`project_id` WHERE `members`.`user_id` = 1 AND (projects.status<>9)
Rendered plugins/redmine_tweaks/app/views/application/_global_html_header.erb (4.4ms)
Attachment Load (1.4ms) SELECT `attachments`.* FROM `attachments` WHERE `attachments`.`container_id` = 1 AND `attachments`.`container_type` = 'Principal' AND `attachments`.`description` = 'avatar' ORDER BY attachments.created_on ASC, attachments.id ASC LIMIT 1
EmailAddress Load (0.6ms) SELECT `email_addresses`.* FROM `email_addresses` WHERE `email_addresses`.`user_id` = 1 AND `email_addresses`.`is_default` = 1 LIMIT 1
Project Load (0.8ms) SELECT `projects`.`id`, `projects`.`name`, `projects`.`identifier`, `projects`.`lft`, `projects`.`rgt` FROM `projects` INNER JOIN `members` ON `projects`.`id` = `members`.`project_id` WHERE `members`.`user_id` = 1 AND (projects.status<>9) AND `projects`.`status` = 1
Rendered plugins/redmine_tweaks/app/views/application/_global_content.erb (30.5ms)
Rendered plugins/redmine_tweaks/app/views/application/_global_footer.erb (0.3ms)
Rendered layouts/base.html.erb (461.6ms)
Completed 200 OK in 8670ms (Views: 8559.7ms | ActiveRecord: 83.7ms)
应用信息:
Ruby version 2.3.3-p222 (2016-11-21) [x86_64-linux]
Rails version 4.2.7.1
答案 0 :(得分:2)
嗯,现在:
Started GET "/settings" for 24.135.248.215 at 2017-05-15 21:07:04 +0200
Processing by SettingsController#index as HTML
Current user: admin (id=1)
Rendered settings/_general.html.erb (33.4ms)
Rendered settings/_display.html.erb (44.1ms)
Rendered settings/_authentication.html.erb (36.3ms)
Rendered settings/_api.html.erb (6.2ms)
Rendered settings/_projects.html.erb (69.4ms)
Rendered queries/_columns.html.erb (56.7ms)
Rendered settings/_issues.html.erb (121.0ms)
Rendered settings/_attachments.html.erb (13.4ms)
Rendered settings/_notifications.html.erb (19.1ms)
Rendered settings/_mail_handler.html.erb (8.8ms)
Rendered settings/_repositories.html.erb (100.0ms)
Rendered common/_tabs.html.erb (497.5ms)
Rendered settings/edit.html.erb within layouts/admin (502.0ms)
Rendered admin/_menu.html.erb (3.8ms)
Rendered plugins/redmine_tweaks/app/views/application/_global_html_header.erb (8.4ms)
Rendered plugins/redmine_tweaks/app/views/application/_global_content.erb (0.4ms)
Rendered plugins/redmine_tweaks/app/views/application/_global_footer.erb (0.3ms)
Rendered layouts/base.html.erb (39.8ms)
Completed 200 OK in 581ms (Views: 483.5ms | ActiveRecord: 83.9ms)
我做的是:
bundle clean --force
rvm gemset empty
rm -rf .bundle
gem install bundler
bundle install --without development test
我不确定究竟是什么解决了这个问题,是宝石,还是现在我安装而没有开发和测试的事实。