{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/40476815","id":40476815,"diff_hunk":"@@ -191,18 +191,27 @@ internal static void SetLocalValue(IAsyncLocal local, object newValue, bool need\n             if (previousValue == newValue)\n                 return;\n \n-            current = new ExecutionContext(current);\n-            current.m_localValues[local] = newValue;\n-\n-            t_currentMaybeNull = current;\n+            Dictionary<IAsyncLocal, object> newValues = new Dictionary<IAsyncLocal, object>(current.m_localValues);","path":"src/mscorlib/src/System/Threading/ExecutionContext.cs","position":22,"original_position":22,"commit_id":"640e6d4b99a3cd26d54348335815e1efff14bbe0","original_commit_id":"640e6d4b99a3cd26d54348335815e1efff14bbe0","user":{"login":"stephentoub","id":2642209,"avatar_url":"https://avatars.githubusercontent.com/u/2642209?v=3","gravatar_id":"","url":"https://api.github.com/users/stephentoub","html_url":"https://github.com/stephentoub","followers_url":"https://api.github.com/users/stephentoub/followers","following_url":"https://api.github.com/users/stephentoub/following{/other_user}","gists_url":"https://api.github.com/users/stephentoub/gists{/gist_id}","starred_url":"https://api.github.com/users/stephentoub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephentoub/subscriptions","organizations_url":"https://api.github.com/users/stephentoub/orgs","repos_url":"https://api.github.com/users/stephentoub/repos","events_url":"https://api.github.com/users/stephentoub/events{/privacy}","received_events_url":"https://api.github.com/users/stephentoub/received_events","type":"User","site_admin":false},"body":"Dictionary's ctor takes an IDictionary, so enumerating this is going to allocate an enumerator object.  Justin's proposed change at https://github.com/dotnet/coreclr/pull/1620 would help with that.  And if there's a good chance m_localValues is empty at this point, we could also just do a count check and use the Dictionary ctor overload that doesn't take an input.","created_at":"2015-09-25T21:21:13Z","updated_at":"2015-09-25T21:21:13Z","html_url":"https://github.com/dotnet/coreclr/pull/1629#discussion_r40476815","pull_request_url":"https://api.github.com/repos/dotnet/coreclr/pulls/1629","_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/40476815"},"html":{"href":"https://github.com/dotnet/coreclr/pull/1629#discussion_r40476815"},"pull_request":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/1629"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/1629","id":46058964,"html_url":"https://github.com/dotnet/coreclr/pull/1629","diff_url":"https://github.com/dotnet/coreclr/pull/1629.diff","patch_url":"https://github.com/dotnet/coreclr/pull/1629.patch","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/1629","number":1629,"state":"open","locked":false,"title":"Reduce allocations in AsyncLocal/ExecutionContext","user":{"login":"ericeil","id":7407587,"avatar_url":"https://avatars.githubusercontent.com/u/7407587?v=3","gravatar_id":"","url":"https://api.github.com/users/ericeil","html_url":"https://github.com/ericeil","followers_url":"https://api.github.com/users/ericeil/followers","following_url":"https://api.github.com/users/ericeil/following{/other_user}","gists_url":"https://api.github.com/users/ericeil/gists{/gist_id}","starred_url":"https://api.github.com/users/ericeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericeil/subscriptions","organizations_url":"https://api.github.com/users/ericeil/orgs","repos_url":"https://api.github.com/users/ericeil/repos","events_url":"https://api.github.com/users/ericeil/events{/privacy}","received_events_url":"https://api.github.com/users/ericeil/received_events","type":"User","site_admin":false},"body":"This partly addresses #1591.  When setting the value of an AsyncLocal, we shouldn't allocate a new notification list unless we need to add a new item to the existing list.  ","created_at":"2015-09-25T21:14:28Z","updated_at":"2015-09-25T21:21:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a9b6a0a499fa042e636101871a69e3fe68580267","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/coreclr/pulls/1629/commits","review_comments_url":"https://api.github.com/repos/dotnet/coreclr/pulls/1629/comments","review_comment_url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/1629/comments","statuses_url":"https://api.github.com/repos/dotnet/coreclr/statuses/640e6d4b99a3cd26d54348335815e1efff14bbe0","head":{"label":"ericeil:AsyncLocalPerf","ref":"AsyncLocalPerf","sha":"640e6d4b99a3cd26d54348335815e1efff14bbe0","user":{"login":"ericeil","id":7407587,"avatar_url":"https://avatars.githubusercontent.com/u/7407587?v=3","gravatar_id":"","url":"https://api.github.com/users/ericeil","html_url":"https://github.com/ericeil","followers_url":"https://api.github.com/users/ericeil/followers","following_url":"https://api.github.com/users/ericeil/following{/other_user}","gists_url":"https://api.github.com/users/ericeil/gists{/gist_id}","starred_url":"https://api.github.com/users/ericeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericeil/subscriptions","organizations_url":"https://api.github.com/users/ericeil/orgs","repos_url":"https://api.github.com/users/ericeil/repos","events_url":"https://api.github.com/users/ericeil/events{/privacy}","received_events_url":"https://api.github.com/users/ericeil/received_events","type":"User","site_admin":false},"repo":{"id":43175447,"name":"coreclr","full_name":"ericeil/coreclr","owner":{"login":"ericeil","id":7407587,"avatar_url":"https://avatars.githubusercontent.com/u/7407587?v=3","gravatar_id":"","url":"https://api.github.com/users/ericeil","html_url":"https://github.com/ericeil","followers_url":"https://api.github.com/users/ericeil/followers","following_url":"https://api.github.com/users/ericeil/following{/other_user}","gists_url":"https://api.github.com/users/ericeil/gists{/gist_id}","starred_url":"https://api.github.com/users/ericeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericeil/subscriptions","organizations_url":"https://api.github.com/users/ericeil/orgs","repos_url":"https://api.github.com/users/ericeil/repos","events_url":"https://api.github.com/users/ericeil/events{/privacy}","received_events_url":"https://api.github.com/users/ericeil/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ericeil/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/ericeil/coreclr","forks_url":"https://api.github.com/repos/ericeil/coreclr/forks","keys_url":"https://api.github.com/repos/ericeil/coreclr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ericeil/coreclr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ericeil/coreclr/teams","hooks_url":"https://api.github.com/repos/ericeil/coreclr/hooks","issue_events_url":"https://api.github.com/repos/ericeil/coreclr/issues/events{/number}","events_url":"https://api.github.com/repos/ericeil/coreclr/events","assignees_url":"https://api.github.com/repos/ericeil/coreclr/assignees{/user}","branches_url":"https://api.github.com/repos/ericeil/coreclr/branches{/branch}","tags_url":"https://api.github.com/repos/ericeil/coreclr/tags","blobs_url":"https://api.github.com/repos/ericeil/coreclr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ericeil/coreclr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ericeil/coreclr/git/refs{/sha}","trees_url":"https://api.github.com/repos/ericeil/coreclr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ericeil/coreclr/statuses/{sha}","languages_url":"https://api.github.com/repos/ericeil/coreclr/languages","stargazers_url":"https://api.github.com/repos/ericeil/coreclr/stargazers","contributors_url":"https://api.github.com/repos/ericeil/coreclr/contributors","subscribers_url":"https://api.github.com/repos/ericeil/coreclr/subscribers","subscription_url":"https://api.github.com/repos/ericeil/coreclr/subscription","commits_url":"https://api.github.com/repos/ericeil/coreclr/commits{/sha}","git_commits_url":"https://api.github.com/repos/ericeil/coreclr/git/commits{/sha}","comments_url":"https://api.github.com/repos/ericeil/coreclr/comments{/number}","issue_comment_url":"https://api.github.com/repos/ericeil/coreclr/issues/comments{/number}","contents_url":"https://api.github.com/repos/ericeil/coreclr/contents/{+path}","compare_url":"https://api.github.com/repos/ericeil/coreclr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ericeil/coreclr/merges","archive_url":"https://api.github.com/repos/ericeil/coreclr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ericeil/coreclr/downloads","issues_url":"https://api.github.com/repos/ericeil/coreclr/issues{/number}","pulls_url":"https://api.github.com/repos/ericeil/coreclr/pulls{/number}","milestones_url":"https://api.github.com/repos/ericeil/coreclr/milestones{/number}","notifications_url":"https://api.github.com/repos/ericeil/coreclr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ericeil/coreclr/labels{/name}","releases_url":"https://api.github.com/repos/ericeil/coreclr/releases{/id}","created_at":"2015-09-25T21:04:26Z","updated_at":"2015-09-25T21:05:10Z","pushed_at":"2015-09-25T21:08:38Z","git_url":"git://github.com/ericeil/coreclr.git","ssh_url":"git@github.com:ericeil/coreclr.git","clone_url":"https://github.com/ericeil/coreclr.git","svn_url":"https://github.com/ericeil/coreclr","homepage":"http://dotnet.github.io/core/","size":37981,"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":"f3f2c08269eeae29ba83df22e13e4f3a06349dcb","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}","created_at":"2015-01-30T22:10:02Z","updated_at":"2015-09-25T17:15:07Z","pushed_at":"2015-09-25T21:14:28Z","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":"http://dotnet.github.io/core/","size":55577,"stargazers_count":5206,"watchers_count":5206,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1051,"mirror_url":null,"open_issues_count":288,"forks":1051,"open_issues":288,"watchers":5206,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/1629"},"html":{"href":"https://github.com/dotnet/coreclr/pull/1629"},"issue":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/1629"},"comments":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/1629/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/1629/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/1629/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/coreclr/statuses/640e6d4b99a3cd26d54348335815e1efff14bbe0"}}}}