{"action":"created","comment":{"url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/comments/59079456","id":59079456,"diff_hunk":"@@ -96,23 +97,60 @@ DEFINE_int32(block_domain, 1,\n static const bool block_domain_dummy\n     = gflags::RegisterFlagValidator(&FLAGS_block_domain, &ValidateBlockDomain);\n \n-static bool ValidateBufferPoolSlots(const char *flagname,\n-                                    std::uint64_t value) {\n-  if (value == 0) {\n-    std::fprintf(stderr, \"--%s must be nonzero\\n\", flagname);\n-    return false;\n-  } else {\n+/**\n+ * @brief Set or validate the buffer pool slots. When automatically picking a\n+ *        default value, check if the system is \"small\" or \"large.\" Set the \n+ *        buffer pool space to 80% of the installed main memory for small\n+ *        and 90% otherwise. \n+ *        This method follows the signature that is set by the gflags module.\n+ * @param flagname The name of the buffer pool flag. \n+ * @param value The value of this flag from the command line, or default (0)\n+ * @return True if the value was set to a legimate value, false otherwise. \n+ *         Currently this method aims to always find some legitimate value,\n+ *         and never returns false.\n+ **/\n+static bool SetOrValidateBufferPoolSlots(const char *flagname,\n+                                         std::uint64_t value) {\n+  if (value != 0) {\n+    // TODO(jmp): Check if this value  is safe and warn the user if it is not.\n+    return true;  // User supplied value is > 0 and we simply use that value.\n+  }\n+\n+  // Need to automatically pick the buffer pool size.\n+  std::uint64_t total_memory;\n+  if (utility::system::calculateTotalMemoryInBytes(&total_memory)) {\n+    // Detected the total installed memory. Now set the buffer pool size\n+    //   based on whether the system is large or small.\n+    if (total_memory/kAGigaByte < kLargeMemorySystemThresholdInGB) {\n+      // This is a \"small\" system. Leave a litte more memory for others.\n+      FLAGS_buffer_pool_slots\n+        = (total_memory*kPercentageToGrabForSmallSystems)/(kSlotSizeBytes*100);\n+    } else {\n+      // This is a \"large\" system. Grab nearly all of the installed memory.\n+      FLAGS_buffer_pool_slots\n+        = (total_memory*kPercentageToGrabForLargeSystems)/(kSlotSizeBytes*100);\n+    }","path":"storage/StorageManager.cpp","position":50,"original_position":50,"commit_id":"f9b55502b89e256fe24387f4264a08177d63b46b","original_commit_id":"3b5c91109dab7de0844e90b85b39a327f94fc969","user":{"login":"zuyu","id":2245572,"avatar_url":"https://avatars.githubusercontent.com/u/2245572?v=3","gravatar_id":"","url":"https://api.github.com/users/zuyu","html_url":"https://github.com/zuyu","followers_url":"https://api.github.com/users/zuyu/followers","following_url":"https://api.github.com/users/zuyu/following{/other_user}","gists_url":"https://api.github.com/users/zuyu/gists{/gist_id}","starred_url":"https://api.github.com/users/zuyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zuyu/subscriptions","organizations_url":"https://api.github.com/users/zuyu/orgs","repos_url":"https://api.github.com/users/zuyu/repos","events_url":"https://api.github.com/users/zuyu/events{/privacy}","received_events_url":"https://api.github.com/users/zuyu/received_events","type":"User","site_admin":false},"body":"Please add two more whitespace indentations for two `FLAGS_buffer_pool_slots` assignments above:\r\n\r\n```\r\n  FLAGS_buffer_pool_slots\r\n      = (total_memory* kPercentageToGrabForLargeSystems)/(kSlotSizeBytes*100);\r\n```\r\n\r\nAlternatively, we could refactor the `if-else` statement as the following:\r\n\r\n```\r\n  FLAGS_buffer_pool_slots =\r\n      ((total_memory/kAGigaByte < kLargeMemorySystemThresholdInGB)\r\n          ? kPercentageToGrabForSmallSystems\r\n          : kPercentageToGrabForLargeSystems) *\r\n       total_memory /\r\n       (kSlotSizeBytes*100);\r\n```","created_at":"2016-04-08T19:47:27Z","updated_at":"2016-04-08T19:47:27Z","html_url":"https://github.com/pivotalsoftware/quickstep/pull/146#discussion_r59079456","pull_request_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/146","_links":{"self":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/comments/59079456"},"html":{"href":"https://github.com/pivotalsoftware/quickstep/pull/146#discussion_r59079456"},"pull_request":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/146"}}},"pull_request":{"url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/146","id":65721285,"html_url":"https://github.com/pivotalsoftware/quickstep/pull/146","diff_url":"https://github.com/pivotalsoftware/quickstep/pull/146.diff","patch_url":"https://github.com/pivotalsoftware/quickstep/pull/146.patch","issue_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/146","number":146,"state":"open","locked":false,"title":"Automatically set the buffer pool size based on installed system memory: Part II (final)","user":{"login":"pateljm","id":8864916,"avatar_url":"https://avatars.githubusercontent.com/u/8864916?v=3","gravatar_id":"","url":"https://api.github.com/users/pateljm","html_url":"https://github.com/pateljm","followers_url":"https://api.github.com/users/pateljm/followers","following_url":"https://api.github.com/users/pateljm/following{/other_user}","gists_url":"https://api.github.com/users/pateljm/gists{/gist_id}","starred_url":"https://api.github.com/users/pateljm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pateljm/subscriptions","organizations_url":"https://api.github.com/users/pateljm/orgs","repos_url":"https://api.github.com/users/pateljm/repos","events_url":"https://api.github.com/users/pateljm/events{/privacy}","received_events_url":"https://api.github.com/users/pateljm/received_events","type":"User","site_admin":false},"body":"Use the new function to detect the installed memory. When we can detect successfully, use it to automatically set the buffer pool size. For systems with more than 32GB  of memory grab 90% for the buffer pool, otherwise only grab 80%. Some magic constants in `storage/StorageManager.cpp,` which are isolated just there. At some point when we have more of these, we may need to refactor all magic constants in one place. ","created_at":"2016-04-08T00:30:50Z","updated_at":"2016-04-08T19:47:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a662428b19ae0d86b977723cf4b5daf41252bdc5","assignee":{"login":"zuyu","id":2245572,"avatar_url":"https://avatars.githubusercontent.com/u/2245572?v=3","gravatar_id":"","url":"https://api.github.com/users/zuyu","html_url":"https://github.com/zuyu","followers_url":"https://api.github.com/users/zuyu/followers","following_url":"https://api.github.com/users/zuyu/following{/other_user}","gists_url":"https://api.github.com/users/zuyu/gists{/gist_id}","starred_url":"https://api.github.com/users/zuyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zuyu/subscriptions","organizations_url":"https://api.github.com/users/zuyu/orgs","repos_url":"https://api.github.com/users/zuyu/repos","events_url":"https://api.github.com/users/zuyu/events{/privacy}","received_events_url":"https://api.github.com/users/zuyu/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/146/commits","review_comments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/146/comments","review_comment_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/146/comments","statuses_url":"https://api.github.com/repos/pivotalsoftware/quickstep/statuses/f9b55502b89e256fe24387f4264a08177d63b46b","head":{"label":"pivotalsoftware:auto_set_buffer_pool_size","ref":"auto_set_buffer_pool_size","sha":"f9b55502b89e256fe24387f4264a08177d63b46b","user":{"login":"pivotalsoftware","id":4247270,"avatar_url":"https://avatars.githubusercontent.com/u/4247270?v=3","gravatar_id":"","url":"https://api.github.com/users/pivotalsoftware","html_url":"https://github.com/pivotalsoftware","followers_url":"https://api.github.com/users/pivotalsoftware/followers","following_url":"https://api.github.com/users/pivotalsoftware/following{/other_user}","gists_url":"https://api.github.com/users/pivotalsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/pivotalsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pivotalsoftware/subscriptions","organizations_url":"https://api.github.com/users/pivotalsoftware/orgs","repos_url":"https://api.github.com/users/pivotalsoftware/repos","events_url":"https://api.github.com/users/pivotalsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/pivotalsoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":45578105,"name":"quickstep","full_name":"pivotalsoftware/quickstep","owner":{"login":"pivotalsoftware","id":4247270,"avatar_url":"https://avatars.githubusercontent.com/u/4247270?v=3","gravatar_id":"","url":"https://api.github.com/users/pivotalsoftware","html_url":"https://github.com/pivotalsoftware","followers_url":"https://api.github.com/users/pivotalsoftware/followers","following_url":"https://api.github.com/users/pivotalsoftware/following{/other_user}","gists_url":"https://api.github.com/users/pivotalsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/pivotalsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pivotalsoftware/subscriptions","organizations_url":"https://api.github.com/users/pivotalsoftware/orgs","repos_url":"https://api.github.com/users/pivotalsoftware/repos","events_url":"https://api.github.com/users/pivotalsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/pivotalsoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pivotalsoftware/quickstep","description":"Quickstep Project","fork":false,"url":"https://api.github.com/repos/pivotalsoftware/quickstep","forks_url":"https://api.github.com/repos/pivotalsoftware/quickstep/forks","keys_url":"https://api.github.com/repos/pivotalsoftware/quickstep/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pivotalsoftware/quickstep/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pivotalsoftware/quickstep/teams","hooks_url":"https://api.github.com/repos/pivotalsoftware/quickstep/hooks","issue_events_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/events{/number}","events_url":"https://api.github.com/repos/pivotalsoftware/quickstep/events","assignees_url":"https://api.github.com/repos/pivotalsoftware/quickstep/assignees{/user}","branches_url":"https://api.github.com/repos/pivotalsoftware/quickstep/branches{/branch}","tags_url":"https://api.github.com/repos/pivotalsoftware/quickstep/tags","blobs_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/refs{/sha}","trees_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pivotalsoftware/quickstep/statuses/{sha}","languages_url":"https://api.github.com/repos/pivotalsoftware/quickstep/languages","stargazers_url":"https://api.github.com/repos/pivotalsoftware/quickstep/stargazers","contributors_url":"https://api.github.com/repos/pivotalsoftware/quickstep/contributors","subscribers_url":"https://api.github.com/repos/pivotalsoftware/quickstep/subscribers","subscription_url":"https://api.github.com/repos/pivotalsoftware/quickstep/subscription","commits_url":"https://api.github.com/repos/pivotalsoftware/quickstep/commits{/sha}","git_commits_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/commits{/sha}","comments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/comments{/number}","issue_comment_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/comments{/number}","contents_url":"https://api.github.com/repos/pivotalsoftware/quickstep/contents/{+path}","compare_url":"https://api.github.com/repos/pivotalsoftware/quickstep/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pivotalsoftware/quickstep/merges","archive_url":"https://api.github.com/repos/pivotalsoftware/quickstep/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pivotalsoftware/quickstep/downloads","issues_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues{/number}","pulls_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls{/number}","milestones_url":"https://api.github.com/repos/pivotalsoftware/quickstep/milestones{/number}","notifications_url":"https://api.github.com/repos/pivotalsoftware/quickstep/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pivotalsoftware/quickstep/labels{/name}","releases_url":"https://api.github.com/repos/pivotalsoftware/quickstep/releases{/id}","deployments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/deployments","created_at":"2015-11-05T01:06:50Z","updated_at":"2016-04-06T02:47:23Z","pushed_at":"2016-04-08T19:40:36Z","git_url":"git://github.com/pivotalsoftware/quickstep.git","ssh_url":"git@github.com:pivotalsoftware/quickstep.git","clone_url":"https://github.com/pivotalsoftware/quickstep.git","svn_url":"https://github.com/pivotalsoftware/quickstep","homepage":null,"size":8169,"stargazers_count":14,"watchers_count":14,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":21,"forks":9,"open_issues":21,"watchers":14,"default_branch":"master"}},"base":{"label":"pivotalsoftware:master","ref":"master","sha":"8229c8ade3cc9b92b1287c562f46512d355490d2","user":{"login":"pivotalsoftware","id":4247270,"avatar_url":"https://avatars.githubusercontent.com/u/4247270?v=3","gravatar_id":"","url":"https://api.github.com/users/pivotalsoftware","html_url":"https://github.com/pivotalsoftware","followers_url":"https://api.github.com/users/pivotalsoftware/followers","following_url":"https://api.github.com/users/pivotalsoftware/following{/other_user}","gists_url":"https://api.github.com/users/pivotalsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/pivotalsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pivotalsoftware/subscriptions","organizations_url":"https://api.github.com/users/pivotalsoftware/orgs","repos_url":"https://api.github.com/users/pivotalsoftware/repos","events_url":"https://api.github.com/users/pivotalsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/pivotalsoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":45578105,"name":"quickstep","full_name":"pivotalsoftware/quickstep","owner":{"login":"pivotalsoftware","id":4247270,"avatar_url":"https://avatars.githubusercontent.com/u/4247270?v=3","gravatar_id":"","url":"https://api.github.com/users/pivotalsoftware","html_url":"https://github.com/pivotalsoftware","followers_url":"https://api.github.com/users/pivotalsoftware/followers","following_url":"https://api.github.com/users/pivotalsoftware/following{/other_user}","gists_url":"https://api.github.com/users/pivotalsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/pivotalsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pivotalsoftware/subscriptions","organizations_url":"https://api.github.com/users/pivotalsoftware/orgs","repos_url":"https://api.github.com/users/pivotalsoftware/repos","events_url":"https://api.github.com/users/pivotalsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/pivotalsoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pivotalsoftware/quickstep","description":"Quickstep Project","fork":false,"url":"https://api.github.com/repos/pivotalsoftware/quickstep","forks_url":"https://api.github.com/repos/pivotalsoftware/quickstep/forks","keys_url":"https://api.github.com/repos/pivotalsoftware/quickstep/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pivotalsoftware/quickstep/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pivotalsoftware/quickstep/teams","hooks_url":"https://api.github.com/repos/pivotalsoftware/quickstep/hooks","issue_events_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/events{/number}","events_url":"https://api.github.com/repos/pivotalsoftware/quickstep/events","assignees_url":"https://api.github.com/repos/pivotalsoftware/quickstep/assignees{/user}","branches_url":"https://api.github.com/repos/pivotalsoftware/quickstep/branches{/branch}","tags_url":"https://api.github.com/repos/pivotalsoftware/quickstep/tags","blobs_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/refs{/sha}","trees_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pivotalsoftware/quickstep/statuses/{sha}","languages_url":"https://api.github.com/repos/pivotalsoftware/quickstep/languages","stargazers_url":"https://api.github.com/repos/pivotalsoftware/quickstep/stargazers","contributors_url":"https://api.github.com/repos/pivotalsoftware/quickstep/contributors","subscribers_url":"https://api.github.com/repos/pivotalsoftware/quickstep/subscribers","subscription_url":"https://api.github.com/repos/pivotalsoftware/quickstep/subscription","commits_url":"https://api.github.com/repos/pivotalsoftware/quickstep/commits{/sha}","git_commits_url":"https://api.github.com/repos/pivotalsoftware/quickstep/git/commits{/sha}","comments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/comments{/number}","issue_comment_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/comments{/number}","contents_url":"https://api.github.com/repos/pivotalsoftware/quickstep/contents/{+path}","compare_url":"https://api.github.com/repos/pivotalsoftware/quickstep/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pivotalsoftware/quickstep/merges","archive_url":"https://api.github.com/repos/pivotalsoftware/quickstep/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pivotalsoftware/quickstep/downloads","issues_url":"https://api.github.com/repos/pivotalsoftware/quickstep/issues{/number}","pulls_url":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls{/number}","milestones_url":"https://api.github.com/repos/pivotalsoftware/quickstep/milestones{/number}","notifications_url":"https://api.github.com/repos/pivotalsoftware/quickstep/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pivotalsoftware/quickstep/labels{/name}","releases_url":"https://api.github.com/repos/pivotalsoftware/quickstep/releases{/id}","deployments_url":"https://api.github.com/repos/pivotalsoftware/quickstep/deployments","created_at":"2015-11-05T01:06:50Z","updated_at":"2016-04-06T02:47:23Z","pushed_at":"2016-04-08T19:40:36Z","git_url":"git://github.com/pivotalsoftware/quickstep.git","ssh_url":"git@github.com:pivotalsoftware/quickstep.git","clone_url":"https://github.com/pivotalsoftware/quickstep.git","svn_url":"https://github.com/pivotalsoftware/quickstep","homepage":null,"size":8169,"stargazers_count":14,"watchers_count":14,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":21,"forks":9,"open_issues":21,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/146"},"html":{"href":"https://github.com/pivotalsoftware/quickstep/pull/146"},"issue":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/146"},"comments":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/issues/146/comments"},"review_comments":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/146/comments"},"review_comment":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/pulls/146/commits"},"statuses":{"href":"https://api.github.com/repos/pivotalsoftware/quickstep/statuses/f9b55502b89e256fe24387f4264a08177d63b46b"}}}}