{"action":"created","comment":{"url":"https://api.github.com/repos/m3db/m3msg/pulls/comments/192784170","pull_request_review_id":125619928,"id":192784170,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5Mjc4NDE3MA==","diff_hunk":"@@ -405,25 +410,23 @@ func (w *messageWriterImpl) SetCutoverNanos(nanos int64) {\n \tw.Unlock()\n }\n \n-func (w *messageWriterImpl) AddConsumerWriter(addr string, cw consumerWriter) {\n+func (w *messageWriterImpl) AddConsumerWriter(cw consumerWriter) {\n \tw.Lock()\n-\tnewConsumerWriters := make(map[string]consumerWriter, len(w.consumerWriters)+1)\n-\tfor key, cw := range w.consumerWriters {\n-\t\tnewConsumerWriters[key] = cw\n-\t}\n-\tnewConsumerWriters[addr] = cw\n+\tnewConsumerWriters := make([]consumerWriter, 0, len(w.consumerWriters)+1)\n+\tnewConsumerWriters = append(newConsumerWriters, w.consumerWriters...)\n+\tnewConsumerWriters = append(newConsumerWriters, cw)\n \tw.consumerWriters = newConsumerWriters\n \tw.Unlock()\n }\n \n func (w *messageWriterImpl) RemoveConsumerWriter(addr string) {\n \tw.Lock()\n-\tnewConsumerWriters := make(map[string]consumerWriter, len(w.consumerWriters)-1)\n-\tfor key, cw := range w.consumerWriters {\n-\t\tif key == addr {\n+\tnewConsumerWriters := make([]consumerWriter, 0, len(w.consumerWriters)-1)","path":"producer/writer/message_writer.go","position":81,"original_position":81,"commit_id":"753c9631739276d057f971fe5237434a8a92fbff","original_commit_id":"753c9631739276d057f971fe5237434a8a92fbff","user":{"login":"xichen2020","id":12239421,"node_id":"MDQ6VXNlcjEyMjM5NDIx","avatar_url":"https://avatars1.githubusercontent.com/u/12239421?v=4","gravatar_id":"","url":"https://api.github.com/users/xichen2020","html_url":"https://github.com/xichen2020","followers_url":"https://api.github.com/users/xichen2020/followers","following_url":"https://api.github.com/users/xichen2020/following{/other_user}","gists_url":"https://api.github.com/users/xichen2020/gists{/gist_id}","starred_url":"https://api.github.com/users/xichen2020/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xichen2020/subscriptions","organizations_url":"https://api.github.com/users/xichen2020/orgs","repos_url":"https://api.github.com/users/xichen2020/repos","events_url":"https://api.github.com/users/xichen2020/events{/privacy}","received_events_url":"https://api.github.com/users/xichen2020/received_events","type":"User","site_admin":false},"body":"Same question as above","created_at":"2018-06-04T15:32:50Z","updated_at":"2018-06-04T15:36:49Z","html_url":"https://github.com/m3db/m3msg/pull/23#discussion_r192784170","pull_request_url":"https://api.github.com/repos/m3db/m3msg/pulls/23","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/m3db/m3msg/pulls/comments/192784170"},"html":{"href":"https://github.com/m3db/m3msg/pull/23#discussion_r192784170"},"pull_request":{"href":"https://api.github.com/repos/m3db/m3msg/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/m3db/m3msg/pulls/23","id":192260772,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyMjYwNzcy","html_url":"https://github.com/m3db/m3msg/pull/23","diff_url":"https://github.com/m3db/m3msg/pull/23.diff","patch_url":"https://github.com/m3db/m3msg/pull/23.patch","issue_url":"https://api.github.com/repos/m3db/m3msg/issues/23","number":23,"state":"closed","locked":false,"title":"Improve fairness in consumer selection","user":{"login":"cw9","id":6710599,"node_id":"MDQ6VXNlcjY3MTA1OTk=","avatar_url":"https://avatars0.githubusercontent.com/u/6710599?v=4","gravatar_id":"","url":"https://api.github.com/users/cw9","html_url":"https://github.com/cw9","followers_url":"https://api.github.com/users/cw9/followers","following_url":"https://api.github.com/users/cw9/following{/other_user}","gists_url":"https://api.github.com/users/cw9/gists{/gist_id}","starred_url":"https://api.github.com/users/cw9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cw9/subscriptions","organizations_url":"https://api.github.com/users/cw9/orgs","repos_url":"https://api.github.com/users/cw9/repos","events_url":"https://api.github.com/users/cw9/events{/privacy}","received_events_url":"https://api.github.com/users/cw9/received_events","type":"User","site_admin":false},"body":"The previous implementation was leveraging the randomness in map iteration for consumer selection, but benchmark shows that the map iteration is not providing enough fairness in choosing the first item,  for example, there is a >50% chance for 2 out of 10 consumers to be chosen as the first item in the iteration, this puts way more load on them than the other available consumers.\r\n\r\n@xichen2020 ","created_at":"2018-06-03T18:30:22Z","updated_at":"2018-06-04T15:36:49Z","closed_at":"2018-06-03T23:33:48Z","merged_at":"2018-06-03T23:33:48Z","merge_commit_sha":"4faab8a6582c4258d23d3d494928c73424613278","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/m3db/m3msg/pulls/23/commits","review_comments_url":"https://api.github.com/repos/m3db/m3msg/pulls/23/comments","review_comment_url":"https://api.github.com/repos/m3db/m3msg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/m3db/m3msg/issues/23/comments","statuses_url":"https://api.github.com/repos/m3db/m3msg/statuses/753c9631739276d057f971fe5237434a8a92fbff","head":{"label":"m3db:chao-consumer-writer-random","ref":"chao-consumer-writer-random","sha":"753c9631739276d057f971fe5237434a8a92fbff","user":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"repo":{"id":126348256,"node_id":"MDEwOlJlcG9zaXRvcnkxMjYzNDgyNTY=","name":"m3msg","full_name":"m3db/m3msg","owner":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/m3db/m3msg","description":null,"fork":false,"url":"https://api.github.com/repos/m3db/m3msg","forks_url":"https://api.github.com/repos/m3db/m3msg/forks","keys_url":"https://api.github.com/repos/m3db/m3msg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m3db/m3msg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m3db/m3msg/teams","hooks_url":"https://api.github.com/repos/m3db/m3msg/hooks","issue_events_url":"https://api.github.com/repos/m3db/m3msg/issues/events{/number}","events_url":"https://api.github.com/repos/m3db/m3msg/events","assignees_url":"https://api.github.com/repos/m3db/m3msg/assignees{/user}","branches_url":"https://api.github.com/repos/m3db/m3msg/branches{/branch}","tags_url":"https://api.github.com/repos/m3db/m3msg/tags","blobs_url":"https://api.github.com/repos/m3db/m3msg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m3db/m3msg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m3db/m3msg/git/refs{/sha}","trees_url":"https://api.github.com/repos/m3db/m3msg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m3db/m3msg/statuses/{sha}","languages_url":"https://api.github.com/repos/m3db/m3msg/languages","stargazers_url":"https://api.github.com/repos/m3db/m3msg/stargazers","contributors_url":"https://api.github.com/repos/m3db/m3msg/contributors","subscribers_url":"https://api.github.com/repos/m3db/m3msg/subscribers","subscription_url":"https://api.github.com/repos/m3db/m3msg/subscription","commits_url":"https://api.github.com/repos/m3db/m3msg/commits{/sha}","git_commits_url":"https://api.github.com/repos/m3db/m3msg/git/commits{/sha}","comments_url":"https://api.github.com/repos/m3db/m3msg/comments{/number}","issue_comment_url":"https://api.github.com/repos/m3db/m3msg/issues/comments{/number}","contents_url":"https://api.github.com/repos/m3db/m3msg/contents/{+path}","compare_url":"https://api.github.com/repos/m3db/m3msg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m3db/m3msg/merges","archive_url":"https://api.github.com/repos/m3db/m3msg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m3db/m3msg/downloads","issues_url":"https://api.github.com/repos/m3db/m3msg/issues{/number}","pulls_url":"https://api.github.com/repos/m3db/m3msg/pulls{/number}","milestones_url":"https://api.github.com/repos/m3db/m3msg/milestones{/number}","notifications_url":"https://api.github.com/repos/m3db/m3msg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m3db/m3msg/labels{/name}","releases_url":"https://api.github.com/repos/m3db/m3msg/releases{/id}","deployments_url":"https://api.github.com/repos/m3db/m3msg/deployments","created_at":"2018-03-22T14:32:21Z","updated_at":"2018-06-04T03:44:47Z","pushed_at":"2018-06-04T03:44:49Z","git_url":"git://github.com/m3db/m3msg.git","ssh_url":"git@github.com:m3db/m3msg.git","clone_url":"https://github.com/m3db/m3msg.git","svn_url":"https://github.com/m3db/m3msg","homepage":null,"size":152,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"m3db:master","ref":"master","sha":"cce2ad3e94fd543d5d640a77cba5957224e2b902","user":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"repo":{"id":126348256,"node_id":"MDEwOlJlcG9zaXRvcnkxMjYzNDgyNTY=","name":"m3msg","full_name":"m3db/m3msg","owner":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/m3db/m3msg","description":null,"fork":false,"url":"https://api.github.com/repos/m3db/m3msg","forks_url":"https://api.github.com/repos/m3db/m3msg/forks","keys_url":"https://api.github.com/repos/m3db/m3msg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m3db/m3msg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m3db/m3msg/teams","hooks_url":"https://api.github.com/repos/m3db/m3msg/hooks","issue_events_url":"https://api.github.com/repos/m3db/m3msg/issues/events{/number}","events_url":"https://api.github.com/repos/m3db/m3msg/events","assignees_url":"https://api.github.com/repos/m3db/m3msg/assignees{/user}","branches_url":"https://api.github.com/repos/m3db/m3msg/branches{/branch}","tags_url":"https://api.github.com/repos/m3db/m3msg/tags","blobs_url":"https://api.github.com/repos/m3db/m3msg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m3db/m3msg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m3db/m3msg/git/refs{/sha}","trees_url":"https://api.github.com/repos/m3db/m3msg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m3db/m3msg/statuses/{sha}","languages_url":"https://api.github.com/repos/m3db/m3msg/languages","stargazers_url":"https://api.github.com/repos/m3db/m3msg/stargazers","contributors_url":"https://api.github.com/repos/m3db/m3msg/contributors","subscribers_url":"https://api.github.com/repos/m3db/m3msg/subscribers","subscription_url":"https://api.github.com/repos/m3db/m3msg/subscription","commits_url":"https://api.github.com/repos/m3db/m3msg/commits{/sha}","git_commits_url":"https://api.github.com/repos/m3db/m3msg/git/commits{/sha}","comments_url":"https://api.github.com/repos/m3db/m3msg/comments{/number}","issue_comment_url":"https://api.github.com/repos/m3db/m3msg/issues/comments{/number}","contents_url":"https://api.github.com/repos/m3db/m3msg/contents/{+path}","compare_url":"https://api.github.com/repos/m3db/m3msg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m3db/m3msg/merges","archive_url":"https://api.github.com/repos/m3db/m3msg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m3db/m3msg/downloads","issues_url":"https://api.github.com/repos/m3db/m3msg/issues{/number}","pulls_url":"https://api.github.com/repos/m3db/m3msg/pulls{/number}","milestones_url":"https://api.github.com/repos/m3db/m3msg/milestones{/number}","notifications_url":"https://api.github.com/repos/m3db/m3msg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m3db/m3msg/labels{/name}","releases_url":"https://api.github.com/repos/m3db/m3msg/releases{/id}","deployments_url":"https://api.github.com/repos/m3db/m3msg/deployments","created_at":"2018-03-22T14:32:21Z","updated_at":"2018-06-04T03:44:47Z","pushed_at":"2018-06-04T03:44:49Z","git_url":"git://github.com/m3db/m3msg.git","ssh_url":"git@github.com:m3db/m3msg.git","clone_url":"https://github.com/m3db/m3msg.git","svn_url":"https://github.com/m3db/m3msg","homepage":null,"size":152,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/m3db/m3msg/pulls/23"},"html":{"href":"https://github.com/m3db/m3msg/pull/23"},"issue":{"href":"https://api.github.com/repos/m3db/m3msg/issues/23"},"comments":{"href":"https://api.github.com/repos/m3db/m3msg/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/m3db/m3msg/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/m3db/m3msg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/m3db/m3msg/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/m3db/m3msg/statuses/753c9631739276d057f971fe5237434a8a92fbff"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"xichen2020"}}