{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/123878976","pull_request_review_id":46127668,"id":123878976,"diff_hunk":"@@ -252,6 +254,38 @@ def index\n       assert_equal \"Hello bukkits\\n\", response[2].body\n     end\n \n+    test \"does not eager load controller actions in development\" do\n+      @plugin.write \"app/controllers/bukkit_controller.rb\", <<-RUBY\n+        class BukkitController < ActionController::Base\n+          def index;end\n+          def show;end\n+        end\n+      RUBY\n+\n+      boot_rails\n+\n+      assert_called(BukkitController, :internal_methods, \"#action_methods is not memoized\", returns: []) do\n+        BukkitController.action_methods\n+      end\n+    end\n+\n+    test \"eager loads controller actions when eager_load is enabled\" do\n+      add_to_env_config(\"development\", \"config.eager_load = true\")\n+\n+      @plugin.write \"app/controllers/bukkit_controller.rb\", <<-RUBY\n+        class BukkitController < ActionController::Base\n+          def index;end\n+          def show;end\n+        end\n+      RUBY\n+\n+      boot_rails\n+\n+      assert_not_called(BukkitController, :internal_methods, \"#action_methods is already memoized\") do","path":"railties/test/railties/engine_test.rb","position":44,"original_position":44,"commit_id":"ce28b69e0cbf4c97ea430e21e116be92ac3ce925","original_commit_id":"ce28b69e0cbf4c97ea430e21e116be92ac3ce925","user":{"login":"kirs","id":522155,"avatar_url":"https://avatars0.githubusercontent.com/u/522155?v=3","gravatar_id":"","url":"https://api.github.com/users/kirs","html_url":"https://github.com/kirs","followers_url":"https://api.github.com/users/kirs/followers","following_url":"https://api.github.com/users/kirs/following{/other_user}","gists_url":"https://api.github.com/users/kirs/gists{/gist_id}","starred_url":"https://api.github.com/users/kirs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirs/subscriptions","organizations_url":"https://api.github.com/users/kirs/orgs","repos_url":"https://api.github.com/users/kirs/repos","events_url":"https://api.github.com/users/kirs/events{/privacy}","received_events_url":"https://api.github.com/users/kirs/received_events","type":"User","site_admin":false},"body":"Another way to test it would be checking the memoized instance variable:\r\n\r\n`assert BukkitController.instance_variable_get(:@action_methods)`\r\n\r\nBut rather I prefered to check that the depending methods are not invoked.","created_at":"2017-06-24T15:07:50Z","updated_at":"2017-06-24T15:07:51Z","html_url":"https://github.com/rails/rails/pull/29559#discussion_r123878976","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/29559","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/123878976"},"html":{"href":"https://github.com/rails/rails/pull/29559#discussion_r123878976"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/29559"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/29559","id":127332807,"html_url":"https://github.com/rails/rails/pull/29559","diff_url":"https://github.com/rails/rails/pull/29559.diff","patch_url":"https://github.com/rails/rails/pull/29559.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/29559","number":29559,"state":"open","locked":false,"title":"Eager load controller actions to reduce response time of the first request","user":{"login":"kirs","id":522155,"avatar_url":"https://avatars0.githubusercontent.com/u/522155?v=3","gravatar_id":"","url":"https://api.github.com/users/kirs","html_url":"https://github.com/kirs","followers_url":"https://api.github.com/users/kirs/followers","following_url":"https://api.github.com/users/kirs/following{/other_user}","gists_url":"https://api.github.com/users/kirs/gists{/gist_id}","starred_url":"https://api.github.com/users/kirs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirs/subscriptions","organizations_url":"https://api.github.com/users/kirs/orgs","repos_url":"https://api.github.com/users/kirs/repos","events_url":"https://api.github.com/users/kirs/events{/privacy}","received_events_url":"https://api.github.com/users/kirs/received_events","type":"User","site_admin":false},"body":"On the first request, `ActionController::Base#action_methods` [computes\r\nand memoizes](https://github.com/rails/rails/blob/a3813dce9a0c950a4af7909111fa730a2622b1db/actionpack/lib/abstract_controller/base.rb#L66-L77) the list of available actions. With this PR we move this expensive operation into eager load step to reduce response time of the first request served in production.\r\n\r\nThis also reduces the memory footprint when running on forking server like Unicorn.\r\n\r\nall credit goes to @casperisfine. I'm just pushing this patch from Shopify into upstream :blush:\r\n\r\n@rafaelfranca @Edouard-chin ","created_at":"2017-06-24T15:06:24Z","updated_at":"2017-06-24T15:07:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"389c175a1e29d4377741e39ae7073c3b81035307","assignee":{"login":"matthewd","id":1034,"avatar_url":"https://avatars2.githubusercontent.com/u/1034?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewd","html_url":"https://github.com/matthewd","followers_url":"https://api.github.com/users/matthewd/followers","following_url":"https://api.github.com/users/matthewd/following{/other_user}","gists_url":"https://api.github.com/users/matthewd/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewd/subscriptions","organizations_url":"https://api.github.com/users/matthewd/orgs","repos_url":"https://api.github.com/users/matthewd/repos","events_url":"https://api.github.com/users/matthewd/events{/privacy}","received_events_url":"https://api.github.com/users/matthewd/received_events","type":"User","site_admin":false},"assignees":[{"login":"matthewd","id":1034,"avatar_url":"https://avatars2.githubusercontent.com/u/1034?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewd","html_url":"https://github.com/matthewd","followers_url":"https://api.github.com/users/matthewd/followers","following_url":"https://api.github.com/users/matthewd/following{/other_user}","gists_url":"https://api.github.com/users/matthewd/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewd/subscriptions","organizations_url":"https://api.github.com/users/matthewd/orgs","repos_url":"https://api.github.com/users/matthewd/repos","events_url":"https://api.github.com/users/matthewd/events{/privacy}","received_events_url":"https://api.github.com/users/matthewd/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/29559/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/29559/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/29559/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/ce28b69e0cbf4c97ea430e21e116be92ac3ce925","head":{"label":"kirs:eager-load-controller-actions","ref":"eager-load-controller-actions","sha":"ce28b69e0cbf4c97ea430e21e116be92ac3ce925","user":{"login":"kirs","id":522155,"avatar_url":"https://avatars0.githubusercontent.com/u/522155?v=3","gravatar_id":"","url":"https://api.github.com/users/kirs","html_url":"https://github.com/kirs","followers_url":"https://api.github.com/users/kirs/followers","following_url":"https://api.github.com/users/kirs/following{/other_user}","gists_url":"https://api.github.com/users/kirs/gists{/gist_id}","starred_url":"https://api.github.com/users/kirs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirs/subscriptions","organizations_url":"https://api.github.com/users/kirs/orgs","repos_url":"https://api.github.com/users/kirs/repos","events_url":"https://api.github.com/users/kirs/events{/privacy}","received_events_url":"https://api.github.com/users/kirs/received_events","type":"User","site_admin":false},"repo":{"id":73438530,"name":"rails-1","full_name":"kirs/rails-1","owner":{"login":"kirs","id":522155,"avatar_url":"https://avatars0.githubusercontent.com/u/522155?v=3","gravatar_id":"","url":"https://api.github.com/users/kirs","html_url":"https://github.com/kirs","followers_url":"https://api.github.com/users/kirs/followers","following_url":"https://api.github.com/users/kirs/following{/other_user}","gists_url":"https://api.github.com/users/kirs/gists{/gist_id}","starred_url":"https://api.github.com/users/kirs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirs/subscriptions","organizations_url":"https://api.github.com/users/kirs/orgs","repos_url":"https://api.github.com/users/kirs/repos","events_url":"https://api.github.com/users/kirs/events{/privacy}","received_events_url":"https://api.github.com/users/kirs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kirs/rails-1","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/kirs/rails-1","forks_url":"https://api.github.com/repos/kirs/rails-1/forks","keys_url":"https://api.github.com/repos/kirs/rails-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kirs/rails-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kirs/rails-1/teams","hooks_url":"https://api.github.com/repos/kirs/rails-1/hooks","issue_events_url":"https://api.github.com/repos/kirs/rails-1/issues/events{/number}","events_url":"https://api.github.com/repos/kirs/rails-1/events","assignees_url":"https://api.github.com/repos/kirs/rails-1/assignees{/user}","branches_url":"https://api.github.com/repos/kirs/rails-1/branches{/branch}","tags_url":"https://api.github.com/repos/kirs/rails-1/tags","blobs_url":"https://api.github.com/repos/kirs/rails-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kirs/rails-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kirs/rails-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/kirs/rails-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kirs/rails-1/statuses/{sha}","languages_url":"https://api.github.com/repos/kirs/rails-1/languages","stargazers_url":"https://api.github.com/repos/kirs/rails-1/stargazers","contributors_url":"https://api.github.com/repos/kirs/rails-1/contributors","subscribers_url":"https://api.github.com/repos/kirs/rails-1/subscribers","subscription_url":"https://api.github.com/repos/kirs/rails-1/subscription","commits_url":"https://api.github.com/repos/kirs/rails-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/kirs/rails-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/kirs/rails-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/kirs/rails-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/kirs/rails-1/contents/{+path}","compare_url":"https://api.github.com/repos/kirs/rails-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kirs/rails-1/merges","archive_url":"https://api.github.com/repos/kirs/rails-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kirs/rails-1/downloads","issues_url":"https://api.github.com/repos/kirs/rails-1/issues{/number}","pulls_url":"https://api.github.com/repos/kirs/rails-1/pulls{/number}","milestones_url":"https://api.github.com/repos/kirs/rails-1/milestones{/number}","notifications_url":"https://api.github.com/repos/kirs/rails-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kirs/rails-1/labels{/name}","releases_url":"https://api.github.com/repos/kirs/rails-1/releases{/id}","deployments_url":"https://api.github.com/repos/kirs/rails-1/deployments","created_at":"2016-11-11T02:22:46Z","updated_at":"2016-11-15T01:48:13Z","pushed_at":"2017-06-24T15:04:34Z","git_url":"git://github.com/kirs/rails-1.git","ssh_url":"git@github.com:kirs/rails-1.git","clone_url":"https://github.com/kirs/rails-1.git","svn_url":"https://github.com/kirs/rails-1","homepage":"http://rubyonrails.org","size":148842,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"8cad811b0559661df3c58528ac1e8d5a2e601d4d","user":{"login":"rails","id":4223,"avatar_url":"https://avatars2.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars2.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","deployments_url":"https://api.github.com/repos/rails/rails/deployments","created_at":"2008-04-11T02:19:47Z","updated_at":"2017-06-24T12:13:09Z","pushed_at":"2017-06-24T15:06:25Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":149630,"stargazers_count":36062,"watchers_count":36062,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":14709,"mirror_url":null,"open_issues_count":1212,"forks":14709,"open_issues":1212,"watchers":36062,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/29559"},"html":{"href":"https://github.com/rails/rails/pull/29559"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/29559"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/29559/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/29559/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/29559/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/ce28b69e0cbf4c97ea430e21e116be92ac3ce925"}}}}
{"actor":{"display_login":"kirs"}}