{"action":"created","comment":{"url":"https://api.github.com/repos/PragTob/benchee/pulls/comments/206967292","pull_request_review_id":142484030,"id":206967292,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjk2NzI5Mg==","diff_hunk":"@@ -44,17 +55,22 @@ defmodule Benchee.Benchmark.Measure.Memory do\n   defp return_memory({memory_usage, result}) when memory_usage < 0, do: {nil, result}\n   defp return_memory({memory_usage, result}), do: {memory_usage, result}\n \n-  defp measure_memory(fun, tracer) do\n-    word_size = :erlang.system_info(:wordsize)\n-    {:garbage_collection_info, heap_before} = Process.info(self(), :garbage_collection_info)\n-    result = fun.()\n-    {:garbage_collection_info, heap_after} = Process.info(self(), :garbage_collection_info)\n-    mem_collected = get_collected_memory(tracer)\n+  defp measure_memory(fun, tracer, parent) do\n+    :erlang.garbage_collect()\n+    send(tracer, :begin_collection)\n \n-    memory_used =\n-      (total_memory(heap_after) - total_memory(heap_before) + mem_collected) * word_size\n+    receive do\n+      :ready -> nil\n+    end\n \n-    {memory_used, result}\n+    result = fun.()\n+    send(parent, {:result, result})\n+    :erlang.garbage_collect()\n+    send(tracer, :end_collection)\n+\n+    receive do\n+      :ready -> nil","path":"lib/benchee/benchmark/measure/memory.ex","position":62,"original_position":62,"commit_id":"8e205179dfdbec501f63e60651f5c4780da955f6","original_commit_id":"8e205179dfdbec501f63e60651f5c4780da955f6","user":{"login":"devonestes","id":8422484,"node_id":"MDQ6VXNlcjg0MjI0ODQ=","avatar_url":"https://avatars1.githubusercontent.com/u/8422484?v=4","gravatar_id":"","url":"https://api.github.com/users/devonestes","html_url":"https://github.com/devonestes","followers_url":"https://api.github.com/users/devonestes/followers","following_url":"https://api.github.com/users/devonestes/following{/other_user}","gists_url":"https://api.github.com/users/devonestes/gists{/gist_id}","starred_url":"https://api.github.com/users/devonestes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devonestes/subscriptions","organizations_url":"https://api.github.com/users/devonestes/orgs","repos_url":"https://api.github.com/users/devonestes/repos","events_url":"https://api.github.com/users/devonestes/events{/privacy}","received_events_url":"https://api.github.com/users/devonestes/received_events","type":"User","site_admin":false},"body":"I'm cool with `:ready_to_begin` and `:ready_to_finish`. It _shouldn't_ be possible for there to be any race conditions because at this point it's essentially synchronous (which is why we're blocking with `receive` while waiting for a response from the tracer), but it's always better to be safe than sorry!","created_at":"2018-08-01T17:31:31Z","updated_at":"2018-08-01T17:31:31Z","html_url":"https://github.com/PragTob/benchee/pull/239#discussion_r206967292","pull_request_url":"https://api.github.com/repos/PragTob/benchee/pulls/239","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/PragTob/benchee/pulls/comments/206967292"},"html":{"href":"https://github.com/PragTob/benchee/pull/239#discussion_r206967292"},"pull_request":{"href":"https://api.github.com/repos/PragTob/benchee/pulls/239"}},"in_reply_to_id":206961493},"pull_request":{"url":"https://api.github.com/repos/PragTob/benchee/pulls/239","id":205399566,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1Mzk5NTY2","html_url":"https://github.com/PragTob/benchee/pull/239","diff_url":"https://github.com/PragTob/benchee/pull/239.diff","patch_url":"https://github.com/PragTob/benchee/pull/239.patch","issue_url":"https://api.github.com/repos/PragTob/benchee/issues/239","number":239,"state":"open","locked":false,"title":"Fix race condition in spawning tracer process","user":{"login":"devonestes","id":8422484,"node_id":"MDQ6VXNlcjg0MjI0ODQ=","avatar_url":"https://avatars1.githubusercontent.com/u/8422484?v=4","gravatar_id":"","url":"https://api.github.com/users/devonestes","html_url":"https://github.com/devonestes","followers_url":"https://api.github.com/users/devonestes/followers","following_url":"https://api.github.com/users/devonestes/following{/other_user}","gists_url":"https://api.github.com/users/devonestes/gists{/gist_id}","starred_url":"https://api.github.com/users/devonestes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devonestes/subscriptions","organizations_url":"https://api.github.com/users/devonestes/orgs","repos_url":"https://api.github.com/users/devonestes/repos","events_url":"https://api.github.com/users/devonestes/events{/privacy}","received_events_url":"https://api.github.com/users/devonestes/received_events","type":"User","site_admin":false},"body":"We were somewhat reliably missing the first garbage collection event\r\nbecause when we spawned our tracer, we were setting the tracing flag in\r\nthe function to be executed in our tracer. This means the runner and\r\ntracer were running concurrently for a moment, and the runner hit a GC\r\nthreshold before the tracer was able to set the appropriate tracing\r\nflag!\r\n\r\nNow we explicitly block the runner from running the function to be run\r\nuntil the tracing flag is set.\r\n\r\nWith this patch applied I now see all the GC events that we should see.\r\n\r\nAlso, I have absolutely no idea how to test this other than the tests we\r\nalready had in place.","created_at":"2018-08-01T11:52:11Z","updated_at":"2018-08-01T17:31:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7db45c62e9c5e9644975a69d9f5989e1fdd81a6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/PragTob/benchee/pulls/239/commits","review_comments_url":"https://api.github.com/repos/PragTob/benchee/pulls/239/comments","review_comment_url":"https://api.github.com/repos/PragTob/benchee/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PragTob/benchee/issues/239/comments","statuses_url":"https://api.github.com/repos/PragTob/benchee/statuses/8e205179dfdbec501f63e60651f5c4780da955f6","head":{"label":"PragTob:fix-race-condition-with-tracer","ref":"fix-race-condition-with-tracer","sha":"8e205179dfdbec501f63e60651f5c4780da955f6","user":{"login":"PragTob","id":606517,"node_id":"MDQ6VXNlcjYwNjUxNw==","avatar_url":"https://avatars1.githubusercontent.com/u/606517?v=4","gravatar_id":"","url":"https://api.github.com/users/PragTob","html_url":"https://github.com/PragTob","followers_url":"https://api.github.com/users/PragTob/followers","following_url":"https://api.github.com/users/PragTob/following{/other_user}","gists_url":"https://api.github.com/users/PragTob/gists{/gist_id}","starred_url":"https://api.github.com/users/PragTob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PragTob/subscriptions","organizations_url":"https://api.github.com/users/PragTob/orgs","repos_url":"https://api.github.com/users/PragTob/repos","events_url":"https://api.github.com/users/PragTob/events{/privacy}","received_events_url":"https://api.github.com/users/PragTob/received_events","type":"User","site_admin":false},"repo":{"id":59428665,"node_id":"MDEwOlJlcG9zaXRvcnk1OTQyODY2NQ==","name":"benchee","full_name":"PragTob/benchee","owner":{"login":"PragTob","id":606517,"node_id":"MDQ6VXNlcjYwNjUxNw==","avatar_url":"https://avatars1.githubusercontent.com/u/606517?v=4","gravatar_id":"","url":"https://api.github.com/users/PragTob","html_url":"https://github.com/PragTob","followers_url":"https://api.github.com/users/PragTob/followers","following_url":"https://api.github.com/users/PragTob/following{/other_user}","gists_url":"https://api.github.com/users/PragTob/gists{/gist_id}","starred_url":"https://api.github.com/users/PragTob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PragTob/subscriptions","organizations_url":"https://api.github.com/users/PragTob/orgs","repos_url":"https://api.github.com/users/PragTob/repos","events_url":"https://api.github.com/users/PragTob/events{/privacy}","received_events_url":"https://api.github.com/users/PragTob/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PragTob/benchee","description":"Easy and extensible benchmarking in Elixir providing you with lots of statistics!","fork":false,"url":"https://api.github.com/repos/PragTob/benchee","forks_url":"https://api.github.com/repos/PragTob/benchee/forks","keys_url":"https://api.github.com/repos/PragTob/benchee/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PragTob/benchee/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PragTob/benchee/teams","hooks_url":"https://api.github.com/repos/PragTob/benchee/hooks","issue_events_url":"https://api.github.com/repos/PragTob/benchee/issues/events{/number}","events_url":"https://api.github.com/repos/PragTob/benchee/events","assignees_url":"https://api.github.com/repos/PragTob/benchee/assignees{/user}","branches_url":"https://api.github.com/repos/PragTob/benchee/branches{/branch}","tags_url":"https://api.github.com/repos/PragTob/benchee/tags","blobs_url":"https://api.github.com/repos/PragTob/benchee/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PragTob/benchee/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PragTob/benchee/git/refs{/sha}","trees_url":"https://api.github.com/repos/PragTob/benchee/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PragTob/benchee/statuses/{sha}","languages_url":"https://api.github.com/repos/PragTob/benchee/languages","stargazers_url":"https://api.github.com/repos/PragTob/benchee/stargazers","contributors_url":"https://api.github.com/repos/PragTob/benchee/contributors","subscribers_url":"https://api.github.com/repos/PragTob/benchee/subscribers","subscription_url":"https://api.github.com/repos/PragTob/benchee/subscription","commits_url":"https://api.github.com/repos/PragTob/benchee/commits{/sha}","git_commits_url":"https://api.github.com/repos/PragTob/benchee/git/commits{/sha}","comments_url":"https://api.github.com/repos/PragTob/benchee/comments{/number}","issue_comment_url":"https://api.github.com/repos/PragTob/benchee/issues/comments{/number}","contents_url":"https://api.github.com/repos/PragTob/benchee/contents/{+path}","compare_url":"https://api.github.com/repos/PragTob/benchee/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PragTob/benchee/merges","archive_url":"https://api.github.com/repos/PragTob/benchee/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PragTob/benchee/downloads","issues_url":"https://api.github.com/repos/PragTob/benchee/issues{/number}","pulls_url":"https://api.github.com/repos/PragTob/benchee/pulls{/number}","milestones_url":"https://api.github.com/repos/PragTob/benchee/milestones{/number}","notifications_url":"https://api.github.com/repos/PragTob/benchee/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PragTob/benchee/labels{/name}","releases_url":"https://api.github.com/repos/PragTob/benchee/releases{/id}","deployments_url":"https://api.github.com/repos/PragTob/benchee/deployments","created_at":"2016-05-22T18:48:43Z","updated_at":"2018-08-01T11:54:53Z","pushed_at":"2018-08-01T13:37:37Z","git_url":"git://github.com/PragTob/benchee.git","ssh_url":"git@github.com:PragTob/benchee.git","clone_url":"https://github.com/PragTob/benchee.git","svn_url":"https://github.com/PragTob/benchee","homepage":"","size":1063,"stargazers_count":474,"watchers_count":474,"language":"Elixir","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"archived":false,"open_issues_count":22,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":27,"open_issues":22,"watchers":474,"default_branch":"master"}},"base":{"label":"PragTob:master","ref":"master","sha":"dc6c814798e278689d2446ec0f9a14fda6fde4ba","user":{"login":"PragTob","id":606517,"node_id":"MDQ6VXNlcjYwNjUxNw==","avatar_url":"https://avatars1.githubusercontent.com/u/606517?v=4","gravatar_id":"","url":"https://api.github.com/users/PragTob","html_url":"https://github.com/PragTob","followers_url":"https://api.github.com/users/PragTob/followers","following_url":"https://api.github.com/users/PragTob/following{/other_user}","gists_url":"https://api.github.com/users/PragTob/gists{/gist_id}","starred_url":"https://api.github.com/users/PragTob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PragTob/subscriptions","organizations_url":"https://api.github.com/users/PragTob/orgs","repos_url":"https://api.github.com/users/PragTob/repos","events_url":"https://api.github.com/users/PragTob/events{/privacy}","received_events_url":"https://api.github.com/users/PragTob/received_events","type":"User","site_admin":false},"repo":{"id":59428665,"node_id":"MDEwOlJlcG9zaXRvcnk1OTQyODY2NQ==","name":"benchee","full_name":"PragTob/benchee","owner":{"login":"PragTob","id":606517,"node_id":"MDQ6VXNlcjYwNjUxNw==","avatar_url":"https://avatars1.githubusercontent.com/u/606517?v=4","gravatar_id":"","url":"https://api.github.com/users/PragTob","html_url":"https://github.com/PragTob","followers_url":"https://api.github.com/users/PragTob/followers","following_url":"https://api.github.com/users/PragTob/following{/other_user}","gists_url":"https://api.github.com/users/PragTob/gists{/gist_id}","starred_url":"https://api.github.com/users/PragTob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PragTob/subscriptions","organizations_url":"https://api.github.com/users/PragTob/orgs","repos_url":"https://api.github.com/users/PragTob/repos","events_url":"https://api.github.com/users/PragTob/events{/privacy}","received_events_url":"https://api.github.com/users/PragTob/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PragTob/benchee","description":"Easy and extensible benchmarking in Elixir providing you with lots of statistics!","fork":false,"url":"https://api.github.com/repos/PragTob/benchee","forks_url":"https://api.github.com/repos/PragTob/benchee/forks","keys_url":"https://api.github.com/repos/PragTob/benchee/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PragTob/benchee/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PragTob/benchee/teams","hooks_url":"https://api.github.com/repos/PragTob/benchee/hooks","issue_events_url":"https://api.github.com/repos/PragTob/benchee/issues/events{/number}","events_url":"https://api.github.com/repos/PragTob/benchee/events","assignees_url":"https://api.github.com/repos/PragTob/benchee/assignees{/user}","branches_url":"https://api.github.com/repos/PragTob/benchee/branches{/branch}","tags_url":"https://api.github.com/repos/PragTob/benchee/tags","blobs_url":"https://api.github.com/repos/PragTob/benchee/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PragTob/benchee/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PragTob/benchee/git/refs{/sha}","trees_url":"https://api.github.com/repos/PragTob/benchee/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PragTob/benchee/statuses/{sha}","languages_url":"https://api.github.com/repos/PragTob/benchee/languages","stargazers_url":"https://api.github.com/repos/PragTob/benchee/stargazers","contributors_url":"https://api.github.com/repos/PragTob/benchee/contributors","subscribers_url":"https://api.github.com/repos/PragTob/benchee/subscribers","subscription_url":"https://api.github.com/repos/PragTob/benchee/subscription","commits_url":"https://api.github.com/repos/PragTob/benchee/commits{/sha}","git_commits_url":"https://api.github.com/repos/PragTob/benchee/git/commits{/sha}","comments_url":"https://api.github.com/repos/PragTob/benchee/comments{/number}","issue_comment_url":"https://api.github.com/repos/PragTob/benchee/issues/comments{/number}","contents_url":"https://api.github.com/repos/PragTob/benchee/contents/{+path}","compare_url":"https://api.github.com/repos/PragTob/benchee/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PragTob/benchee/merges","archive_url":"https://api.github.com/repos/PragTob/benchee/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PragTob/benchee/downloads","issues_url":"https://api.github.com/repos/PragTob/benchee/issues{/number}","pulls_url":"https://api.github.com/repos/PragTob/benchee/pulls{/number}","milestones_url":"https://api.github.com/repos/PragTob/benchee/milestones{/number}","notifications_url":"https://api.github.com/repos/PragTob/benchee/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PragTob/benchee/labels{/name}","releases_url":"https://api.github.com/repos/PragTob/benchee/releases{/id}","deployments_url":"https://api.github.com/repos/PragTob/benchee/deployments","created_at":"2016-05-22T18:48:43Z","updated_at":"2018-08-01T11:54:53Z","pushed_at":"2018-08-01T13:37:37Z","git_url":"git://github.com/PragTob/benchee.git","ssh_url":"git@github.com:PragTob/benchee.git","clone_url":"https://github.com/PragTob/benchee.git","svn_url":"https://github.com/PragTob/benchee","homepage":"","size":1063,"stargazers_count":474,"watchers_count":474,"language":"Elixir","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"archived":false,"open_issues_count":22,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":27,"open_issues":22,"watchers":474,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PragTob/benchee/pulls/239"},"html":{"href":"https://github.com/PragTob/benchee/pull/239"},"issue":{"href":"https://api.github.com/repos/PragTob/benchee/issues/239"},"comments":{"href":"https://api.github.com/repos/PragTob/benchee/issues/239/comments"},"review_comments":{"href":"https://api.github.com/repos/PragTob/benchee/pulls/239/comments"},"review_comment":{"href":"https://api.github.com/repos/PragTob/benchee/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PragTob/benchee/pulls/239/commits"},"statuses":{"href":"https://api.github.com/repos/PragTob/benchee/statuses/8e205179dfdbec501f63e60651f5c4780da955f6"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"devonestes"}}