{"action":"created","comment":{"url":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/comments/93723958","pull_request_review_id":14256911,"id":93723958,"diff_hunk":"@@ -150,7 +150,23 @@ private static void EnsureName(MiniProfiler profiler, HttpRequest request)\n         /// </summary>\n         public override MiniProfiler GetCurrentProfiler() => Current;\n \n+        /// <summary>\n+        /// Current head timing.\n+        /// </summary>\n+        public override Timing CurrentHead","path":"src/MiniProfiler/ProfileProviders/WebRequestProfilerProvider.cs","position":7,"original_position":7,"commit_id":"0000723ee52536b7067197ff164d4af681d86337","original_commit_id":"0000723ee52536b7067197ff164d4af681d86337","user":{"login":"NickCraver","id":454813,"avatar_url":"https://avatars.githubusercontent.com/u/454813?v=3","gravatar_id":"","url":"https://api.github.com/users/NickCraver","html_url":"https://github.com/NickCraver","followers_url":"https://api.github.com/users/NickCraver/followers","following_url":"https://api.github.com/users/NickCraver/following{/other_user}","gists_url":"https://api.github.com/users/NickCraver/gists{/gist_id}","starred_url":"https://api.github.com/users/NickCraver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NickCraver/subscriptions","organizations_url":"https://api.github.com/users/NickCraver/orgs","repos_url":"https://api.github.com/users/NickCraver/repos","events_url":"https://api.github.com/users/NickCraver/events{/privacy}","received_events_url":"https://api.github.com/users/NickCraver/received_events","type":"User","site_admin":false},"body":"I agree it's possible WebRequest provider can go away, but it's a fairly drastic behavior change and possible weight and breaking change to do such. Consider at the moment the case where there is no profiler because of the async context breaks to backend code. If suddenly there is a profiler on massive operations, that may add significant weight and allocations (even from a stack trace strings standpoint), as well as serialization costs at the end to that path. This can easily break things.\r\n\r\nI'm not against it per se, but it'd definitely be a top breaking change alert in the v4 notes.","created_at":"2016-12-23T02:09:04Z","updated_at":"2016-12-23T02:22:20Z","html_url":"https://github.com/MiniProfiler/dotnet/pull/147#discussion_r93723958","pull_request_url":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/147","_links":{"self":{"href":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/comments/93723958"},"html":{"href":"https://github.com/MiniProfiler/dotnet/pull/147#discussion_r93723958"},"pull_request":{"href":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/147"}}},"pull_request":{"url":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/147","id":99176237,"html_url":"https://github.com/MiniProfiler/dotnet/pull/147","diff_url":"https://github.com/MiniProfiler/dotnet/pull/147.diff","patch_url":"https://github.com/MiniProfiler/dotnet/pull/147.patch","issue_url":"https://api.github.com/repos/MiniProfiler/dotnet/issues/147","number":147,"state":"open","locked":false,"title":"async multithreading support","user":{"login":"alexsku","id":14228762,"avatar_url":"https://avatars.githubusercontent.com/u/14228762?v=3","gravatar_id":"","url":"https://api.github.com/users/alexsku","html_url":"https://github.com/alexsku","followers_url":"https://api.github.com/users/alexsku/followers","following_url":"https://api.github.com/users/alexsku/following{/other_user}","gists_url":"https://api.github.com/users/alexsku/gists{/gist_id}","starred_url":"https://api.github.com/users/alexsku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexsku/subscriptions","organizations_url":"https://api.github.com/users/alexsku/orgs","repos_url":"https://api.github.com/users/alexsku/repos","events_url":"https://api.github.com/users/alexsku/events{/privacy}","received_events_url":"https://api.github.com/users/alexsku/received_events","type":"User","site_admin":false},"body":"This is my attempt to improve multithreading support for miniprofiler v4. I think the current version of the mini profiler would have issues in scenarios where the current thread spawns more than one task and waits for them.\r\n```\r\n        [Fact]\r\n        public void Head_WhenMultipleTasksSpawned_EachSetsItsOwnHead()\r\n        {\r\n            MiniProfiler.Settings.ProfilerProvider = new DefaultProfilerProvider();\r\n            var allTasks = new SemaphoreSlim(0, 1);\r\n            var completed = new TaskCompletionSource<int>();\r\n            using (GetRequest(\"http://localhost/Test.aspx\", startAndStopProfiler: false))\r\n            {\r\n                MiniProfiler.Start();\r\n                var sut = MiniProfiler.Current;\r\n                var head = sut.Head;\r\n\r\n                Task.Run(() => {\r\n                    Assert.Equal(head, sut.Head);\r\n                    using (sut.Step(\"test1\"))\r\n                    {\r\n                        allTasks.Release();\r\n                        completed.Task.Wait();\r\n                    }\r\n                });\r\n                allTasks.Wait();\r\n                Task.Run(() => {\r\n                    using (sut.Step(\"test2\"))\r\n                    {\r\n                        allTasks.Release();\r\n                        completed.Task.Wait();\r\n                    }\r\n                });\r\n                allTasks.Wait();\r\n\r\n                Assert.NotNull(sut.Head);\r\n                Assert.Equal(head, sut.Head);\r\n                completed.SetResult(0);\r\n            }\r\n        }\r\n```\r\nIn this scenario there would be multiple threads working with the mini profiler (since they would share it via AsyncLocal). This could lead to random failures since Timing class is not thread safe. Also this could lead to inconsistencies since the spawned tasks would replace the Head timing for the mini profiler instance, with one of the tasks's timing potentially becoming a child of another's. ","created_at":"2016-12-22T21:58:26Z","updated_at":"2016-12-23T02:22:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59c1f42dd25a16fe18d039dae3c07d486551c6b2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/147/commits","review_comments_url":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/147/comments","review_comment_url":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MiniProfiler/dotnet/issues/147/comments","statuses_url":"https://api.github.com/repos/MiniProfiler/dotnet/statuses/0000723ee52536b7067197ff164d4af681d86337","head":{"label":"alexsku:v4-async-multithreading","ref":"v4-async-multithreading","sha":"0000723ee52536b7067197ff164d4af681d86337","user":{"login":"alexsku","id":14228762,"avatar_url":"https://avatars.githubusercontent.com/u/14228762?v=3","gravatar_id":"","url":"https://api.github.com/users/alexsku","html_url":"https://github.com/alexsku","followers_url":"https://api.github.com/users/alexsku/followers","following_url":"https://api.github.com/users/alexsku/following{/other_user}","gists_url":"https://api.github.com/users/alexsku/gists{/gist_id}","starred_url":"https://api.github.com/users/alexsku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexsku/subscriptions","organizations_url":"https://api.github.com/users/alexsku/orgs","repos_url":"https://api.github.com/users/alexsku/repos","events_url":"https://api.github.com/users/alexsku/events{/privacy}","received_events_url":"https://api.github.com/users/alexsku/received_events","type":"User","site_admin":false},"repo":{"id":76416630,"name":"dotnet","full_name":"alexsku/dotnet","owner":{"login":"alexsku","id":14228762,"avatar_url":"https://avatars.githubusercontent.com/u/14228762?v=3","gravatar_id":"","url":"https://api.github.com/users/alexsku","html_url":"https://github.com/alexsku","followers_url":"https://api.github.com/users/alexsku/followers","following_url":"https://api.github.com/users/alexsku/following{/other_user}","gists_url":"https://api.github.com/users/alexsku/gists{/gist_id}","starred_url":"https://api.github.com/users/alexsku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexsku/subscriptions","organizations_url":"https://api.github.com/users/alexsku/orgs","repos_url":"https://api.github.com/users/alexsku/repos","events_url":"https://api.github.com/users/alexsku/events{/privacy}","received_events_url":"https://api.github.com/users/alexsku/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexsku/dotnet","description":"A simple but effective mini-profiler for ASP.NET websites","fork":true,"url":"https://api.github.com/repos/alexsku/dotnet","forks_url":"https://api.github.com/repos/alexsku/dotnet/forks","keys_url":"https://api.github.com/repos/alexsku/dotnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexsku/dotnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexsku/dotnet/teams","hooks_url":"https://api.github.com/repos/alexsku/dotnet/hooks","issue_events_url":"https://api.github.com/repos/alexsku/dotnet/issues/events{/number}","events_url":"https://api.github.com/repos/alexsku/dotnet/events","assignees_url":"https://api.github.com/repos/alexsku/dotnet/assignees{/user}","branches_url":"https://api.github.com/repos/alexsku/dotnet/branches{/branch}","tags_url":"https://api.github.com/repos/alexsku/dotnet/tags","blobs_url":"https://api.github.com/repos/alexsku/dotnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexsku/dotnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexsku/dotnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexsku/dotnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexsku/dotnet/statuses/{sha}","languages_url":"https://api.github.com/repos/alexsku/dotnet/languages","stargazers_url":"https://api.github.com/repos/alexsku/dotnet/stargazers","contributors_url":"https://api.github.com/repos/alexsku/dotnet/contributors","subscribers_url":"https://api.github.com/repos/alexsku/dotnet/subscribers","subscription_url":"https://api.github.com/repos/alexsku/dotnet/subscription","commits_url":"https://api.github.com/repos/alexsku/dotnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexsku/dotnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexsku/dotnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexsku/dotnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexsku/dotnet/contents/{+path}","compare_url":"https://api.github.com/repos/alexsku/dotnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexsku/dotnet/merges","archive_url":"https://api.github.com/repos/alexsku/dotnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexsku/dotnet/downloads","issues_url":"https://api.github.com/repos/alexsku/dotnet/issues{/number}","pulls_url":"https://api.github.com/repos/alexsku/dotnet/pulls{/number}","milestones_url":"https://api.github.com/repos/alexsku/dotnet/milestones{/number}","notifications_url":"https://api.github.com/repos/alexsku/dotnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexsku/dotnet/labels{/name}","releases_url":"https://api.github.com/repos/alexsku/dotnet/releases{/id}","deployments_url":"https://api.github.com/repos/alexsku/dotnet/deployments","created_at":"2016-12-14T02:21:02Z","updated_at":"2016-12-14T02:21:04Z","pushed_at":"2016-12-22T22:33:11Z","git_url":"git://github.com/alexsku/dotnet.git","ssh_url":"git@github.com:alexsku/dotnet.git","clone_url":"https://github.com/alexsku/dotnet.git","svn_url":"https://github.com/alexsku/dotnet","homepage":null,"size":50414,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"MiniProfiler:v4","ref":"v4","sha":"309ec37f971c69b41e6c89f9aaf72a5635e6b7b6","user":{"login":"MiniProfiler","id":1631473,"avatar_url":"https://avatars.githubusercontent.com/u/1631473?v=3","gravatar_id":"","url":"https://api.github.com/users/MiniProfiler","html_url":"https://github.com/MiniProfiler","followers_url":"https://api.github.com/users/MiniProfiler/followers","following_url":"https://api.github.com/users/MiniProfiler/following{/other_user}","gists_url":"https://api.github.com/users/MiniProfiler/gists{/gist_id}","starred_url":"https://api.github.com/users/MiniProfiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MiniProfiler/subscriptions","organizations_url":"https://api.github.com/users/MiniProfiler/orgs","repos_url":"https://api.github.com/users/MiniProfiler/repos","events_url":"https://api.github.com/users/MiniProfiler/events{/privacy}","received_events_url":"https://api.github.com/users/MiniProfiler/received_events","type":"Organization","site_admin":false},"repo":{"id":11906821,"name":"dotnet","full_name":"MiniProfiler/dotnet","owner":{"login":"MiniProfiler","id":1631473,"avatar_url":"https://avatars.githubusercontent.com/u/1631473?v=3","gravatar_id":"","url":"https://api.github.com/users/MiniProfiler","html_url":"https://github.com/MiniProfiler","followers_url":"https://api.github.com/users/MiniProfiler/followers","following_url":"https://api.github.com/users/MiniProfiler/following{/other_user}","gists_url":"https://api.github.com/users/MiniProfiler/gists{/gist_id}","starred_url":"https://api.github.com/users/MiniProfiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MiniProfiler/subscriptions","organizations_url":"https://api.github.com/users/MiniProfiler/orgs","repos_url":"https://api.github.com/users/MiniProfiler/repos","events_url":"https://api.github.com/users/MiniProfiler/events{/privacy}","received_events_url":"https://api.github.com/users/MiniProfiler/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MiniProfiler/dotnet","description":"A simple but effective mini-profiler for ASP.NET websites","fork":false,"url":"https://api.github.com/repos/MiniProfiler/dotnet","forks_url":"https://api.github.com/repos/MiniProfiler/dotnet/forks","keys_url":"https://api.github.com/repos/MiniProfiler/dotnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MiniProfiler/dotnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MiniProfiler/dotnet/teams","hooks_url":"https://api.github.com/repos/MiniProfiler/dotnet/hooks","issue_events_url":"https://api.github.com/repos/MiniProfiler/dotnet/issues/events{/number}","events_url":"https://api.github.com/repos/MiniProfiler/dotnet/events","assignees_url":"https://api.github.com/repos/MiniProfiler/dotnet/assignees{/user}","branches_url":"https://api.github.com/repos/MiniProfiler/dotnet/branches{/branch}","tags_url":"https://api.github.com/repos/MiniProfiler/dotnet/tags","blobs_url":"https://api.github.com/repos/MiniProfiler/dotnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MiniProfiler/dotnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MiniProfiler/dotnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/MiniProfiler/dotnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MiniProfiler/dotnet/statuses/{sha}","languages_url":"https://api.github.com/repos/MiniProfiler/dotnet/languages","stargazers_url":"https://api.github.com/repos/MiniProfiler/dotnet/stargazers","contributors_url":"https://api.github.com/repos/MiniProfiler/dotnet/contributors","subscribers_url":"https://api.github.com/repos/MiniProfiler/dotnet/subscribers","subscription_url":"https://api.github.com/repos/MiniProfiler/dotnet/subscription","commits_url":"https://api.github.com/repos/MiniProfiler/dotnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/MiniProfiler/dotnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/MiniProfiler/dotnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/MiniProfiler/dotnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/MiniProfiler/dotnet/contents/{+path}","compare_url":"https://api.github.com/repos/MiniProfiler/dotnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MiniProfiler/dotnet/merges","archive_url":"https://api.github.com/repos/MiniProfiler/dotnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MiniProfiler/dotnet/downloads","issues_url":"https://api.github.com/repos/MiniProfiler/dotnet/issues{/number}","pulls_url":"https://api.github.com/repos/MiniProfiler/dotnet/pulls{/number}","milestones_url":"https://api.github.com/repos/MiniProfiler/dotnet/milestones{/number}","notifications_url":"https://api.github.com/repos/MiniProfiler/dotnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MiniProfiler/dotnet/labels{/name}","releases_url":"https://api.github.com/repos/MiniProfiler/dotnet/releases{/id}","deployments_url":"https://api.github.com/repos/MiniProfiler/dotnet/deployments","created_at":"2013-08-05T19:29:15Z","updated_at":"2016-12-22T09:21:28Z","pushed_at":"2016-12-22T21:58:27Z","git_url":"git://github.com/MiniProfiler/dotnet.git","ssh_url":"git@github.com:MiniProfiler/dotnet.git","clone_url":"https://github.com/MiniProfiler/dotnet.git","svn_url":"https://github.com/MiniProfiler/dotnet","homepage":null,"size":50375,"stargazers_count":795,"watchers_count":795,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":245,"mirror_url":null,"open_issues_count":21,"forks":245,"open_issues":21,"watchers":795,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/147"},"html":{"href":"https://github.com/MiniProfiler/dotnet/pull/147"},"issue":{"href":"https://api.github.com/repos/MiniProfiler/dotnet/issues/147"},"comments":{"href":"https://api.github.com/repos/MiniProfiler/dotnet/issues/147/comments"},"review_comments":{"href":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/147/comments"},"review_comment":{"href":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MiniProfiler/dotnet/pulls/147/commits"},"statuses":{"href":"https://api.github.com/repos/MiniProfiler/dotnet/statuses/0000723ee52536b7067197ff164d4af681d86337"}}}}
{"actor":{"display_login":"NickCraver"}}