{"action":"created","comment":{"url":"https://api.github.com/repos/vitessio/vitess/pulls/comments/215388186","pull_request_review_id":152641523,"id":215388186,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNTM4ODE4Ng==","diff_hunk":"@@ -0,0 +1,81 @@\n+package bucketpool\n+\n+import (\n+\t\"sync\"\n+)\n+\n+type sizedPool struct {\n+\tsize int\n+\tpool sync.Pool\n+}\n+\n+func newSizedPool(size int) *sizedPool {\n+\treturn &sizedPool{\n+\t\tsize: size,\n+\t\tpool: sync.Pool{\n+\t\t\tNew: func() interface{} { return makeSlicePointer(size) },\n+\t\t},\n+\t}\n+}\n+\n+// Pool is actually multiple pools which store buffers of specific size.\n+// i.e. it can be three pools which return buffers 32K, 64K and 128K.\n+type Pool struct {\n+\tmaxSize int\n+\tpools   []*sizedPool\n+}\n+\n+// New returns Pool which has buckets from minSize to maxSize.\n+// Last pool will always be capped to maxSize.\n+// i.e with multiplier 2: [2b, 4b, 16b, ... , 1024b]\n+func New(minSize, maxSize, multiplier int) *Pool {\n+\tvar pools []*sizedPool\n+\tfor minSize < maxSize {\n+\t\tpools = append(pools, newSizedPool(minSize))\n+\t\tminSize *= multiplier\n+\t}\n+\tpools = append(pools, newSizedPool(maxSize))\n+\treturn &Pool{\n+\t\tmaxSize: maxSize,\n+\t\tpools:   pools,\n+\t}\n+}\n+\n+func (p *Pool) findPool(size int) *sizedPool {\n+\tif size > p.maxSize {\n+\t\treturn nil\n+\t}\n+\tfor _, sp := range p.pools {","path":"go/bucketpool/bucketpool.go","position":48,"original_position":48,"commit_id":"5df15e2b32f20e0583f213c4f0bebfce4f8797a7","original_commit_id":"5df15e2b32f20e0583f213c4f0bebfce4f8797a7","user":{"login":"danieltahara","id":1313465,"node_id":"MDQ6VXNlcjEzMTM0NjU=","avatar_url":"https://avatars2.githubusercontent.com/u/1313465?v=4","gravatar_id":"","url":"https://api.github.com/users/danieltahara","html_url":"https://github.com/danieltahara","followers_url":"https://api.github.com/users/danieltahara/followers","following_url":"https://api.github.com/users/danieltahara/following{/other_user}","gists_url":"https://api.github.com/users/danieltahara/gists{/gist_id}","starred_url":"https://api.github.com/users/danieltahara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieltahara/subscriptions","organizations_url":"https://api.github.com/users/danieltahara/orgs","repos_url":"https://api.github.com/users/danieltahara/repos","events_url":"https://api.github.com/users/danieltahara/events{/privacy}","received_events_url":"https://api.github.com/users/danieltahara/received_events","type":"User","site_admin":false},"body":"https://golang.org/pkg/sort/#SearchInts","created_at":"2018-09-05T18:56:00Z","updated_at":"2018-09-05T18:56:05Z","html_url":"https://github.com/vitessio/vitess/pull/4183#discussion_r215388186","pull_request_url":"https://api.github.com/repos/vitessio/vitess/pulls/4183","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/vitessio/vitess/pulls/comments/215388186"},"html":{"href":"https://github.com/vitessio/vitess/pull/4183#discussion_r215388186"},"pull_request":{"href":"https://api.github.com/repos/vitessio/vitess/pulls/4183"}}},"pull_request":{"url":"https://api.github.com/repos/vitessio/vitess/pulls/4183","id":213353339,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEzMzUzMzM5","html_url":"https://github.com/vitessio/vitess/pull/4183","diff_url":"https://github.com/vitessio/vitess/pull/4183.diff","patch_url":"https://github.com/vitessio/vitess/pull/4183.patch","issue_url":"https://api.github.com/repos/vitessio/vitess/issues/4183","number":4183,"state":"open","locked":false,"title":"[go/mysql] use tiered pool for buffers to avoid false hits","user":{"login":"LK4D4","id":101445,"node_id":"MDQ6VXNlcjEwMTQ0NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/101445?v=4","gravatar_id":"","url":"https://api.github.com/users/LK4D4","html_url":"https://github.com/LK4D4","followers_url":"https://api.github.com/users/LK4D4/followers","following_url":"https://api.github.com/users/LK4D4/following{/other_user}","gists_url":"https://api.github.com/users/LK4D4/gists{/gist_id}","starred_url":"https://api.github.com/users/LK4D4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LK4D4/subscriptions","organizations_url":"https://api.github.com/users/LK4D4/orgs","repos_url":"https://api.github.com/users/LK4D4/repos","events_url":"https://api.github.com/users/LK4D4/events{/privacy}","received_events_url":"https://api.github.com/users/LK4D4/received_events","type":"User","site_admin":false},"body":"Now when we get smaller than we want buffer from pool, we just put it\r\nback and allocate a new one. This might be quite inefficient.\r\nSo, instead use multiple pools which always return buffers >= request\r\nsize.\r\nBenchmark results:\r\n```\r\nbenchmark                            old ns/op     new ns/op     delta\r\nBenchmarkParallelShortQueries-8      3347          3327          -0.60%\r\nBenchmarkParallelMediumQueries-8     6535          5789          -11.42%\r\nBenchmarkParallelRandomQueries-8     6001539       5453566       -9.13%\r\n\r\nbenchmark                            old MB/s     new MB/s     speedup\r\nBenchmarkParallelShortQueries-8      3.29         3.31         1.01x\r\nBenchmarkParallelMediumQueries-8     2507.72      2830.78      1.13x\r\n\r\nbenchmark                            old allocs     new allocs     delta\r\nBenchmarkParallelShortQueries-8      23             23             +0.00%\r\nBenchmarkParallelMediumQueries-8     9              8              -11.11%\r\nBenchmarkParallelRandomQueries-8     15             14             -6.67%\r\n\r\nbenchmark                            old bytes     new bytes     delta\r\nBenchmarkParallelShortQueries-8      720           720           +0.00%\r\nBenchmarkParallelMediumQueries-8     27243         20865         -23.41%\r\nBenchmarkParallelRandomQueries-8     36496086      29452887      -19.30%\r\n```\r\nThis is new package and internal to vitess. So, we can make interface less flexible maybe. Like allow only powers of two and say that multiplier is always 2.","created_at":"2018-09-05T16:20:20Z","updated_at":"2018-09-05T18:56:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f4976025e7a907689e91d2e3f428cf1afed3d4ae","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/vitessio/vitess/pulls/4183/commits","review_comments_url":"https://api.github.com/repos/vitessio/vitess/pulls/4183/comments","review_comment_url":"https://api.github.com/repos/vitessio/vitess/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vitessio/vitess/issues/4183/comments","statuses_url":"https://api.github.com/repos/vitessio/vitess/statuses/5df15e2b32f20e0583f213c4f0bebfce4f8797a7","head":{"label":"LK4D4:tiered_pool","ref":"tiered_pool","sha":"5df15e2b32f20e0583f213c4f0bebfce4f8797a7","user":{"login":"LK4D4","id":101445,"node_id":"MDQ6VXNlcjEwMTQ0NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/101445?v=4","gravatar_id":"","url":"https://api.github.com/users/LK4D4","html_url":"https://github.com/LK4D4","followers_url":"https://api.github.com/users/LK4D4/followers","following_url":"https://api.github.com/users/LK4D4/following{/other_user}","gists_url":"https://api.github.com/users/LK4D4/gists{/gist_id}","starred_url":"https://api.github.com/users/LK4D4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LK4D4/subscriptions","organizations_url":"https://api.github.com/users/LK4D4/orgs","repos_url":"https://api.github.com/users/LK4D4/repos","events_url":"https://api.github.com/users/LK4D4/events{/privacy}","received_events_url":"https://api.github.com/users/LK4D4/received_events","type":"User","site_admin":false},"repo":{"id":145909065,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU5MDkwNjU=","name":"vitess","full_name":"LK4D4/vitess","owner":{"login":"LK4D4","id":101445,"node_id":"MDQ6VXNlcjEwMTQ0NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/101445?v=4","gravatar_id":"","url":"https://api.github.com/users/LK4D4","html_url":"https://github.com/LK4D4","followers_url":"https://api.github.com/users/LK4D4/followers","following_url":"https://api.github.com/users/LK4D4/following{/other_user}","gists_url":"https://api.github.com/users/LK4D4/gists{/gist_id}","starred_url":"https://api.github.com/users/LK4D4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LK4D4/subscriptions","organizations_url":"https://api.github.com/users/LK4D4/orgs","repos_url":"https://api.github.com/users/LK4D4/repos","events_url":"https://api.github.com/users/LK4D4/events{/privacy}","received_events_url":"https://api.github.com/users/LK4D4/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LK4D4/vitess","description":"Vitess is a database clustering system for horizontal scaling of MySQL.","fork":true,"url":"https://api.github.com/repos/LK4D4/vitess","forks_url":"https://api.github.com/repos/LK4D4/vitess/forks","keys_url":"https://api.github.com/repos/LK4D4/vitess/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LK4D4/vitess/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LK4D4/vitess/teams","hooks_url":"https://api.github.com/repos/LK4D4/vitess/hooks","issue_events_url":"https://api.github.com/repos/LK4D4/vitess/issues/events{/number}","events_url":"https://api.github.com/repos/LK4D4/vitess/events","assignees_url":"https://api.github.com/repos/LK4D4/vitess/assignees{/user}","branches_url":"https://api.github.com/repos/LK4D4/vitess/branches{/branch}","tags_url":"https://api.github.com/repos/LK4D4/vitess/tags","blobs_url":"https://api.github.com/repos/LK4D4/vitess/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LK4D4/vitess/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LK4D4/vitess/git/refs{/sha}","trees_url":"https://api.github.com/repos/LK4D4/vitess/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LK4D4/vitess/statuses/{sha}","languages_url":"https://api.github.com/repos/LK4D4/vitess/languages","stargazers_url":"https://api.github.com/repos/LK4D4/vitess/stargazers","contributors_url":"https://api.github.com/repos/LK4D4/vitess/contributors","subscribers_url":"https://api.github.com/repos/LK4D4/vitess/subscribers","subscription_url":"https://api.github.com/repos/LK4D4/vitess/subscription","commits_url":"https://api.github.com/repos/LK4D4/vitess/commits{/sha}","git_commits_url":"https://api.github.com/repos/LK4D4/vitess/git/commits{/sha}","comments_url":"https://api.github.com/repos/LK4D4/vitess/comments{/number}","issue_comment_url":"https://api.github.com/repos/LK4D4/vitess/issues/comments{/number}","contents_url":"https://api.github.com/repos/LK4D4/vitess/contents/{+path}","compare_url":"https://api.github.com/repos/LK4D4/vitess/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LK4D4/vitess/merges","archive_url":"https://api.github.com/repos/LK4D4/vitess/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LK4D4/vitess/downloads","issues_url":"https://api.github.com/repos/LK4D4/vitess/issues{/number}","pulls_url":"https://api.github.com/repos/LK4D4/vitess/pulls{/number}","milestones_url":"https://api.github.com/repos/LK4D4/vitess/milestones{/number}","notifications_url":"https://api.github.com/repos/LK4D4/vitess/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LK4D4/vitess/labels{/name}","releases_url":"https://api.github.com/repos/LK4D4/vitess/releases{/id}","deployments_url":"https://api.github.com/repos/LK4D4/vitess/deployments","created_at":"2018-08-23T21:28:29Z","updated_at":"2018-09-05T04:35:47Z","pushed_at":"2018-09-05T16:32:22Z","git_url":"git://github.com/LK4D4/vitess.git","ssh_url":"git@github.com:LK4D4/vitess.git","clone_url":"https://github.com/LK4D4/vitess.git","svn_url":"https://github.com/LK4D4/vitess","homepage":"http://vitess.io","size":98703,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"vitessio:master","ref":"master","sha":"b416c1f96220f0f7efc84b9ce042eec5fac911d6","user":{"login":"vitessio","id":33043890,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMDQzODkw","avatar_url":"https://avatars1.githubusercontent.com/u/33043890?v=4","gravatar_id":"","url":"https://api.github.com/users/vitessio","html_url":"https://github.com/vitessio","followers_url":"https://api.github.com/users/vitessio/followers","following_url":"https://api.github.com/users/vitessio/following{/other_user}","gists_url":"https://api.github.com/users/vitessio/gists{/gist_id}","starred_url":"https://api.github.com/users/vitessio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitessio/subscriptions","organizations_url":"https://api.github.com/users/vitessio/orgs","repos_url":"https://api.github.com/users/vitessio/repos","events_url":"https://api.github.com/users/vitessio/events{/privacy}","received_events_url":"https://api.github.com/users/vitessio/received_events","type":"Organization","site_admin":false},"repo":{"id":11008207,"node_id":"MDEwOlJlcG9zaXRvcnkxMTAwODIwNw==","name":"vitess","full_name":"vitessio/vitess","owner":{"login":"vitessio","id":33043890,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMDQzODkw","avatar_url":"https://avatars1.githubusercontent.com/u/33043890?v=4","gravatar_id":"","url":"https://api.github.com/users/vitessio","html_url":"https://github.com/vitessio","followers_url":"https://api.github.com/users/vitessio/followers","following_url":"https://api.github.com/users/vitessio/following{/other_user}","gists_url":"https://api.github.com/users/vitessio/gists{/gist_id}","starred_url":"https://api.github.com/users/vitessio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitessio/subscriptions","organizations_url":"https://api.github.com/users/vitessio/orgs","repos_url":"https://api.github.com/users/vitessio/repos","events_url":"https://api.github.com/users/vitessio/events{/privacy}","received_events_url":"https://api.github.com/users/vitessio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vitessio/vitess","description":"Vitess is a database clustering system for horizontal scaling of MySQL.","fork":false,"url":"https://api.github.com/repos/vitessio/vitess","forks_url":"https://api.github.com/repos/vitessio/vitess/forks","keys_url":"https://api.github.com/repos/vitessio/vitess/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vitessio/vitess/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vitessio/vitess/teams","hooks_url":"https://api.github.com/repos/vitessio/vitess/hooks","issue_events_url":"https://api.github.com/repos/vitessio/vitess/issues/events{/number}","events_url":"https://api.github.com/repos/vitessio/vitess/events","assignees_url":"https://api.github.com/repos/vitessio/vitess/assignees{/user}","branches_url":"https://api.github.com/repos/vitessio/vitess/branches{/branch}","tags_url":"https://api.github.com/repos/vitessio/vitess/tags","blobs_url":"https://api.github.com/repos/vitessio/vitess/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vitessio/vitess/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vitessio/vitess/git/refs{/sha}","trees_url":"https://api.github.com/repos/vitessio/vitess/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vitessio/vitess/statuses/{sha}","languages_url":"https://api.github.com/repos/vitessio/vitess/languages","stargazers_url":"https://api.github.com/repos/vitessio/vitess/stargazers","contributors_url":"https://api.github.com/repos/vitessio/vitess/contributors","subscribers_url":"https://api.github.com/repos/vitessio/vitess/subscribers","subscription_url":"https://api.github.com/repos/vitessio/vitess/subscription","commits_url":"https://api.github.com/repos/vitessio/vitess/commits{/sha}","git_commits_url":"https://api.github.com/repos/vitessio/vitess/git/commits{/sha}","comments_url":"https://api.github.com/repos/vitessio/vitess/comments{/number}","issue_comment_url":"https://api.github.com/repos/vitessio/vitess/issues/comments{/number}","contents_url":"https://api.github.com/repos/vitessio/vitess/contents/{+path}","compare_url":"https://api.github.com/repos/vitessio/vitess/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vitessio/vitess/merges","archive_url":"https://api.github.com/repos/vitessio/vitess/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vitessio/vitess/downloads","issues_url":"https://api.github.com/repos/vitessio/vitess/issues{/number}","pulls_url":"https://api.github.com/repos/vitessio/vitess/pulls{/number}","milestones_url":"https://api.github.com/repos/vitessio/vitess/milestones{/number}","notifications_url":"https://api.github.com/repos/vitessio/vitess/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vitessio/vitess/labels{/name}","releases_url":"https://api.github.com/repos/vitessio/vitess/releases{/id}","deployments_url":"https://api.github.com/repos/vitessio/vitess/deployments","created_at":"2013-06-27T21:20:28Z","updated_at":"2018-09-05T12:04:35Z","pushed_at":"2018-09-05T16:32:23Z","git_url":"git://github.com/vitessio/vitess.git","ssh_url":"git@github.com:vitessio/vitess.git","clone_url":"https://github.com/vitessio/vitess.git","svn_url":"https://github.com/vitessio/vitess","homepage":"http://vitess.io","size":99735,"stargazers_count":6495,"watchers_count":6495,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":840,"mirror_url":null,"archived":false,"open_issues_count":215,"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":840,"open_issues":215,"watchers":6495,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vitessio/vitess/pulls/4183"},"html":{"href":"https://github.com/vitessio/vitess/pull/4183"},"issue":{"href":"https://api.github.com/repos/vitessio/vitess/issues/4183"},"comments":{"href":"https://api.github.com/repos/vitessio/vitess/issues/4183/comments"},"review_comments":{"href":"https://api.github.com/repos/vitessio/vitess/pulls/4183/comments"},"review_comment":{"href":"https://api.github.com/repos/vitessio/vitess/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vitessio/vitess/pulls/4183/commits"},"statuses":{"href":"https://api.github.com/repos/vitessio/vitess/statuses/5df15e2b32f20e0583f213c4f0bebfce4f8797a7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"danieltahara"}}