{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/89919475","pull_request_review_id":10448346,"id":89919475,"diff_hunk":"@@ -1031,6 +1028,45 @@ public void Sort(IComparer<T> comparer)\n             return true;\n         }\n \n+        private void AddEnumerable(IEnumerable<T> enumerable)\n+        {\n+            Contract.Assert(enumerable != null);\n+            Contract.Assert(!(enumerable is ICollection<T>), \"We should have optimized for this beforehand.\");\n+\n+            using (IEnumerator<T> en = enumerable.GetEnumerator())\n+            {\n+                T[] items = _items;\n+                int size = _size;\n+\n+                // Read in items from the enumerator, only updating fields\n+                // when we run out of space.\n+\n+                try\n+                {\n+                    while (en.MoveNext())\n+                    {\n+                        if (size == items.Length)\n+                        {\n+                            _size = size;\n+                            EnsureCapacity(size + 1);\n+                            items = _items;\n+                        }\n+\n+                        // Note: It's important we increment size after Current is called.\n+                        // If that throws an exception we don't want to do the increment.\n+                        items[size] = en.Current;\n+                        size++;\n+                    }\n+                }\n+                finally\n+                {\n+                    // Make a final update to _size and _version after we've finished adding.\n+                    _size = size;\n+                    _version++;","path":"src/mscorlib/src/System/Collections/Generic/List.cs","position":null,"original_position":88,"commit_id":"9dd876f4c7cad071cee6c50f22b88650b7330b37","original_commit_id":"8f696732033b58a0cad119624535854c2dd48dff","user":{"login":"jkotas","id":6668460,"avatar_url":"https://avatars.githubusercontent.com/u/6668460?v=3","gravatar_id":"","url":"https://api.github.com/users/jkotas","html_url":"https://github.com/jkotas","followers_url":"https://api.github.com/users/jkotas/followers","following_url":"https://api.github.com/users/jkotas/following{/other_user}","gists_url":"https://api.github.com/users/jkotas/gists{/gist_id}","starred_url":"https://api.github.com/users/jkotas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkotas/subscriptions","organizations_url":"https://api.github.com/users/jkotas/orgs","repos_url":"https://api.github.com/users/jkotas/repos","events_url":"https://api.github.com/users/jkotas/events{/privacy}","received_events_url":"https://api.github.com/users/jkotas/received_events","type":"User","site_admin":false},"body":"cc @AndyAyersMS \r\n\r\nManual inlining is double edged sword. You can get a small improvement in a lot of places by manually inlining and always show there is a performance improvement in microbenchmark. However if you have done manual inlining enough times, the real world workloads would likely get slower because of the code size increase from manual inlining would overwhelm the benefits.\r\n\r\nWe may want to be more data driven for manual inlining - only do it if there is real-world workload where it makes a dent, and leave profile guided optimizations to take care of the rest.","created_at":"2016-11-29T00:48:01Z","updated_at":"2016-11-29T00:48:01Z","html_url":"https://github.com/dotnet/coreclr/pull/8306#discussion_r89919475","pull_request_url":"https://api.github.com/repos/dotnet/coreclr/pulls/8306","_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/89919475"},"html":{"href":"https://github.com/dotnet/coreclr/pull/8306#discussion_r89919475"},"pull_request":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/8306"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/8306","id":95241710,"html_url":"https://github.com/dotnet/coreclr/pull/8306","diff_url":"https://github.com/dotnet/coreclr/pull/8306.diff","patch_url":"https://github.com/dotnet/coreclr/pull/8306.patch","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/8306","number":8306,"state":"open","locked":false,"title":"Better bulk adds for List.","user":{"login":"jamesqo","id":9159214,"avatar_url":"https://avatars.githubusercontent.com/u/9159214?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesqo","html_url":"https://github.com/jamesqo","followers_url":"https://api.github.com/users/jamesqo/followers","following_url":"https://api.github.com/users/jamesqo/following{/other_user}","gists_url":"https://api.github.com/users/jamesqo/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesqo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesqo/subscriptions","organizations_url":"https://api.github.com/users/jamesqo/orgs","repos_url":"https://api.github.com/users/jamesqo/repos","events_url":"https://api.github.com/users/jamesqo/events{/privacy}","received_events_url":"https://api.github.com/users/jamesqo/received_events","type":"User","site_admin":false},"body":"This PR optimizes the `List(IEnumerable<T>)` .ctor and `AddRange` method for lazy enumerables.\r\n\r\n- For the constructor, we were previously looping through the sequence and calling `Add` on each item. This is not very efficient since `Add` is not inlined. Instead, we can have a tighter loop where we essentially write `Add` inline and only update fields when we run out of space.\r\n\r\n- For `InsertRange`, we check if we are adding at the end of the list first. This is a common case, since `AddRange` just forwards to `InsertRange`. If we are, then we call `AddEnumerable` instead of `Insert` in a loop.\r\n\r\nI ran tests on corefx's System.Collections and everything passes.\r\n\r\nNote: I can't test the perf impact these changes have at the moment because of #8266. If/when I am able to, however, I will update this PR.\r\n\r\ncc @stephentoub @jkotas \r\n\r\nRelated: https://github.com/dotnet/corefx/pull/13942#issuecomment-262844479","created_at":"2016-11-25T02:10:05Z","updated_at":"2016-11-29T00:48:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9e84e2a8c2129886c27ddb40489923b76ba11b43","assignee":{"login":"ianhays","id":2606879,"avatar_url":"https://avatars.githubusercontent.com/u/2606879?v=3","gravatar_id":"","url":"https://api.github.com/users/ianhays","html_url":"https://github.com/ianhays","followers_url":"https://api.github.com/users/ianhays/followers","following_url":"https://api.github.com/users/ianhays/following{/other_user}","gists_url":"https://api.github.com/users/ianhays/gists{/gist_id}","starred_url":"https://api.github.com/users/ianhays/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianhays/subscriptions","organizations_url":"https://api.github.com/users/ianhays/orgs","repos_url":"https://api.github.com/users/ianhays/repos","events_url":"https://api.github.com/users/ianhays/events{/privacy}","received_events_url":"https://api.github.com/users/ianhays/received_events","type":"User","site_admin":false},"assignees":[{"login":"ianhays","id":2606879,"avatar_url":"https://avatars.githubusercontent.com/u/2606879?v=3","gravatar_id":"","url":"https://api.github.com/users/ianhays","html_url":"https://github.com/ianhays","followers_url":"https://api.github.com/users/ianhays/followers","following_url":"https://api.github.com/users/ianhays/following{/other_user}","gists_url":"https://api.github.com/users/ianhays/gists{/gist_id}","starred_url":"https://api.github.com/users/ianhays/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianhays/subscriptions","organizations_url":"https://api.github.com/users/ianhays/orgs","repos_url":"https://api.github.com/users/ianhays/repos","events_url":"https://api.github.com/users/ianhays/events{/privacy}","received_events_url":"https://api.github.com/users/ianhays/received_events","type":"User","site_admin":false},{"login":"Priya91","id":7853870,"avatar_url":"https://avatars.githubusercontent.com/u/7853870?v=3","gravatar_id":"","url":"https://api.github.com/users/Priya91","html_url":"https://github.com/Priya91","followers_url":"https://api.github.com/users/Priya91/followers","following_url":"https://api.github.com/users/Priya91/following{/other_user}","gists_url":"https://api.github.com/users/Priya91/gists{/gist_id}","starred_url":"https://api.github.com/users/Priya91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Priya91/subscriptions","organizations_url":"https://api.github.com/users/Priya91/orgs","repos_url":"https://api.github.com/users/Priya91/repos","events_url":"https://api.github.com/users/Priya91/events{/privacy}","received_events_url":"https://api.github.com/users/Priya91/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/coreclr/pulls/8306/commits","review_comments_url":"https://api.github.com/repos/dotnet/coreclr/pulls/8306/comments","review_comment_url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/8306/comments","statuses_url":"https://api.github.com/repos/dotnet/coreclr/statuses/9dd876f4c7cad071cee6c50f22b88650b7330b37","head":{"label":"jamesqo:better-bulk-add","ref":"better-bulk-add","sha":"9dd876f4c7cad071cee6c50f22b88650b7330b37","user":{"login":"jamesqo","id":9159214,"avatar_url":"https://avatars.githubusercontent.com/u/9159214?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesqo","html_url":"https://github.com/jamesqo","followers_url":"https://api.github.com/users/jamesqo/followers","following_url":"https://api.github.com/users/jamesqo/following{/other_user}","gists_url":"https://api.github.com/users/jamesqo/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesqo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesqo/subscriptions","organizations_url":"https://api.github.com/users/jamesqo/orgs","repos_url":"https://api.github.com/users/jamesqo/repos","events_url":"https://api.github.com/users/jamesqo/events{/privacy}","received_events_url":"https://api.github.com/users/jamesqo/received_events","type":"User","site_admin":false},"repo":{"id":37690478,"name":"coreclr","full_name":"jamesqo/coreclr","owner":{"login":"jamesqo","id":9159214,"avatar_url":"https://avatars.githubusercontent.com/u/9159214?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesqo","html_url":"https://github.com/jamesqo","followers_url":"https://api.github.com/users/jamesqo/followers","following_url":"https://api.github.com/users/jamesqo/following{/other_user}","gists_url":"https://api.github.com/users/jamesqo/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesqo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesqo/subscriptions","organizations_url":"https://api.github.com/users/jamesqo/orgs","repos_url":"https://api.github.com/users/jamesqo/repos","events_url":"https://api.github.com/users/jamesqo/events{/privacy}","received_events_url":"https://api.github.com/users/jamesqo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jamesqo/coreclr","description":"This repo contains the .NET Core runtime, called CoreCLR, and the base library, called mscorlib. It includes the garbage collector, JIT compiler, base .NET data types and many low-level classes.","fork":true,"url":"https://api.github.com/repos/jamesqo/coreclr","forks_url":"https://api.github.com/repos/jamesqo/coreclr/forks","keys_url":"https://api.github.com/repos/jamesqo/coreclr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jamesqo/coreclr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jamesqo/coreclr/teams","hooks_url":"https://api.github.com/repos/jamesqo/coreclr/hooks","issue_events_url":"https://api.github.com/repos/jamesqo/coreclr/issues/events{/number}","events_url":"https://api.github.com/repos/jamesqo/coreclr/events","assignees_url":"https://api.github.com/repos/jamesqo/coreclr/assignees{/user}","branches_url":"https://api.github.com/repos/jamesqo/coreclr/branches{/branch}","tags_url":"https://api.github.com/repos/jamesqo/coreclr/tags","blobs_url":"https://api.github.com/repos/jamesqo/coreclr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jamesqo/coreclr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jamesqo/coreclr/git/refs{/sha}","trees_url":"https://api.github.com/repos/jamesqo/coreclr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jamesqo/coreclr/statuses/{sha}","languages_url":"https://api.github.com/repos/jamesqo/coreclr/languages","stargazers_url":"https://api.github.com/repos/jamesqo/coreclr/stargazers","contributors_url":"https://api.github.com/repos/jamesqo/coreclr/contributors","subscribers_url":"https://api.github.com/repos/jamesqo/coreclr/subscribers","subscription_url":"https://api.github.com/repos/jamesqo/coreclr/subscription","commits_url":"https://api.github.com/repos/jamesqo/coreclr/commits{/sha}","git_commits_url":"https://api.github.com/repos/jamesqo/coreclr/git/commits{/sha}","comments_url":"https://api.github.com/repos/jamesqo/coreclr/comments{/number}","issue_comment_url":"https://api.github.com/repos/jamesqo/coreclr/issues/comments{/number}","contents_url":"https://api.github.com/repos/jamesqo/coreclr/contents/{+path}","compare_url":"https://api.github.com/repos/jamesqo/coreclr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jamesqo/coreclr/merges","archive_url":"https://api.github.com/repos/jamesqo/coreclr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jamesqo/coreclr/downloads","issues_url":"https://api.github.com/repos/jamesqo/coreclr/issues{/number}","pulls_url":"https://api.github.com/repos/jamesqo/coreclr/pulls{/number}","milestones_url":"https://api.github.com/repos/jamesqo/coreclr/milestones{/number}","notifications_url":"https://api.github.com/repos/jamesqo/coreclr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jamesqo/coreclr/labels{/name}","releases_url":"https://api.github.com/repos/jamesqo/coreclr/releases{/id}","deployments_url":"https://api.github.com/repos/jamesqo/coreclr/deployments","created_at":"2015-06-18T23:12:00Z","updated_at":"2016-07-30T03:18:02Z","pushed_at":"2016-11-28T22:06:48Z","git_url":"git://github.com/jamesqo/coreclr.git","ssh_url":"git@github.com:jamesqo/coreclr.git","clone_url":"https://github.com/jamesqo/coreclr.git","svn_url":"https://github.com/jamesqo/coreclr","homepage":"http://dotnet.github.io/core/","size":119458,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"dotnet:master","ref":"master","sha":"3e60aade2971016dc8e60ac683d1121f1969ca51","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":30092893,"name":"coreclr","full_name":"dotnet/coreclr","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/coreclr","description":"This repo contains the .NET Core runtime, called CoreCLR, and the base library, called mscorlib. It includes the garbage collector, JIT compiler, base .NET data types and many low-level classes.","fork":false,"url":"https://api.github.com/repos/dotnet/coreclr","forks_url":"https://api.github.com/repos/dotnet/coreclr/forks","keys_url":"https://api.github.com/repos/dotnet/coreclr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/coreclr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/coreclr/teams","hooks_url":"https://api.github.com/repos/dotnet/coreclr/hooks","issue_events_url":"https://api.github.com/repos/dotnet/coreclr/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/coreclr/events","assignees_url":"https://api.github.com/repos/dotnet/coreclr/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/coreclr/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/coreclr/tags","blobs_url":"https://api.github.com/repos/dotnet/coreclr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/coreclr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/coreclr/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/coreclr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/coreclr/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/coreclr/languages","stargazers_url":"https://api.github.com/repos/dotnet/coreclr/stargazers","contributors_url":"https://api.github.com/repos/dotnet/coreclr/contributors","subscribers_url":"https://api.github.com/repos/dotnet/coreclr/subscribers","subscription_url":"https://api.github.com/repos/dotnet/coreclr/subscription","commits_url":"https://api.github.com/repos/dotnet/coreclr/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/coreclr/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/coreclr/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/coreclr/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/coreclr/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/coreclr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/coreclr/merges","archive_url":"https://api.github.com/repos/dotnet/coreclr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/coreclr/downloads","issues_url":"https://api.github.com/repos/dotnet/coreclr/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/coreclr/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/coreclr/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/coreclr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/coreclr/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/coreclr/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/coreclr/deployments","created_at":"2015-01-30T22:10:02Z","updated_at":"2016-11-28T23:34:07Z","pushed_at":"2016-11-29T00:09:50Z","git_url":"git://github.com/dotnet/coreclr.git","ssh_url":"git@github.com:dotnet/coreclr.git","clone_url":"https://github.com/dotnet/coreclr.git","svn_url":"https://github.com/dotnet/coreclr","homepage":"https://docs.microsoft.com/dotnet/","size":136410,"stargazers_count":7091,"watchers_count":7091,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1726,"mirror_url":null,"open_issues_count":1041,"forks":1726,"open_issues":1041,"watchers":7091,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/8306"},"html":{"href":"https://github.com/dotnet/coreclr/pull/8306"},"issue":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/8306"},"comments":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/8306/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/8306/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/8306/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/coreclr/statuses/9dd876f4c7cad071cee6c50f22b88650b7330b37"}}}}
{"actor":{"display_login":"jkotas"}}