{"action":"created","comment":{"url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/comments/121542341","pull_request_review_id":43580132,"id":121542341,"diff_hunk":"@@ -31,18 +35,27 @@ object Invoker {\n     // times since for coverage we only care about 1 or more, (it just slows things down to\n     // do it more than once), anything we can do to help is good. This helps especially with code\n     // that is executed many times quickly, eg tight loops.\n-    if (!ids.contains(dataDir, id)) {\n+    if (!dataDirToIds.contains(dataDir)) {\n+      // Guard against SI-7943: \"TrieMap method getOrElseUpdate is not thread-safe\".","path":"scalac-scoverage-runtime/shared/src/main/scala/scoverage/Invoker.scala","position":21,"original_position":21,"commit_id":"4626fd8d3c0705b2a7fc7e11932508231c8fcead","original_commit_id":"4626fd8d3c0705b2a7fc7e11932508231c8fcead","user":{"login":"JoshRosen","id":50748,"avatar_url":"https://avatars3.githubusercontent.com/u/50748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshRosen","html_url":"https://github.com/JoshRosen","followers_url":"https://api.github.com/users/JoshRosen/followers","following_url":"https://api.github.com/users/JoshRosen/following{/other_user}","gists_url":"https://api.github.com/users/JoshRosen/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshRosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshRosen/subscriptions","organizations_url":"https://api.github.com/users/JoshRosen/orgs","repos_url":"https://api.github.com/users/JoshRosen/repos","events_url":"https://api.github.com/users/JoshRosen/events{/privacy}","received_events_url":"https://api.github.com/users/JoshRosen/received_events","type":"User","site_admin":false},"body":"I noticed that this was also calling `getOrElseUpdate` on a `TrieMap` down in `files.getOrElseUpdate`, but that case wasn't an issue because that map is used only in a single thread (since it comes from a non-inheritable `ThreadLocal`).\r\n\r\nTo help make this clearer in the code, I went ahead and used a plain `mutable.HashMap` at that other site.","created_at":"2017-06-12T22:27:40Z","updated_at":"2017-06-12T22:27:40Z","html_url":"https://github.com/scoverage/scalac-scoverage-plugin/pull/202#discussion_r121542341","pull_request_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/202","_links":{"self":{"href":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/comments/121542341"},"html":{"href":"https://github.com/scoverage/scalac-scoverage-plugin/pull/202#discussion_r121542341"},"pull_request":{"href":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/202"}}},"pull_request":{"url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/202","id":125242796,"html_url":"https://github.com/scoverage/scalac-scoverage-plugin/pull/202","diff_url":"https://github.com/scoverage/scalac-scoverage-plugin/pull/202.diff","patch_url":"https://github.com/scoverage/scalac-scoverage-plugin/pull/202.patch","issue_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/issues/202","number":202,"state":"open","locked":false,"title":"Reduce performance overhead of map lookups in Invoker.invoked()","user":{"login":"JoshRosen","id":50748,"avatar_url":"https://avatars3.githubusercontent.com/u/50748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshRosen","html_url":"https://github.com/JoshRosen","followers_url":"https://api.github.com/users/JoshRosen/followers","following_url":"https://api.github.com/users/JoshRosen/following{/other_user}","gists_url":"https://api.github.com/users/JoshRosen/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshRosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshRosen/subscriptions","organizations_url":"https://api.github.com/users/JoshRosen/orgs","repos_url":"https://api.github.com/users/JoshRosen/repos","events_url":"https://api.github.com/users/JoshRosen/events{/privacy}","received_events_url":"https://api.github.com/users/JoshRosen/received_events","type":"User","site_admin":false},"body":"`Invoker.invoked()` is showing up as a performance hotspot in my tests. For full details of my investigation, see #201.\r\n\r\nIn my profiling, half of the time in `Invoker.invoked()` was spent computing hashCodes when indexing into the `ids` map, which is a `ThreadSafeMap[(String, Int), Any]`. This PR replaces the single-level map by a two-level `ThreadSafeMap[String, ThreadSafeMap[Int, Any]]` map. This isn't much more space because the `String` part of the key is usually constant and it's not a whole lot of extra lookup time either because the outer map typically has at most one element.\r\n\r\nAfter making this change I no longer saw map lookups as a bottleneck; instead, all of the time shifted to `flush()` calls (which I plan to address in a separate PR; see discussion at #201).\r\n\r\nI also made a small micro-optimization to avoid unnecessary int boxing and implicit `StringBuilder` construction.","created_at":"2017-06-12T22:23:50Z","updated_at":"2017-06-12T22:27:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"114e927ca6751cc075ecbc10d1c63a0e4eb0b680","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/202/commits","review_comments_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/202/comments","review_comment_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/issues/202/comments","statuses_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/statuses/4626fd8d3c0705b2a7fc7e11932508231c8fcead","head":{"label":"JoshRosen:Invoker-map-lookup-performance-improvements","ref":"Invoker-map-lookup-performance-improvements","sha":"4626fd8d3c0705b2a7fc7e11932508231c8fcead","user":{"login":"JoshRosen","id":50748,"avatar_url":"https://avatars3.githubusercontent.com/u/50748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshRosen","html_url":"https://github.com/JoshRosen","followers_url":"https://api.github.com/users/JoshRosen/followers","following_url":"https://api.github.com/users/JoshRosen/following{/other_user}","gists_url":"https://api.github.com/users/JoshRosen/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshRosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshRosen/subscriptions","organizations_url":"https://api.github.com/users/JoshRosen/orgs","repos_url":"https://api.github.com/users/JoshRosen/repos","events_url":"https://api.github.com/users/JoshRosen/events{/privacy}","received_events_url":"https://api.github.com/users/JoshRosen/received_events","type":"User","site_admin":false},"repo":{"id":93888179,"name":"scalac-scoverage-plugin","full_name":"JoshRosen/scalac-scoverage-plugin","owner":{"login":"JoshRosen","id":50748,"avatar_url":"https://avatars3.githubusercontent.com/u/50748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshRosen","html_url":"https://github.com/JoshRosen","followers_url":"https://api.github.com/users/JoshRosen/followers","following_url":"https://api.github.com/users/JoshRosen/following{/other_user}","gists_url":"https://api.github.com/users/JoshRosen/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshRosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshRosen/subscriptions","organizations_url":"https://api.github.com/users/JoshRosen/orgs","repos_url":"https://api.github.com/users/JoshRosen/repos","events_url":"https://api.github.com/users/JoshRosen/events{/privacy}","received_events_url":"https://api.github.com/users/JoshRosen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JoshRosen/scalac-scoverage-plugin","description":"Scoverage Scala Code Coverage Core Libs","fork":true,"url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin","forks_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/forks","keys_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/teams","hooks_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/hooks","issue_events_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/events","assignees_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/tags","blobs_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/languages","stargazers_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/stargazers","contributors_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/contributors","subscribers_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/subscribers","subscription_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/subscription","commits_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/merges","archive_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/downloads","issues_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/labels{/name}","releases_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/JoshRosen/scalac-scoverage-plugin/deployments","created_at":"2017-06-09T18:52:28Z","updated_at":"2017-06-09T18:52:29Z","pushed_at":"2017-06-12T22:13:29Z","git_url":"git://github.com/JoshRosen/scalac-scoverage-plugin.git","ssh_url":"git@github.com:JoshRosen/scalac-scoverage-plugin.git","clone_url":"https://github.com/JoshRosen/scalac-scoverage-plugin.git","svn_url":"https://github.com/JoshRosen/scalac-scoverage-plugin","homepage":"http://scoverage.org","size":5797,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"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":"scoverage:master","ref":"master","sha":"715d76b8ae490a93646e6b38f22fb046b1ce7477","user":{"login":"scoverage","id":5998302,"avatar_url":"https://avatars3.githubusercontent.com/u/5998302?v=3","gravatar_id":"","url":"https://api.github.com/users/scoverage","html_url":"https://github.com/scoverage","followers_url":"https://api.github.com/users/scoverage/followers","following_url":"https://api.github.com/users/scoverage/following{/other_user}","gists_url":"https://api.github.com/users/scoverage/gists{/gist_id}","starred_url":"https://api.github.com/users/scoverage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scoverage/subscriptions","organizations_url":"https://api.github.com/users/scoverage/orgs","repos_url":"https://api.github.com/users/scoverage/repos","events_url":"https://api.github.com/users/scoverage/events{/privacy}","received_events_url":"https://api.github.com/users/scoverage/received_events","type":"Organization","site_admin":false},"repo":{"id":14709196,"name":"scalac-scoverage-plugin","full_name":"scoverage/scalac-scoverage-plugin","owner":{"login":"scoverage","id":5998302,"avatar_url":"https://avatars3.githubusercontent.com/u/5998302?v=3","gravatar_id":"","url":"https://api.github.com/users/scoverage","html_url":"https://github.com/scoverage","followers_url":"https://api.github.com/users/scoverage/followers","following_url":"https://api.github.com/users/scoverage/following{/other_user}","gists_url":"https://api.github.com/users/scoverage/gists{/gist_id}","starred_url":"https://api.github.com/users/scoverage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scoverage/subscriptions","organizations_url":"https://api.github.com/users/scoverage/orgs","repos_url":"https://api.github.com/users/scoverage/repos","events_url":"https://api.github.com/users/scoverage/events{/privacy}","received_events_url":"https://api.github.com/users/scoverage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scoverage/scalac-scoverage-plugin","description":"Scoverage Scala Code Coverage Core Libs","fork":false,"url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin","forks_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/forks","keys_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/teams","hooks_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/hooks","issue_events_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/events","assignees_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/tags","blobs_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/languages","stargazers_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/stargazers","contributors_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/contributors","subscribers_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/subscribers","subscription_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/subscription","commits_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/merges","archive_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/downloads","issues_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/labels{/name}","releases_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/deployments","created_at":"2013-11-26T06:47:38Z","updated_at":"2017-05-22T18:02:47Z","pushed_at":"2017-06-12T22:23:51Z","git_url":"git://github.com/scoverage/scalac-scoverage-plugin.git","ssh_url":"git@github.com:scoverage/scalac-scoverage-plugin.git","clone_url":"https://github.com/scoverage/scalac-scoverage-plugin.git","svn_url":"https://github.com/scoverage/scalac-scoverage-plugin","homepage":"http://scoverage.org","size":5797,"stargazers_count":272,"watchers_count":272,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":75,"mirror_url":null,"open_issues_count":42,"forks":75,"open_issues":42,"watchers":272,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/202"},"html":{"href":"https://github.com/scoverage/scalac-scoverage-plugin/pull/202"},"issue":{"href":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/issues/202"},"comments":{"href":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/issues/202/comments"},"review_comments":{"href":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/202/comments"},"review_comment":{"href":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/pulls/202/commits"},"statuses":{"href":"https://api.github.com/repos/scoverage/scalac-scoverage-plugin/statuses/4626fd8d3c0705b2a7fc7e11932508231c8fcead"}}}}
{"actor":{"display_login":"JoshRosen"}}