{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/59469165","id":59469165,"diff_hunk":"@@ -68,14 +68,16 @@ public T Value\n \n     [DataContract(Namespace = \"http://schemas.microsoft.com/2003/10/Serialization/Arrays\")]\n #if USE_REFEMIT\n-    public struct KeyValue<K, V>\n+    public class KeyValue<K, V>\n #else\n-    internal struct KeyValue<K, V>","path":"src/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs","position":7,"original_position":7,"commit_id":"042ed27ae7599d8d6c5a1c67dba236cbb07820db","original_commit_id":"042ed27ae7599d8d6c5a1c67dba236cbb07820db","user":{"login":"mconnew","id":8648390,"avatar_url":"https://avatars.githubusercontent.com/u/8648390?v=3","gravatar_id":"","url":"https://api.github.com/users/mconnew","html_url":"https://github.com/mconnew","followers_url":"https://api.github.com/users/mconnew/followers","following_url":"https://api.github.com/users/mconnew/following{/other_user}","gists_url":"https://api.github.com/users/mconnew/gists{/gist_id}","starred_url":"https://api.github.com/users/mconnew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mconnew/subscriptions","organizations_url":"https://api.github.com/users/mconnew/orgs","repos_url":"https://api.github.com/users/mconnew/repos","events_url":"https://api.github.com/users/mconnew/events{/privacy}","received_events_url":"https://api.github.com/users/mconnew/received_events","type":"User","site_admin":false},"body":"Changing KeyValue from a struct to a class will have a significant performance hit which you won't see in a micro benchmark. This could place a lot of stress on the heap and cause long GC pauses some time later. It will could also cause significantly slower memory accesses as an array of structs are next to each other in memory. An array of classes will require an extra dereference which will be slower, and you won't benefit from cache locality and on high core machines under sufficient load to context switch, this could be a significant issue.","created_at":"2016-04-12T23:02:44Z","updated_at":"2016-04-12T23:02:44Z","html_url":"https://github.com/dotnet/corefx/pull/7608#discussion_r59469165","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/7608","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/59469165"},"html":{"href":"https://github.com/dotnet/corefx/pull/7608#discussion_r59469165"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/7608"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/7608","id":65861822,"html_url":"https://github.com/dotnet/corefx/pull/7608","diff_url":"https://github.com/dotnet/corefx/pull/7608.diff","patch_url":"https://github.com/dotnet/corefx/pull/7608.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/7608","number":7608,"state":"open","locked":false,"title":"Improve data contract serializers performance in dictionary scenario","user":{"login":"khdang","id":10590707,"avatar_url":"https://avatars.githubusercontent.com/u/10590707?v=3","gravatar_id":"","url":"https://api.github.com/users/khdang","html_url":"https://github.com/khdang","followers_url":"https://api.github.com/users/khdang/followers","following_url":"https://api.github.com/users/khdang/following{/other_user}","gists_url":"https://api.github.com/users/khdang/gists{/gist_id}","starred_url":"https://api.github.com/users/khdang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khdang/subscriptions","organizations_url":"https://api.github.com/users/khdang/orgs","repos_url":"https://api.github.com/users/khdang/repos","events_url":"https://api.github.com/users/khdang/events{/privacy}","received_events_url":"https://api.github.com/users/khdang/received_events","type":"User","site_admin":false},"body":"- Improve data contract serializers performance in dictionary scenario by 2x.\r\n- Instead of the current way to get encoded string which involves string creation and buffer copy, use the encoding.GetBytes API\r\n- When creating a new instance of a type without a default constructor we use reflection to invoke a method that is not from the serialization assembly. Since that is significantly slower, we should use Activator.CreateInstance whenever we can. The Activator.CreateInstance throws exception so we need to check to know if a type has default constructor or not and use the appropriate method. As this check is also slow, so I've added a cache to make sure we only do this once for each type.\r\n- Internally dictionaries are handled as collection of KeyValues. I've updated this type to have default constructor so we can use Activator.CreateInstance to create new instance of it.\r\n\r\ncc: @shmao @SGuyGe @zhenlan @mconnew \r\n\r\nFix #7578 and #7577","created_at":"2016-04-08T23:43:59Z","updated_at":"2016-04-12T23:02:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0c84dfddcde1ae2c900c5ac19418b5a7df7f9f4f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/7608/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/7608/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/7608/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/042ed27ae7599d8d6c5a1c67dba236cbb07820db","head":{"label":"khdang:improve_serialization_perf_dcs_dictionary","ref":"improve_serialization_perf_dcs_dictionary","sha":"042ed27ae7599d8d6c5a1c67dba236cbb07820db","user":{"login":"khdang","id":10590707,"avatar_url":"https://avatars.githubusercontent.com/u/10590707?v=3","gravatar_id":"","url":"https://api.github.com/users/khdang","html_url":"https://github.com/khdang","followers_url":"https://api.github.com/users/khdang/followers","following_url":"https://api.github.com/users/khdang/following{/other_user}","gists_url":"https://api.github.com/users/khdang/gists{/gist_id}","starred_url":"https://api.github.com/users/khdang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khdang/subscriptions","organizations_url":"https://api.github.com/users/khdang/orgs","repos_url":"https://api.github.com/users/khdang/repos","events_url":"https://api.github.com/users/khdang/events{/privacy}","received_events_url":"https://api.github.com/users/khdang/received_events","type":"User","site_admin":false},"repo":{"id":33624190,"name":"corefx","full_name":"khdang/corefx","owner":{"login":"khdang","id":10590707,"avatar_url":"https://avatars.githubusercontent.com/u/10590707?v=3","gravatar_id":"","url":"https://api.github.com/users/khdang","html_url":"https://github.com/khdang","followers_url":"https://api.github.com/users/khdang/followers","following_url":"https://api.github.com/users/khdang/following{/other_user}","gists_url":"https://api.github.com/users/khdang/gists{/gist_id}","starred_url":"https://api.github.com/users/khdang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khdang/subscriptions","organizations_url":"https://api.github.com/users/khdang/orgs","repos_url":"https://api.github.com/users/khdang/repos","events_url":"https://api.github.com/users/khdang/events{/privacy}","received_events_url":"https://api.github.com/users/khdang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/khdang/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":true,"url":"https://api.github.com/repos/khdang/corefx","forks_url":"https://api.github.com/repos/khdang/corefx/forks","keys_url":"https://api.github.com/repos/khdang/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/khdang/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/khdang/corefx/teams","hooks_url":"https://api.github.com/repos/khdang/corefx/hooks","issue_events_url":"https://api.github.com/repos/khdang/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/khdang/corefx/events","assignees_url":"https://api.github.com/repos/khdang/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/khdang/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/khdang/corefx/tags","blobs_url":"https://api.github.com/repos/khdang/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/khdang/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/khdang/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/khdang/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/khdang/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/khdang/corefx/languages","stargazers_url":"https://api.github.com/repos/khdang/corefx/stargazers","contributors_url":"https://api.github.com/repos/khdang/corefx/contributors","subscribers_url":"https://api.github.com/repos/khdang/corefx/subscribers","subscription_url":"https://api.github.com/repos/khdang/corefx/subscription","commits_url":"https://api.github.com/repos/khdang/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/khdang/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/khdang/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/khdang/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/khdang/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/khdang/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/khdang/corefx/merges","archive_url":"https://api.github.com/repos/khdang/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/khdang/corefx/downloads","issues_url":"https://api.github.com/repos/khdang/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/khdang/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/khdang/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/khdang/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/khdang/corefx/labels{/name}","releases_url":"https://api.github.com/repos/khdang/corefx/releases{/id}","deployments_url":"https://api.github.com/repos/khdang/corefx/deployments","created_at":"2015-04-08T18:20:35Z","updated_at":"2016-02-10T22:31:56Z","pushed_at":"2016-04-12T17:53:49Z","git_url":"git://github.com/khdang/corefx.git","ssh_url":"git@github.com:khdang/corefx.git","clone_url":"https://github.com/khdang/corefx.git","svn_url":"https://github.com/khdang/corefx","homepage":"","size":62994,"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":"f7a7fd0ff966e24def44d69dba8d51c69000cd71","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":26295345,"name":"corefx","full_name":"dotnet/corefx","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/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":false,"url":"https://api.github.com/repos/dotnet/corefx","forks_url":"https://api.github.com/repos/dotnet/corefx/forks","keys_url":"https://api.github.com/repos/dotnet/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefx/teams","hooks_url":"https://api.github.com/repos/dotnet/corefx/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefx/events","assignees_url":"https://api.github.com/repos/dotnet/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefx/tags","blobs_url":"https://api.github.com/repos/dotnet/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefx/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefx/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefx/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefx/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefx/subscription","commits_url":"https://api.github.com/repos/dotnet/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefx/merges","archive_url":"https://api.github.com/repos/dotnet/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefx/downloads","issues_url":"https://api.github.com/repos/dotnet/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefx/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefx/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/corefx/deployments","created_at":"2014-11-06T23:42:48Z","updated_at":"2016-04-12T20:28:58Z","pushed_at":"2016-04-12T23:00:34Z","git_url":"git://github.com/dotnet/corefx.git","ssh_url":"git@github.com:dotnet/corefx.git","clone_url":"https://github.com/dotnet/corefx.git","svn_url":"https://github.com/dotnet/corefx","homepage":"http://dotnet.github.io/","size":86395,"stargazers_count":9486,"watchers_count":9486,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2243,"mirror_url":null,"open_issues_count":945,"forks":2243,"open_issues":945,"watchers":9486,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/7608"},"html":{"href":"https://github.com/dotnet/corefx/pull/7608"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/7608"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/7608/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/7608/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/7608/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/042ed27ae7599d8d6c5a1c67dba236cbb07820db"}}}}