{"action":"created","comment":{"url":"https://api.github.com/repos/envoyproxy/envoy/pulls/comments/167559900","pull_request_review_id":95791848,"id":167559900,"diff_hunk":"@@ -0,0 +1,81 @@\n+#include \"common/upstream/thread_aware_lb_impl.h\"\n+\n+namespace Envoy {\n+namespace Upstream {\n+\n+void ThreadAwareLoadBalancerBase::initialize() {\n+  // TODO(mattklein123): In the future, once initialized and the initial LB is built, it would be\n+  // better to use a background thread for computing LB updates. This has the substantial benefit\n+  // that if the LB computation thread falls behind, host set updates can be trivially collapsed.\n+  // I will look into doing this in a follow up. Doing everything using a background thread heavily\n+  // complicated initialization as the load balancer would need its own initialized callback. I\n+  // think the synchronous/asynchronous split is probably the best option.\n+  priority_set_.addMemberUpdateCb(\n+      [this](uint32_t, const HostVector&, const HostVector&) -> void { refresh(); });\n+\n+  refresh();\n+}\n+\n+void ThreadAwareLoadBalancerBase::refresh() {\n+  auto per_priority_state = std::make_shared<std::vector<PerPriorityStatePtr>>(\n+      priority_set_.hostSetsPerPriority().size());\n+  auto per_priority_load = std::make_shared<std::vector<uint32_t>>(per_priority_load_);\n+\n+  // Note that we only compute global panic on host set refresh. Given that the runtime setting will\n+  // rarely change, this is a reasonable compromise to avoid creating extra rings when we only\n+  // need to create one per priority level.\n+  for (auto& host_set : priority_set_.hostSetsPerPriority()) {","path":"source/common/upstream/thread_aware_lb_impl.cc","position":27,"original_position":27,"commit_id":"885dfac29191a099bf43aa211b46a5f83d0d8b73","original_commit_id":"885dfac29191a099bf43aa211b46a5f83d0d8b73","user":{"login":"jmarantz","id":1942589,"avatar_url":"https://avatars3.githubusercontent.com/u/1942589?v=4","gravatar_id":"","url":"https://api.github.com/users/jmarantz","html_url":"https://github.com/jmarantz","followers_url":"https://api.github.com/users/jmarantz/followers","following_url":"https://api.github.com/users/jmarantz/following{/other_user}","gists_url":"https://api.github.com/users/jmarantz/gists{/gist_id}","starred_url":"https://api.github.com/users/jmarantz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmarantz/subscriptions","organizations_url":"https://api.github.com/users/jmarantz/orgs","repos_url":"https://api.github.com/users/jmarantz/repos","events_url":"https://api.github.com/users/jmarantz/events{/privacy}","received_events_url":"https://api.github.com/users/jmarantz/received_events","type":"User","site_admin":false},"body":"it looks like this can be 'const auto& host_set' as all the refs in there don't modify (e.g. createLoadBalancer takes a const ref).","created_at":"2018-02-12T13:49:55Z","updated_at":"2018-02-12T13:53:19Z","html_url":"https://github.com/envoyproxy/envoy/pull/2584#discussion_r167559900","pull_request_url":"https://api.github.com/repos/envoyproxy/envoy/pulls/2584","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/envoyproxy/envoy/pulls/comments/167559900"},"html":{"href":"https://github.com/envoyproxy/envoy/pull/2584#discussion_r167559900"},"pull_request":{"href":"https://api.github.com/repos/envoyproxy/envoy/pulls/2584"}}},"pull_request":{"url":"https://api.github.com/repos/envoyproxy/envoy/pulls/2584","id":168488891,"html_url":"https://github.com/envoyproxy/envoy/pull/2584","diff_url":"https://github.com/envoyproxy/envoy/pull/2584.diff","patch_url":"https://github.com/envoyproxy/envoy/pull/2584.patch","issue_url":"https://api.github.com/repos/envoyproxy/envoy/issues/2584","number":2584,"state":"open","locked":false,"title":"load balancer: add Maglev","user":{"login":"mattklein123","id":6305260,"avatar_url":"https://avatars3.githubusercontent.com/u/6305260?v=4","gravatar_id":"","url":"https://api.github.com/users/mattklein123","html_url":"https://github.com/mattklein123","followers_url":"https://api.github.com/users/mattklein123/followers","following_url":"https://api.github.com/users/mattklein123/following{/other_user}","gists_url":"https://api.github.com/users/mattklein123/gists{/gist_id}","starred_url":"https://api.github.com/users/mattklein123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattklein123/subscriptions","organizations_url":"https://api.github.com/users/mattklein123/orgs","repos_url":"https://api.github.com/users/mattklein123/repos","events_url":"https://api.github.com/users/mattklein123/events{/privacy}","received_events_url":"https://api.github.com/users/mattklein123/received_events","type":"User","site_admin":false},"body":"Refactor RingHash into a common base class. The amount of new code needed\r\nfor Maglev is tiny.\r\n\r\n*Risk Level*: Low \r\n*Testing*: Unit\r\n*Docs Changes*: https://github.com/envoyproxy/data-plane-api/pull/487\r\n*API Changes*: https://github.com/envoyproxy/data-plane-api/pull/487\r\n*Release Notes*: Added\r\nFixes https://github.com/envoyproxy/envoy/issues/2267\r\n\r\n\r\n\r\n","created_at":"2018-02-12T02:04:43Z","updated_at":"2018-02-12T13:53:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b46901705e04c0e631fae364228129f036247838","assignee":{"login":"danielhochman","id":4712430,"avatar_url":"https://avatars3.githubusercontent.com/u/4712430?v=4","gravatar_id":"","url":"https://api.github.com/users/danielhochman","html_url":"https://github.com/danielhochman","followers_url":"https://api.github.com/users/danielhochman/followers","following_url":"https://api.github.com/users/danielhochman/following{/other_user}","gists_url":"https://api.github.com/users/danielhochman/gists{/gist_id}","starred_url":"https://api.github.com/users/danielhochman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielhochman/subscriptions","organizations_url":"https://api.github.com/users/danielhochman/orgs","repos_url":"https://api.github.com/users/danielhochman/repos","events_url":"https://api.github.com/users/danielhochman/events{/privacy}","received_events_url":"https://api.github.com/users/danielhochman/received_events","type":"User","site_admin":false},"assignees":[{"login":"danielhochman","id":4712430,"avatar_url":"https://avatars3.githubusercontent.com/u/4712430?v=4","gravatar_id":"","url":"https://api.github.com/users/danielhochman","html_url":"https://github.com/danielhochman","followers_url":"https://api.github.com/users/danielhochman/followers","following_url":"https://api.github.com/users/danielhochman/following{/other_user}","gists_url":"https://api.github.com/users/danielhochman/gists{/gist_id}","starred_url":"https://api.github.com/users/danielhochman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielhochman/subscriptions","organizations_url":"https://api.github.com/users/danielhochman/orgs","repos_url":"https://api.github.com/users/danielhochman/repos","events_url":"https://api.github.com/users/danielhochman/events{/privacy}","received_events_url":"https://api.github.com/users/danielhochman/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/envoyproxy/envoy/pulls/2584/commits","review_comments_url":"https://api.github.com/repos/envoyproxy/envoy/pulls/2584/comments","review_comment_url":"https://api.github.com/repos/envoyproxy/envoy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/envoyproxy/envoy/issues/2584/comments","statuses_url":"https://api.github.com/repos/envoyproxy/envoy/statuses/885dfac29191a099bf43aa211b46a5f83d0d8b73","head":{"label":"envoyproxy:add_maglev","ref":"add_maglev","sha":"885dfac29191a099bf43aa211b46a5f83d0d8b73","user":{"login":"envoyproxy","id":30125649,"avatar_url":"https://avatars1.githubusercontent.com/u/30125649?v=4","gravatar_id":"","url":"https://api.github.com/users/envoyproxy","html_url":"https://github.com/envoyproxy","followers_url":"https://api.github.com/users/envoyproxy/followers","following_url":"https://api.github.com/users/envoyproxy/following{/other_user}","gists_url":"https://api.github.com/users/envoyproxy/gists{/gist_id}","starred_url":"https://api.github.com/users/envoyproxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/envoyproxy/subscriptions","organizations_url":"https://api.github.com/users/envoyproxy/orgs","repos_url":"https://api.github.com/users/envoyproxy/repos","events_url":"https://api.github.com/users/envoyproxy/events{/privacy}","received_events_url":"https://api.github.com/users/envoyproxy/received_events","type":"Organization","site_admin":false},"repo":{"id":65214191,"name":"envoy","full_name":"envoyproxy/envoy","owner":{"login":"envoyproxy","id":30125649,"avatar_url":"https://avatars1.githubusercontent.com/u/30125649?v=4","gravatar_id":"","url":"https://api.github.com/users/envoyproxy","html_url":"https://github.com/envoyproxy","followers_url":"https://api.github.com/users/envoyproxy/followers","following_url":"https://api.github.com/users/envoyproxy/following{/other_user}","gists_url":"https://api.github.com/users/envoyproxy/gists{/gist_id}","starred_url":"https://api.github.com/users/envoyproxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/envoyproxy/subscriptions","organizations_url":"https://api.github.com/users/envoyproxy/orgs","repos_url":"https://api.github.com/users/envoyproxy/repos","events_url":"https://api.github.com/users/envoyproxy/events{/privacy}","received_events_url":"https://api.github.com/users/envoyproxy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/envoyproxy/envoy","description":"C++ front/service proxy","fork":false,"url":"https://api.github.com/repos/envoyproxy/envoy","forks_url":"https://api.github.com/repos/envoyproxy/envoy/forks","keys_url":"https://api.github.com/repos/envoyproxy/envoy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/envoyproxy/envoy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/envoyproxy/envoy/teams","hooks_url":"https://api.github.com/repos/envoyproxy/envoy/hooks","issue_events_url":"https://api.github.com/repos/envoyproxy/envoy/issues/events{/number}","events_url":"https://api.github.com/repos/envoyproxy/envoy/events","assignees_url":"https://api.github.com/repos/envoyproxy/envoy/assignees{/user}","branches_url":"https://api.github.com/repos/envoyproxy/envoy/branches{/branch}","tags_url":"https://api.github.com/repos/envoyproxy/envoy/tags","blobs_url":"https://api.github.com/repos/envoyproxy/envoy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/envoyproxy/envoy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/envoyproxy/envoy/git/refs{/sha}","trees_url":"https://api.github.com/repos/envoyproxy/envoy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/envoyproxy/envoy/statuses/{sha}","languages_url":"https://api.github.com/repos/envoyproxy/envoy/languages","stargazers_url":"https://api.github.com/repos/envoyproxy/envoy/stargazers","contributors_url":"https://api.github.com/repos/envoyproxy/envoy/contributors","subscribers_url":"https://api.github.com/repos/envoyproxy/envoy/subscribers","subscription_url":"https://api.github.com/repos/envoyproxy/envoy/subscription","commits_url":"https://api.github.com/repos/envoyproxy/envoy/commits{/sha}","git_commits_url":"https://api.github.com/repos/envoyproxy/envoy/git/commits{/sha}","comments_url":"https://api.github.com/repos/envoyproxy/envoy/comments{/number}","issue_comment_url":"https://api.github.com/repos/envoyproxy/envoy/issues/comments{/number}","contents_url":"https://api.github.com/repos/envoyproxy/envoy/contents/{+path}","compare_url":"https://api.github.com/repos/envoyproxy/envoy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/envoyproxy/envoy/merges","archive_url":"https://api.github.com/repos/envoyproxy/envoy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/envoyproxy/envoy/downloads","issues_url":"https://api.github.com/repos/envoyproxy/envoy/issues{/number}","pulls_url":"https://api.github.com/repos/envoyproxy/envoy/pulls{/number}","milestones_url":"https://api.github.com/repos/envoyproxy/envoy/milestones{/number}","notifications_url":"https://api.github.com/repos/envoyproxy/envoy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/envoyproxy/envoy/labels{/name}","releases_url":"https://api.github.com/repos/envoyproxy/envoy/releases{/id}","deployments_url":"https://api.github.com/repos/envoyproxy/envoy/deployments","created_at":"2016-08-08T15:07:24Z","updated_at":"2018-02-12T12:02:39Z","pushed_at":"2018-02-12T08:38:43Z","git_url":"git://github.com/envoyproxy/envoy.git","ssh_url":"git@github.com:envoyproxy/envoy.git","clone_url":"https://github.com/envoyproxy/envoy.git","svn_url":"https://github.com/envoyproxy/envoy","homepage":"https://envoyproxy.github.io/","size":11895,"stargazers_count":3852,"watchers_count":3852,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":468,"mirror_url":null,"archived":false,"open_issues_count":226,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":468,"open_issues":226,"watchers":3852,"default_branch":"master"}},"base":{"label":"envoyproxy:master","ref":"master","sha":"c31077b28e4f8a7db17895d5d2570e806e9e2a3e","user":{"login":"envoyproxy","id":30125649,"avatar_url":"https://avatars1.githubusercontent.com/u/30125649?v=4","gravatar_id":"","url":"https://api.github.com/users/envoyproxy","html_url":"https://github.com/envoyproxy","followers_url":"https://api.github.com/users/envoyproxy/followers","following_url":"https://api.github.com/users/envoyproxy/following{/other_user}","gists_url":"https://api.github.com/users/envoyproxy/gists{/gist_id}","starred_url":"https://api.github.com/users/envoyproxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/envoyproxy/subscriptions","organizations_url":"https://api.github.com/users/envoyproxy/orgs","repos_url":"https://api.github.com/users/envoyproxy/repos","events_url":"https://api.github.com/users/envoyproxy/events{/privacy}","received_events_url":"https://api.github.com/users/envoyproxy/received_events","type":"Organization","site_admin":false},"repo":{"id":65214191,"name":"envoy","full_name":"envoyproxy/envoy","owner":{"login":"envoyproxy","id":30125649,"avatar_url":"https://avatars1.githubusercontent.com/u/30125649?v=4","gravatar_id":"","url":"https://api.github.com/users/envoyproxy","html_url":"https://github.com/envoyproxy","followers_url":"https://api.github.com/users/envoyproxy/followers","following_url":"https://api.github.com/users/envoyproxy/following{/other_user}","gists_url":"https://api.github.com/users/envoyproxy/gists{/gist_id}","starred_url":"https://api.github.com/users/envoyproxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/envoyproxy/subscriptions","organizations_url":"https://api.github.com/users/envoyproxy/orgs","repos_url":"https://api.github.com/users/envoyproxy/repos","events_url":"https://api.github.com/users/envoyproxy/events{/privacy}","received_events_url":"https://api.github.com/users/envoyproxy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/envoyproxy/envoy","description":"C++ front/service proxy","fork":false,"url":"https://api.github.com/repos/envoyproxy/envoy","forks_url":"https://api.github.com/repos/envoyproxy/envoy/forks","keys_url":"https://api.github.com/repos/envoyproxy/envoy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/envoyproxy/envoy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/envoyproxy/envoy/teams","hooks_url":"https://api.github.com/repos/envoyproxy/envoy/hooks","issue_events_url":"https://api.github.com/repos/envoyproxy/envoy/issues/events{/number}","events_url":"https://api.github.com/repos/envoyproxy/envoy/events","assignees_url":"https://api.github.com/repos/envoyproxy/envoy/assignees{/user}","branches_url":"https://api.github.com/repos/envoyproxy/envoy/branches{/branch}","tags_url":"https://api.github.com/repos/envoyproxy/envoy/tags","blobs_url":"https://api.github.com/repos/envoyproxy/envoy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/envoyproxy/envoy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/envoyproxy/envoy/git/refs{/sha}","trees_url":"https://api.github.com/repos/envoyproxy/envoy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/envoyproxy/envoy/statuses/{sha}","languages_url":"https://api.github.com/repos/envoyproxy/envoy/languages","stargazers_url":"https://api.github.com/repos/envoyproxy/envoy/stargazers","contributors_url":"https://api.github.com/repos/envoyproxy/envoy/contributors","subscribers_url":"https://api.github.com/repos/envoyproxy/envoy/subscribers","subscription_url":"https://api.github.com/repos/envoyproxy/envoy/subscription","commits_url":"https://api.github.com/repos/envoyproxy/envoy/commits{/sha}","git_commits_url":"https://api.github.com/repos/envoyproxy/envoy/git/commits{/sha}","comments_url":"https://api.github.com/repos/envoyproxy/envoy/comments{/number}","issue_comment_url":"https://api.github.com/repos/envoyproxy/envoy/issues/comments{/number}","contents_url":"https://api.github.com/repos/envoyproxy/envoy/contents/{+path}","compare_url":"https://api.github.com/repos/envoyproxy/envoy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/envoyproxy/envoy/merges","archive_url":"https://api.github.com/repos/envoyproxy/envoy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/envoyproxy/envoy/downloads","issues_url":"https://api.github.com/repos/envoyproxy/envoy/issues{/number}","pulls_url":"https://api.github.com/repos/envoyproxy/envoy/pulls{/number}","milestones_url":"https://api.github.com/repos/envoyproxy/envoy/milestones{/number}","notifications_url":"https://api.github.com/repos/envoyproxy/envoy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/envoyproxy/envoy/labels{/name}","releases_url":"https://api.github.com/repos/envoyproxy/envoy/releases{/id}","deployments_url":"https://api.github.com/repos/envoyproxy/envoy/deployments","created_at":"2016-08-08T15:07:24Z","updated_at":"2018-02-12T12:02:39Z","pushed_at":"2018-02-12T08:38:43Z","git_url":"git://github.com/envoyproxy/envoy.git","ssh_url":"git@github.com:envoyproxy/envoy.git","clone_url":"https://github.com/envoyproxy/envoy.git","svn_url":"https://github.com/envoyproxy/envoy","homepage":"https://envoyproxy.github.io/","size":11895,"stargazers_count":3852,"watchers_count":3852,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":468,"mirror_url":null,"archived":false,"open_issues_count":226,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":468,"open_issues":226,"watchers":3852,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/envoyproxy/envoy/pulls/2584"},"html":{"href":"https://github.com/envoyproxy/envoy/pull/2584"},"issue":{"href":"https://api.github.com/repos/envoyproxy/envoy/issues/2584"},"comments":{"href":"https://api.github.com/repos/envoyproxy/envoy/issues/2584/comments"},"review_comments":{"href":"https://api.github.com/repos/envoyproxy/envoy/pulls/2584/comments"},"review_comment":{"href":"https://api.github.com/repos/envoyproxy/envoy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/envoyproxy/envoy/pulls/2584/commits"},"statuses":{"href":"https://api.github.com/repos/envoyproxy/envoy/statuses/885dfac29191a099bf43aa211b46a5f83d0d8b73"}},"author_association":"OWNER"}}
{"actor":{"display_login":"jmarantz"}}