{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/198237580","pull_request_review_id":132131821,"id":198237580,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODIzNzU4MA==","diff_hunk":"@@ -43,6 +43,11 @@ def initialize(columns, rows, column_types = {})\n       @column_types = column_types\n     end\n \n+    # Does this result set include the column named +name+ ?","path":"activerecord/lib/active_record/result.rb","position":4,"original_position":4,"commit_id":"a01de4deab59f57874965a69e9a4c83112b3cb47","original_commit_id":"a01de4deab59f57874965a69e9a4c83112b3cb47","user":{"login":"rafaelfranca","id":47848,"node_id":"MDQ6VXNlcjQ3ODQ4","avatar_url":"https://avatars3.githubusercontent.com/u/47848?v=4","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"body":"To follow the same convention on this same class we should do:\r\n\r\n```ruby\r\n# Returns true if this result set include the column named +name+\r\n```","created_at":"2018-06-26T17:42:03Z","updated_at":"2018-06-26T17:43:38Z","html_url":"https://github.com/rails/rails/pull/33223#discussion_r198237580","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/33223","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/198237580"},"html":{"href":"https://github.com/rails/rails/pull/33223#discussion_r198237580"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/33223"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/33223","id":197258247,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3MjU4MjQ3","html_url":"https://github.com/rails/rails/pull/33223","diff_url":"https://github.com/rails/rails/pull/33223.diff","patch_url":"https://github.com/rails/rails/pull/33223.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/33223","number":33223,"state":"open","locked":false,"title":"Speed up homogeneous AR lists / reduce allocations","user":{"login":"tenderlove","id":3124,"node_id":"MDQ6VXNlcjMxMjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/3124?v=4","gravatar_id":"","url":"https://api.github.com/users/tenderlove","html_url":"https://github.com/tenderlove","followers_url":"https://api.github.com/users/tenderlove/followers","following_url":"https://api.github.com/users/tenderlove/following{/other_user}","gists_url":"https://api.github.com/users/tenderlove/gists{/gist_id}","starred_url":"https://api.github.com/users/tenderlove/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tenderlove/subscriptions","organizations_url":"https://api.github.com/users/tenderlove/orgs","repos_url":"https://api.github.com/users/tenderlove/repos","events_url":"https://api.github.com/users/tenderlove/events{/privacy}","received_events_url":"https://api.github.com/users/tenderlove/received_events","type":"User","site_admin":true},"body":"This commit speeds up allocating homogeneous lists of AR objects.  We\r\ncan know if the result set contains an STI column before initializing\r\nevery AR object, so this change pulls the \"does this result set contain\r\nan STI column?\" test up, then uses a specialized instantiation function.\r\nThis way we only have to check for an STI column once rather than N\r\ntimes.\r\n\r\nThis change also introduces a new initialization function that is meant\r\nfor use when allocating AR objects that come from the database.  Doing\r\nthis allows us to eliminate one hash allocation per AR instance.\r\n\r\nHere is a benchmark:\r\n\r\n```ruby\r\nrequire 'active_record'\r\nrequire 'benchmark/ips'\r\n\r\nActiveRecord::Base.establish_connection adapter: \"sqlite3\", database: \":memory:\"\r\n\r\nActiveRecord::Migration.verbose = false\r\n\r\nActiveRecord::Schema.define do\r\n  create_table :users, force: true do |t|\r\n    t.string :name\r\n    t.timestamps null: false\r\n  end\r\nend\r\n\r\nclass User < ActiveRecord::Base; end\r\n\r\n2000.times do\r\n  User.create!(name: \"Gorby\")\r\nend\r\n\r\nBenchmark.ips do |x|\r\n  x.report(\"find\") do\r\n    User.limit(2000).to_a\r\n  end\r\nend\r\n```\r\n\r\nResults:\r\n\r\nBefore:\r\n\r\n```\r\n[aaron@TC activerecord (master)]$ be ruby -I lib:~/git/allocation_tracer/lib speed.rb\r\nWarming up --------------------------------------\r\n                find     5.000  i/100ms\r\nCalculating -------------------------------------\r\n                find     56.192  (± 3.6%) i/s -    285.000  in   5.080940s\r\n```\r\n\r\nAfter:\r\n\r\n```\r\n[aaron@TC activerecord (homogeneous-allocation)]$ be ruby -I lib:~/git/allocation_tracer/lib speed.rb\r\nWarming up --------------------------------------\r\n                find     7.000  i/100ms\r\nCalculating -------------------------------------\r\n                find     72.204  (± 2.8%) i/s -    364.000  in   5.044592s\r\n```\r\n","created_at":"2018-06-25T22:57:08Z","updated_at":"2018-06-26T17:43:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b010bab4b4f7e1154838bfa0a21c6f3233fce4b9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/33223/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/33223/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/33223/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/a01de4deab59f57874965a69e9a4c83112b3cb47","head":{"label":"rails:homogeneous-allocation","ref":"homogeneous-allocation","sha":"a01de4deab59f57874965a69e9a4c83112b3cb47","user":{"login":"rails","id":4223,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyMjM=","avatar_url":"https://avatars1.githubusercontent.com/u/4223?v=4","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,"node_id":"MDEwOlJlcG9zaXRvcnk4NTE0","name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyMjM=","avatar_url":"https://avatars1.githubusercontent.com/u/4223?v=4","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":"2018-06-26T17:34:30Z","pushed_at":"2018-06-26T17:26:10Z","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":164018,"stargazers_count":40024,"watchers_count":40024,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16157,"mirror_url":null,"archived":false,"open_issues_count":1128,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":16157,"open_issues":1128,"watchers":40024,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"7c769234f6070e9dcc17f92d448e770358dd57e4","user":{"login":"rails","id":4223,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyMjM=","avatar_url":"https://avatars1.githubusercontent.com/u/4223?v=4","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,"node_id":"MDEwOlJlcG9zaXRvcnk4NTE0","name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyMjM=","avatar_url":"https://avatars1.githubusercontent.com/u/4223?v=4","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":"2018-06-26T17:34:30Z","pushed_at":"2018-06-26T17:26:10Z","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":164018,"stargazers_count":40024,"watchers_count":40024,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16157,"mirror_url":null,"archived":false,"open_issues_count":1128,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":16157,"open_issues":1128,"watchers":40024,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/33223"},"html":{"href":"https://github.com/rails/rails/pull/33223"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/33223"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/33223/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/33223/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/33223/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/a01de4deab59f57874965a69e9a4c83112b3cb47"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"rafaelfranca"}}