{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/comments/221450367","pull_request_review_id":160105278,"id":221450367,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTQ1MDM2Nw==","diff_hunk":"@@ -315,6 +323,8 @@ func NewSessionVars() *SessionVars {\n \t\tRetryLimit:                DefTiDBRetryLimit,\n \t\tDisableTxnAutoRetry:       DefTiDBDisableTxnAutoRetry,\n \t\tDDLReorgPriority:          kv.PriorityLow,\n+\t\tEnableRadixJoin:           false,\n+\t\tL2CacheSize:               cpuid.CPU.Cache.L2,","path":"sessionctx/variable/session.go","position":27,"original_position":27,"commit_id":"7a46046b34953c145714f0b8d06540974e9e15f0","original_commit_id":"7a46046b34953c145714f0b8d06540974e9e15f0","user":{"login":"eurekaka","id":6261973,"node_id":"MDQ6VXNlcjYyNjE5NzM=","avatar_url":"https://avatars2.githubusercontent.com/u/6261973?v=4","gravatar_id":"","url":"https://api.github.com/users/eurekaka","html_url":"https://github.com/eurekaka","followers_url":"https://api.github.com/users/eurekaka/followers","following_url":"https://api.github.com/users/eurekaka/following{/other_user}","gists_url":"https://api.github.com/users/eurekaka/gists{/gist_id}","starred_url":"https://api.github.com/users/eurekaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eurekaka/subscriptions","organizations_url":"https://api.github.com/users/eurekaka/orgs","repos_url":"https://api.github.com/users/eurekaka/repos","events_url":"https://api.github.com/users/eurekaka/events{/privacy}","received_events_url":"https://api.github.com/users/eurekaka/received_events","type":"User","site_admin":false},"body":"I am not familiar with golang package management, where does `cpuid.CPU.Cache.L2` variable initialized? we don't need to call a init function in package `cpuid`to set up this variable?","created_at":"2018-09-30T07:42:43Z","updated_at":"2018-09-30T07:43:02Z","html_url":"https://github.com/pingcap/tidb/pull/7816#discussion_r221450367","pull_request_url":"https://api.github.com/repos/pingcap/tidb/pulls/7816","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments/221450367"},"html":{"href":"https://github.com/pingcap/tidb/pull/7816#discussion_r221450367"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7816"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/7816","id":219121903,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5MTIxOTAz","html_url":"https://github.com/pingcap/tidb/pull/7816","diff_url":"https://github.com/pingcap/tidb/pull/7816.diff","patch_url":"https://github.com/pingcap/tidb/pull/7816.patch","issue_url":"https://api.github.com/repos/pingcap/tidb/issues/7816","number":7816,"state":"open","locked":false,"title":" executor, sessionctx: calculate radix bit number before building hash table","user":{"login":"XuHuaiyu","id":9039012,"node_id":"MDQ6VXNlcjkwMzkwMTI=","avatar_url":"https://avatars1.githubusercontent.com/u/9039012?v=4","gravatar_id":"","url":"https://api.github.com/users/XuHuaiyu","html_url":"https://github.com/XuHuaiyu","followers_url":"https://api.github.com/users/XuHuaiyu/followers","following_url":"https://api.github.com/users/XuHuaiyu/following{/other_user}","gists_url":"https://api.github.com/users/XuHuaiyu/gists{/gist_id}","starred_url":"https://api.github.com/users/XuHuaiyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XuHuaiyu/subscriptions","organizations_url":"https://api.github.com/users/XuHuaiyu/orgs","repos_url":"https://api.github.com/users/XuHuaiyu/repos","events_url":"https://api.github.com/users/XuHuaiyu/events{/privacy}","received_events_url":"https://api.github.com/users/XuHuaiyu/received_events","type":"User","site_admin":false},"body":"PTAL @winoros @eurekaka \r\n\r\n<!--\r\nThank you for contributing to TiDB! Please read TiDB's [CONTRIBUTING](https://github.com/pingcap/tidb/blob/master/CONTRIBUTING.md) document **BEFORE** filing this PR.\r\n-->\r\n\r\n### What problem does this PR solve? <!--add issue link with summary if exists-->\r\nThe first step of https://github.com/pingcap/tidb/issues/7762.\r\n\r\n### What is changed and how it works?\r\n1. This PR adds a new variable `L2CacheSize` in SessionVars to store the size of L2 cache.\r\n2. This PR introduces a new package [github.com/klauspost/cpuid](https://github.com/klauspost/cpuid) to fetch the L2CacheSize.\r\n2. Calculate the radix bit number after we read all the inner relation, the formula used is mentioned in proposal https://github.com/pingcap/tidb/blob/master/docs/design/2018-09-21-radix-hashjoin.md#proposal.\r\n3. Note: We do not trigger the calculation for the radix bit number before the radix hash join is fully implemented. We use `UseRadixPartion` to control this according to the value of session variable \"tidb_enable_radix_join\". \r\n\r\n### Check List <!--REMOVE the items that are not applicable-->\r\n\r\nTests <!-- At least one of them must be included. -->\r\n\r\n - Manual test\r\n1. Set value of L2CacheSize to 1 in sessionctx/variable/session.go: NewSessionVars.\r\n2. create table t(a bigint), and insert 8 values.\r\n3. Add a log to check the value of HashJoinExec.radixBit which should be 8.\r\n4. create table t(a bigint), and insert 64 values.\r\n5. Add a log to check the value of HashJoinExec.radixBit which should be 9.\r\n\r\nCode changes\r\n\r\n - Has exported variable/fields change\r\n\r\nSide effects\r\n\r\nnone\r\n\r\nRelated changes\r\n\r\nnone\r\n","created_at":"2018-09-29T03:20:20Z","updated_at":"2018-09-30T07:43:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f231f5af1b8af808200a6691f214312cfa52e26a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":970807266,"node_id":"MDU6TGFiZWw5NzA4MDcyNjY=","url":"https://api.github.com/repos/pingcap/tidb/labels/component/executor","name":"component/executor","color":"000000","default":false},{"id":256872088,"node_id":"MDU6TGFiZWwyNTY4NzIwODg=","url":"https://api.github.com/repos/pingcap/tidb/labels/type/enhancement","name":"type/enhancement","color":"84b6eb","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tidb/pulls/7816/commits","review_comments_url":"https://api.github.com/repos/pingcap/tidb/pulls/7816/comments","review_comment_url":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/7816/comments","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/7a46046b34953c145714f0b8d06540974e9e15f0","head":{"label":"XuHuaiyu:fetch_l2","ref":"fetch_l2","sha":"7a46046b34953c145714f0b8d06540974e9e15f0","user":{"login":"XuHuaiyu","id":9039012,"node_id":"MDQ6VXNlcjkwMzkwMTI=","avatar_url":"https://avatars1.githubusercontent.com/u/9039012?v=4","gravatar_id":"","url":"https://api.github.com/users/XuHuaiyu","html_url":"https://github.com/XuHuaiyu","followers_url":"https://api.github.com/users/XuHuaiyu/followers","following_url":"https://api.github.com/users/XuHuaiyu/following{/other_user}","gists_url":"https://api.github.com/users/XuHuaiyu/gists{/gist_id}","starred_url":"https://api.github.com/users/XuHuaiyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XuHuaiyu/subscriptions","organizations_url":"https://api.github.com/users/XuHuaiyu/orgs","repos_url":"https://api.github.com/users/XuHuaiyu/repos","events_url":"https://api.github.com/users/XuHuaiyu/events{/privacy}","received_events_url":"https://api.github.com/users/XuHuaiyu/received_events","type":"User","site_admin":false},"repo":{"id":63865082,"node_id":"MDEwOlJlcG9zaXRvcnk2Mzg2NTA4Mg==","name":"tidb","full_name":"XuHuaiyu/tidb","private":false,"owner":{"login":"XuHuaiyu","id":9039012,"node_id":"MDQ6VXNlcjkwMzkwMTI=","avatar_url":"https://avatars1.githubusercontent.com/u/9039012?v=4","gravatar_id":"","url":"https://api.github.com/users/XuHuaiyu","html_url":"https://github.com/XuHuaiyu","followers_url":"https://api.github.com/users/XuHuaiyu/followers","following_url":"https://api.github.com/users/XuHuaiyu/following{/other_user}","gists_url":"https://api.github.com/users/XuHuaiyu/gists{/gist_id}","starred_url":"https://api.github.com/users/XuHuaiyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XuHuaiyu/subscriptions","organizations_url":"https://api.github.com/users/XuHuaiyu/orgs","repos_url":"https://api.github.com/users/XuHuaiyu/repos","events_url":"https://api.github.com/users/XuHuaiyu/events{/privacy}","received_events_url":"https://api.github.com/users/XuHuaiyu/received_events","type":"User","site_admin":false},"html_url":"https://github.com/XuHuaiyu/tidb","description":"TiDB is a distributed NewSQL database compatible with MySQL protocol ","fork":true,"url":"https://api.github.com/repos/XuHuaiyu/tidb","forks_url":"https://api.github.com/repos/XuHuaiyu/tidb/forks","keys_url":"https://api.github.com/repos/XuHuaiyu/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/XuHuaiyu/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/XuHuaiyu/tidb/teams","hooks_url":"https://api.github.com/repos/XuHuaiyu/tidb/hooks","issue_events_url":"https://api.github.com/repos/XuHuaiyu/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/XuHuaiyu/tidb/events","assignees_url":"https://api.github.com/repos/XuHuaiyu/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/XuHuaiyu/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/XuHuaiyu/tidb/tags","blobs_url":"https://api.github.com/repos/XuHuaiyu/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/XuHuaiyu/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/XuHuaiyu/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/XuHuaiyu/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/XuHuaiyu/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/XuHuaiyu/tidb/languages","stargazers_url":"https://api.github.com/repos/XuHuaiyu/tidb/stargazers","contributors_url":"https://api.github.com/repos/XuHuaiyu/tidb/contributors","subscribers_url":"https://api.github.com/repos/XuHuaiyu/tidb/subscribers","subscription_url":"https://api.github.com/repos/XuHuaiyu/tidb/subscription","commits_url":"https://api.github.com/repos/XuHuaiyu/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/XuHuaiyu/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/XuHuaiyu/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/XuHuaiyu/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/XuHuaiyu/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/XuHuaiyu/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/XuHuaiyu/tidb/merges","archive_url":"https://api.github.com/repos/XuHuaiyu/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/XuHuaiyu/tidb/downloads","issues_url":"https://api.github.com/repos/XuHuaiyu/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/XuHuaiyu/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/XuHuaiyu/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/XuHuaiyu/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/XuHuaiyu/tidb/labels{/name}","releases_url":"https://api.github.com/repos/XuHuaiyu/tidb/releases{/id}","deployments_url":"https://api.github.com/repos/XuHuaiyu/tidb/deployments","created_at":"2016-07-21T11:50:49Z","updated_at":"2016-07-21T11:50:51Z","pushed_at":"2018-09-30T03:33:22Z","git_url":"git://github.com/XuHuaiyu/tidb.git","ssh_url":"git@github.com:XuHuaiyu/tidb.git","clone_url":"https://github.com/XuHuaiyu/tidb.git","svn_url":"https://github.com/XuHuaiyu/tidb","homepage":"","size":57220,"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":"pingcap:master","ref":"master","sha":"6a1e94ffa6a7d7cd66d1c433d29e358e07c4498b","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":41986369,"node_id":"MDEwOlJlcG9zaXRvcnk0MTk4NjM2OQ==","name":"tidb","full_name":"pingcap/tidb","private":false,"owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pingcap/tidb","description":"TiDB is a distributed HTAP database compatible with the MySQL protocol ","fork":false,"url":"https://api.github.com/repos/pingcap/tidb","forks_url":"https://api.github.com/repos/pingcap/tidb/forks","keys_url":"https://api.github.com/repos/pingcap/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tidb/teams","hooks_url":"https://api.github.com/repos/pingcap/tidb/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tidb/events","assignees_url":"https://api.github.com/repos/pingcap/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tidb/tags","blobs_url":"https://api.github.com/repos/pingcap/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tidb/languages","stargazers_url":"https://api.github.com/repos/pingcap/tidb/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tidb/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tidb/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tidb/subscription","commits_url":"https://api.github.com/repos/pingcap/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tidb/merges","archive_url":"https://api.github.com/repos/pingcap/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tidb/downloads","issues_url":"https://api.github.com/repos/pingcap/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tidb/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tidb/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tidb/deployments","created_at":"2015-09-06T04:01:52Z","updated_at":"2018-09-30T07:33:12Z","pushed_at":"2018-09-30T07:33:01Z","git_url":"git://github.com/pingcap/tidb.git","ssh_url":"git@github.com:pingcap/tidb.git","clone_url":"https://github.com/pingcap/tidb.git","svn_url":"https://github.com/pingcap/tidb","homepage":"https://pingcap.com","size":83071,"stargazers_count":15142,"watchers_count":15142,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2138,"mirror_url":null,"archived":false,"open_issues_count":571,"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":2138,"open_issues":571,"watchers":15142,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7816"},"html":{"href":"https://github.com/pingcap/tidb/pull/7816"},"issue":{"href":"https://api.github.com/repos/pingcap/tidb/issues/7816"},"comments":{"href":"https://api.github.com/repos/pingcap/tidb/issues/7816/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7816/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7816/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tidb/statuses/7a46046b34953c145714f0b8d06540974e9e15f0"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"eurekaka"}}