{"action":"created","comment":{"url":"https://api.github.com/repos/airbnb/synapse/pulls/comments/85858660","pull_request_review_id":6548242,"id":85858660,"diff_hunk":"@@ -1060,20 +1064,23 @@ def update_backends_at(socket_file_path, watchers)\n \n       # parse the stats output to get current backends\n       cur_backends = {}\n+      re = Regexp.new('^(.+?),(.+?),(?:.*?,){15}(.+?),')\n+\n       info.split(\"\\n\").each do |line|\n         next if line[0] == '#'\n \n-        parts = line.split(',')\n-        next if ['FRONTEND', 'BACKEND'].include?(parts[1])\n+        name, addr, state = re.match(line)[1..3]\n \n-        cur_backends[parts[0]] ||= []\n-        cur_backends[parts[0]] << parts[1]\n+        next if ['FRONTEND', 'BACKEND'].include?(address)\n+\n+        cur_backends[name] ||= {}\n+        cur_backends[name][address] = state\n       end\n \n       # build a list of backends that should be enabled\n       enabled_backends = {}\n       watchers.each do |watcher|\n-        enabled_backends[watcher.name] = []\n+        enabled_backends[watcher.name] = {}","path":"lib/synapse/haproxy.rb","position":36,"original_position":36,"commit_id":"84a7e32deb89133dbd8bfe9bb8445fa17c47c066","original_commit_id":"84a7e32deb89133dbd8bfe9bb8445fa17c47c066","user":{"login":"igor47","id":200575,"avatar_url":"https://avatars.githubusercontent.com/u/200575?v=3","gravatar_id":"","url":"https://api.github.com/users/igor47","html_url":"https://github.com/igor47","followers_url":"https://api.github.com/users/igor47/followers","following_url":"https://api.github.com/users/igor47/following{/other_user}","gists_url":"https://api.github.com/users/igor47/gists{/gist_id}","starred_url":"https://api.github.com/users/igor47/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igor47/subscriptions","organizations_url":"https://api.github.com/users/igor47/orgs","repos_url":"https://api.github.com/users/igor47/repos","events_url":"https://api.github.com/users/igor47/events{/privacy}","received_events_url":"https://api.github.com/users/igor47/received_events","type":"User","site_admin":false},"body":"if you're turning this into a hash to speed up lookups, i would recommend using a Set instead","created_at":"2016-11-01T00:14:36Z","updated_at":"2016-11-01T00:16:02Z","html_url":"https://github.com/airbnb/synapse/pull/211#discussion_r85858660","pull_request_url":"https://api.github.com/repos/airbnb/synapse/pulls/211","_links":{"self":{"href":"https://api.github.com/repos/airbnb/synapse/pulls/comments/85858660"},"html":{"href":"https://github.com/airbnb/synapse/pull/211#discussion_r85858660"},"pull_request":{"href":"https://api.github.com/repos/airbnb/synapse/pulls/211"}}},"pull_request":{"url":"https://api.github.com/repos/airbnb/synapse/pulls/211","id":91150049,"html_url":"https://github.com/airbnb/synapse/pull/211","diff_url":"https://github.com/airbnb/synapse/pull/211.diff","patch_url":"https://github.com/airbnb/synapse/pull/211.patch","issue_url":"https://api.github.com/repos/airbnb/synapse/issues/211","number":211,"state":"open","locked":false,"title":"[haproxy] Avoid unnecessary HAProxy re-configuration.","user":{"login":"noggi","id":3590016,"avatar_url":"https://avatars.githubusercontent.com/u/3590016?v=3","gravatar_id":"","url":"https://api.github.com/users/noggi","html_url":"https://github.com/noggi","followers_url":"https://api.github.com/users/noggi/followers","following_url":"https://api.github.com/users/noggi/following{/other_user}","gists_url":"https://api.github.com/users/noggi/gists{/gist_id}","starred_url":"https://api.github.com/users/noggi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noggi/subscriptions","organizations_url":"https://api.github.com/users/noggi/orgs","repos_url":"https://api.github.com/users/noggi/repos","events_url":"https://api.github.com/users/noggi/events{/privacy}","received_events_url":"https://api.github.com/users/noggi/received_events","type":"User","site_admin":false},"body":"Currently, on every topology update event Synapse sends re-enable command to HAProxy for every live backend instance, even though that instance may already be `UP`. The number of such backend instances can be quite significant, so after every single topology update Synapse may send thousands of re-enable commands which are essentially noops.\n\nThe following changes were made to address the problem:\n1. HAProxy command batching: commands are now sent in groups of 4 or less, which reduces\n   overall number of syscalls per topology update event.\n2. Re-enable command is now sent only if a given instance status is not `UP`.\n3. Minor performance improvements in HAProxy stats parsing code (~35% time/cpu savings). \n\nNOTE: command batching in HAproxy was [added in version 1.4.0](http://git.haproxy.org/?p=haproxy.git;a=commit;h=9a42c0d771986913888dd2c3066dca059a850357) (early 2010)\n","created_at":"2016-10-27T07:56:59Z","updated_at":"2016-11-01T00:16:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e8c406e6e8a6729348bbdbfe14543b2ab14d364e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/airbnb/synapse/pulls/211/commits","review_comments_url":"https://api.github.com/repos/airbnb/synapse/pulls/211/comments","review_comment_url":"https://api.github.com/repos/airbnb/synapse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/airbnb/synapse/issues/211/comments","statuses_url":"https://api.github.com/repos/airbnb/synapse/statuses/84a7e32deb89133dbd8bfe9bb8445fa17c47c066","head":{"label":"noggi:synapse/haproxy_avoid_noop_reenable","ref":"synapse/haproxy_avoid_noop_reenable","sha":"84a7e32deb89133dbd8bfe9bb8445fa17c47c066","user":{"login":"noggi","id":3590016,"avatar_url":"https://avatars.githubusercontent.com/u/3590016?v=3","gravatar_id":"","url":"https://api.github.com/users/noggi","html_url":"https://github.com/noggi","followers_url":"https://api.github.com/users/noggi/followers","following_url":"https://api.github.com/users/noggi/following{/other_user}","gists_url":"https://api.github.com/users/noggi/gists{/gist_id}","starred_url":"https://api.github.com/users/noggi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noggi/subscriptions","organizations_url":"https://api.github.com/users/noggi/orgs","repos_url":"https://api.github.com/users/noggi/repos","events_url":"https://api.github.com/users/noggi/events{/privacy}","received_events_url":"https://api.github.com/users/noggi/received_events","type":"User","site_admin":false},"repo":{"id":71288565,"name":"synapse","full_name":"noggi/synapse","owner":{"login":"noggi","id":3590016,"avatar_url":"https://avatars.githubusercontent.com/u/3590016?v=3","gravatar_id":"","url":"https://api.github.com/users/noggi","html_url":"https://github.com/noggi","followers_url":"https://api.github.com/users/noggi/followers","following_url":"https://api.github.com/users/noggi/following{/other_user}","gists_url":"https://api.github.com/users/noggi/gists{/gist_id}","starred_url":"https://api.github.com/users/noggi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noggi/subscriptions","organizations_url":"https://api.github.com/users/noggi/orgs","repos_url":"https://api.github.com/users/noggi/repos","events_url":"https://api.github.com/users/noggi/events{/privacy}","received_events_url":"https://api.github.com/users/noggi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/noggi/synapse","description":"A transparent service discovery framework for connecting an SOA","fork":true,"url":"https://api.github.com/repos/noggi/synapse","forks_url":"https://api.github.com/repos/noggi/synapse/forks","keys_url":"https://api.github.com/repos/noggi/synapse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/noggi/synapse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/noggi/synapse/teams","hooks_url":"https://api.github.com/repos/noggi/synapse/hooks","issue_events_url":"https://api.github.com/repos/noggi/synapse/issues/events{/number}","events_url":"https://api.github.com/repos/noggi/synapse/events","assignees_url":"https://api.github.com/repos/noggi/synapse/assignees{/user}","branches_url":"https://api.github.com/repos/noggi/synapse/branches{/branch}","tags_url":"https://api.github.com/repos/noggi/synapse/tags","blobs_url":"https://api.github.com/repos/noggi/synapse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/noggi/synapse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/noggi/synapse/git/refs{/sha}","trees_url":"https://api.github.com/repos/noggi/synapse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/noggi/synapse/statuses/{sha}","languages_url":"https://api.github.com/repos/noggi/synapse/languages","stargazers_url":"https://api.github.com/repos/noggi/synapse/stargazers","contributors_url":"https://api.github.com/repos/noggi/synapse/contributors","subscribers_url":"https://api.github.com/repos/noggi/synapse/subscribers","subscription_url":"https://api.github.com/repos/noggi/synapse/subscription","commits_url":"https://api.github.com/repos/noggi/synapse/commits{/sha}","git_commits_url":"https://api.github.com/repos/noggi/synapse/git/commits{/sha}","comments_url":"https://api.github.com/repos/noggi/synapse/comments{/number}","issue_comment_url":"https://api.github.com/repos/noggi/synapse/issues/comments{/number}","contents_url":"https://api.github.com/repos/noggi/synapse/contents/{+path}","compare_url":"https://api.github.com/repos/noggi/synapse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/noggi/synapse/merges","archive_url":"https://api.github.com/repos/noggi/synapse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/noggi/synapse/downloads","issues_url":"https://api.github.com/repos/noggi/synapse/issues{/number}","pulls_url":"https://api.github.com/repos/noggi/synapse/pulls{/number}","milestones_url":"https://api.github.com/repos/noggi/synapse/milestones{/number}","notifications_url":"https://api.github.com/repos/noggi/synapse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/noggi/synapse/labels{/name}","releases_url":"https://api.github.com/repos/noggi/synapse/releases{/id}","deployments_url":"https://api.github.com/repos/noggi/synapse/deployments","created_at":"2016-10-18T20:29:05Z","updated_at":"2016-10-18T20:29:07Z","pushed_at":"2016-10-26T04:53:41Z","git_url":"git://github.com/noggi/synapse.git","ssh_url":"git@github.com:noggi/synapse.git","clone_url":"https://github.com/noggi/synapse.git","svn_url":"https://github.com/noggi/synapse","homepage":"","size":559,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"airbnb:master","ref":"master","sha":"e9f6b393bde394f3cbe0c45d6656ac8978e2cb0c","user":{"login":"airbnb","id":698437,"avatar_url":"https://avatars.githubusercontent.com/u/698437?v=3","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"repo":{"id":6607851,"name":"synapse","full_name":"airbnb/synapse","owner":{"login":"airbnb","id":698437,"avatar_url":"https://avatars.githubusercontent.com/u/698437?v=3","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/airbnb/synapse","description":"A transparent service discovery framework for connecting an SOA","fork":false,"url":"https://api.github.com/repos/airbnb/synapse","forks_url":"https://api.github.com/repos/airbnb/synapse/forks","keys_url":"https://api.github.com/repos/airbnb/synapse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/airbnb/synapse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/airbnb/synapse/teams","hooks_url":"https://api.github.com/repos/airbnb/synapse/hooks","issue_events_url":"https://api.github.com/repos/airbnb/synapse/issues/events{/number}","events_url":"https://api.github.com/repos/airbnb/synapse/events","assignees_url":"https://api.github.com/repos/airbnb/synapse/assignees{/user}","branches_url":"https://api.github.com/repos/airbnb/synapse/branches{/branch}","tags_url":"https://api.github.com/repos/airbnb/synapse/tags","blobs_url":"https://api.github.com/repos/airbnb/synapse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/airbnb/synapse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/airbnb/synapse/git/refs{/sha}","trees_url":"https://api.github.com/repos/airbnb/synapse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/airbnb/synapse/statuses/{sha}","languages_url":"https://api.github.com/repos/airbnb/synapse/languages","stargazers_url":"https://api.github.com/repos/airbnb/synapse/stargazers","contributors_url":"https://api.github.com/repos/airbnb/synapse/contributors","subscribers_url":"https://api.github.com/repos/airbnb/synapse/subscribers","subscription_url":"https://api.github.com/repos/airbnb/synapse/subscription","commits_url":"https://api.github.com/repos/airbnb/synapse/commits{/sha}","git_commits_url":"https://api.github.com/repos/airbnb/synapse/git/commits{/sha}","comments_url":"https://api.github.com/repos/airbnb/synapse/comments{/number}","issue_comment_url":"https://api.github.com/repos/airbnb/synapse/issues/comments{/number}","contents_url":"https://api.github.com/repos/airbnb/synapse/contents/{+path}","compare_url":"https://api.github.com/repos/airbnb/synapse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/airbnb/synapse/merges","archive_url":"https://api.github.com/repos/airbnb/synapse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/airbnb/synapse/downloads","issues_url":"https://api.github.com/repos/airbnb/synapse/issues{/number}","pulls_url":"https://api.github.com/repos/airbnb/synapse/pulls{/number}","milestones_url":"https://api.github.com/repos/airbnb/synapse/milestones{/number}","notifications_url":"https://api.github.com/repos/airbnb/synapse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/airbnb/synapse/labels{/name}","releases_url":"https://api.github.com/repos/airbnb/synapse/releases{/id}","deployments_url":"https://api.github.com/repos/airbnb/synapse/deployments","created_at":"2012-11-09T03:03:06Z","updated_at":"2016-11-01T00:12:18Z","pushed_at":"2016-10-27T07:56:59Z","git_url":"git://github.com/airbnb/synapse.git","ssh_url":"git@github.com:airbnb/synapse.git","clone_url":"https://github.com/airbnb/synapse.git","svn_url":"https://github.com/airbnb/synapse","homepage":"","size":918,"stargazers_count":1491,"watchers_count":1491,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":200,"mirror_url":null,"open_issues_count":46,"forks":200,"open_issues":46,"watchers":1491,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/airbnb/synapse/pulls/211"},"html":{"href":"https://github.com/airbnb/synapse/pull/211"},"issue":{"href":"https://api.github.com/repos/airbnb/synapse/issues/211"},"comments":{"href":"https://api.github.com/repos/airbnb/synapse/issues/211/comments"},"review_comments":{"href":"https://api.github.com/repos/airbnb/synapse/pulls/211/comments"},"review_comment":{"href":"https://api.github.com/repos/airbnb/synapse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/airbnb/synapse/pulls/211/commits"},"statuses":{"href":"https://api.github.com/repos/airbnb/synapse/statuses/84a7e32deb89133dbd8bfe9bb8445fa17c47c066"}}}}
{"actor":{"display_login":"igor47"}}