{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/rocksdb/pulls/comments/227109429","pull_request_review_id":167074360,"id":227109429,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzEwOTQyOQ==","diff_hunk":"@@ -599,7 +613,64 @@ void DBImpl::StartTimedTasks() {\n             stats_dump_period_sec * 1000000));\n       }\n     }\n+    stats_persist_period_sec = mutable_db_options_.stats_persist_period_sec;\n+    if (stats_persist_period_sec > 0) {\n+      if (!thread_persist_stats_) {\n+        thread_persist_stats_.reset(new rocksdb::RepeatableThread(\n+          [this]() { DBImpl::PersistStats(); }, \"pst_st\", env_,\n+          stats_persist_period_sec * 1000000));\n+      }\n+    }\n+  }\n+}\n+\n+void DBImpl::PersistStats() {\n+  TEST_SYNC_POINT(\"DBImpl::PersistStats:1\");\n+#ifndef ROCKSDB_LITE\n+  const DBPropertyInfo* cf_property_info =\n+      GetPropertyInfo(DB::Properties::kCFStats);\n+  assert(cf_property_info != nullptr);\n+  const DBPropertyInfo* db_property_info =\n+      GetPropertyInfo(DB::Properties::kDBStats);\n+  assert(db_property_info != nullptr);\n+  std::map<std::string, std::string> stats_map;\n+  if (shutdown_initiated_) {\n+    return;\n+  }\n+  {\n+    InstrumentedMutexLock l(&mutex_);\n+    default_cf_internal_stats_->GetMapProperty(\n+        *db_property_info, DB::Properties::kDBStats, &stats_map);\n+    for (auto cfd : *versions_->GetColumnFamilySet()) {\n+      if (cfd->initialized()) {\n+        cfd->internal_stats()->GetMapProperty(\n+            *cf_property_info, DB::Properties::kCFStatsNoFileHistogram,\n+            &stats_map);\n+      }\n+    }\n+    for (auto cfd : *versions_->GetColumnFamilySet()) {\n+      if (cfd->initialized()) {\n+        cfd->internal_stats()->GetMapProperty(\n+            *cf_property_info, DB::Properties::kCFFileHistogram, &stats_map);\n+      }\n+    }\n+  }\n+  TEST_SYNC_POINT(\"DBImpl::PersistStats:2\");\n+  ROCKS_LOG_WARN(immutable_db_options_.info_log,\n+                 \"------- PERSISTING STATS -------\");","path":"db/db_impl.cc","position":112,"original_position":112,"commit_id":"b0513da4280b8ef21f74cd532acf39b29b3f4f26","original_commit_id":"b0513da4280b8ef21f74cd532acf39b29b3f4f26","user":{"login":"siying","id":5334567,"node_id":"MDQ6VXNlcjUzMzQ1Njc=","avatar_url":"https://avatars3.githubusercontent.com/u/5334567?v=4","gravatar_id":"","url":"https://api.github.com/users/siying","html_url":"https://github.com/siying","followers_url":"https://api.github.com/users/siying/followers","following_url":"https://api.github.com/users/siying/following{/other_user}","gists_url":"https://api.github.com/users/siying/gists{/gist_id}","starred_url":"https://api.github.com/users/siying/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siying/subscriptions","organizations_url":"https://api.github.com/users/siying/orgs","repos_url":"https://api.github.com/users/siying/repos","events_url":"https://api.github.com/users/siying/events{/privacy}","received_events_url":"https://api.github.com/users/siying/received_events","type":"User","site_admin":false},"body":"Why add a log line?","created_at":"2018-10-22T19:37:49Z","updated_at":"2018-10-22T19:42:23Z","html_url":"https://github.com/facebook/rocksdb/pull/4535#discussion_r227109429","pull_request_url":"https://api.github.com/repos/facebook/rocksdb/pulls/4535","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/comments/227109429"},"html":{"href":"https://github.com/facebook/rocksdb/pull/4535#discussion_r227109429"},"pull_request":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/4535"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/rocksdb/pulls/4535","id":224031545,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI0MDMxNTQ1","html_url":"https://github.com/facebook/rocksdb/pull/4535","diff_url":"https://github.com/facebook/rocksdb/pull/4535.diff","patch_url":"https://github.com/facebook/rocksdb/pull/4535.patch","issue_url":"https://api.github.com/repos/facebook/rocksdb/issues/4535","number":4535,"state":"open","locked":false,"title":"Persistent stats: periodically persist RocksDB stats ","user":{"login":"miasantreble","id":12212793,"node_id":"MDQ6VXNlcjEyMjEyNzkz","avatar_url":"https://avatars3.githubusercontent.com/u/12212793?v=4","gravatar_id":"","url":"https://api.github.com/users/miasantreble","html_url":"https://github.com/miasantreble","followers_url":"https://api.github.com/users/miasantreble/followers","following_url":"https://api.github.com/users/miasantreble/following{/other_user}","gists_url":"https://api.github.com/users/miasantreble/gists{/gist_id}","starred_url":"https://api.github.com/users/miasantreble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miasantreble/subscriptions","organizations_url":"https://api.github.com/users/miasantreble/orgs","repos_url":"https://api.github.com/users/miasantreble/repos","events_url":"https://api.github.com/users/miasantreble/events{/privacy}","received_events_url":"https://api.github.com/users/miasantreble/received_events","type":"User","site_admin":false},"body":"This PR introduces persistent stats feature which automatically writes RocksDB statistics back into RocksDB periodically. The stats are written to a builtin column family `_persistent_stats` which is maintained without requiring user intervention. User will be able to access the new column family via public API `DBImpl::PersistentStatsColumnFamily()`.","created_at":"2018-10-18T17:06:26Z","updated_at":"2018-10-22T19:42:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"af5d3ddea21494c4391dbb3048c751b545aa69fe","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":196859108,"node_id":"MDU6TGFiZWwxOTY4NTkxMDg=","url":"https://api.github.com/repos/facebook/rocksdb/labels/CLA%20Signed","name":"CLA Signed","color":"009900","default":false},{"id":919790210,"node_id":"MDU6TGFiZWw5MTk3OTAyMTA=","url":"https://api.github.com/repos/facebook/rocksdb/labels/WIP","name":"WIP","color":"c2e0c6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/facebook/rocksdb/pulls/4535/commits","review_comments_url":"https://api.github.com/repos/facebook/rocksdb/pulls/4535/comments","review_comment_url":"https://api.github.com/repos/facebook/rocksdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/rocksdb/issues/4535/comments","statuses_url":"https://api.github.com/repos/facebook/rocksdb/statuses/b0513da4280b8ef21f74cd532acf39b29b3f4f26","head":{"label":"miasantreble:persistent-stats-initial","ref":"persistent-stats-initial","sha":"b0513da4280b8ef21f74cd532acf39b29b3f4f26","user":{"login":"miasantreble","id":12212793,"node_id":"MDQ6VXNlcjEyMjEyNzkz","avatar_url":"https://avatars3.githubusercontent.com/u/12212793?v=4","gravatar_id":"","url":"https://api.github.com/users/miasantreble","html_url":"https://github.com/miasantreble","followers_url":"https://api.github.com/users/miasantreble/followers","following_url":"https://api.github.com/users/miasantreble/following{/other_user}","gists_url":"https://api.github.com/users/miasantreble/gists{/gist_id}","starred_url":"https://api.github.com/users/miasantreble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miasantreble/subscriptions","organizations_url":"https://api.github.com/users/miasantreble/orgs","repos_url":"https://api.github.com/users/miasantreble/repos","events_url":"https://api.github.com/users/miasantreble/events{/privacy}","received_events_url":"https://api.github.com/users/miasantreble/received_events","type":"User","site_admin":false},"repo":{"id":103351953,"node_id":"MDEwOlJlcG9zaXRvcnkxMDMzNTE5NTM=","name":"rocksdb","full_name":"miasantreble/rocksdb","private":false,"owner":{"login":"miasantreble","id":12212793,"node_id":"MDQ6VXNlcjEyMjEyNzkz","avatar_url":"https://avatars3.githubusercontent.com/u/12212793?v=4","gravatar_id":"","url":"https://api.github.com/users/miasantreble","html_url":"https://github.com/miasantreble","followers_url":"https://api.github.com/users/miasantreble/followers","following_url":"https://api.github.com/users/miasantreble/following{/other_user}","gists_url":"https://api.github.com/users/miasantreble/gists{/gist_id}","starred_url":"https://api.github.com/users/miasantreble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miasantreble/subscriptions","organizations_url":"https://api.github.com/users/miasantreble/orgs","repos_url":"https://api.github.com/users/miasantreble/repos","events_url":"https://api.github.com/users/miasantreble/events{/privacy}","received_events_url":"https://api.github.com/users/miasantreble/received_events","type":"User","site_admin":false},"html_url":"https://github.com/miasantreble/rocksdb","description":"A library that provides an embeddable, persistent key-value store for fast storage.","fork":true,"url":"https://api.github.com/repos/miasantreble/rocksdb","forks_url":"https://api.github.com/repos/miasantreble/rocksdb/forks","keys_url":"https://api.github.com/repos/miasantreble/rocksdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/miasantreble/rocksdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/miasantreble/rocksdb/teams","hooks_url":"https://api.github.com/repos/miasantreble/rocksdb/hooks","issue_events_url":"https://api.github.com/repos/miasantreble/rocksdb/issues/events{/number}","events_url":"https://api.github.com/repos/miasantreble/rocksdb/events","assignees_url":"https://api.github.com/repos/miasantreble/rocksdb/assignees{/user}","branches_url":"https://api.github.com/repos/miasantreble/rocksdb/branches{/branch}","tags_url":"https://api.github.com/repos/miasantreble/rocksdb/tags","blobs_url":"https://api.github.com/repos/miasantreble/rocksdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/miasantreble/rocksdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/miasantreble/rocksdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/miasantreble/rocksdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/miasantreble/rocksdb/statuses/{sha}","languages_url":"https://api.github.com/repos/miasantreble/rocksdb/languages","stargazers_url":"https://api.github.com/repos/miasantreble/rocksdb/stargazers","contributors_url":"https://api.github.com/repos/miasantreble/rocksdb/contributors","subscribers_url":"https://api.github.com/repos/miasantreble/rocksdb/subscribers","subscription_url":"https://api.github.com/repos/miasantreble/rocksdb/subscription","commits_url":"https://api.github.com/repos/miasantreble/rocksdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/miasantreble/rocksdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/miasantreble/rocksdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/miasantreble/rocksdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/miasantreble/rocksdb/contents/{+path}","compare_url":"https://api.github.com/repos/miasantreble/rocksdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/miasantreble/rocksdb/merges","archive_url":"https://api.github.com/repos/miasantreble/rocksdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/miasantreble/rocksdb/downloads","issues_url":"https://api.github.com/repos/miasantreble/rocksdb/issues{/number}","pulls_url":"https://api.github.com/repos/miasantreble/rocksdb/pulls{/number}","milestones_url":"https://api.github.com/repos/miasantreble/rocksdb/milestones{/number}","notifications_url":"https://api.github.com/repos/miasantreble/rocksdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/miasantreble/rocksdb/labels{/name}","releases_url":"https://api.github.com/repos/miasantreble/rocksdb/releases{/id}","deployments_url":"https://api.github.com/repos/miasantreble/rocksdb/deployments","created_at":"2017-09-13T04:08:50Z","updated_at":"2018-10-22T18:15:21Z","pushed_at":"2018-10-22T18:15:17Z","git_url":"git://github.com/miasantreble/rocksdb.git","ssh_url":"git@github.com:miasantreble/rocksdb.git","clone_url":"https://github.com/miasantreble/rocksdb.git","svn_url":"https://github.com/miasantreble/rocksdb","homepage":"http://rocksdb.org","size":119188,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"a4d9aa6b18e20fc6499e0ca73ee0342a8fc5fe95","user":{"login":"facebook","id":69631,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NjMx","avatar_url":"https://avatars3.githubusercontent.com/u/69631?v=4","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":6934395,"node_id":"MDEwOlJlcG9zaXRvcnk2OTM0Mzk1","name":"rocksdb","full_name":"facebook/rocksdb","private":false,"owner":{"login":"facebook","id":69631,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NjMx","avatar_url":"https://avatars3.githubusercontent.com/u/69631?v=4","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/facebook/rocksdb","description":"A library that provides an embeddable, persistent key-value store for fast storage.","fork":false,"url":"https://api.github.com/repos/facebook/rocksdb","forks_url":"https://api.github.com/repos/facebook/rocksdb/forks","keys_url":"https://api.github.com/repos/facebook/rocksdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/rocksdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/rocksdb/teams","hooks_url":"https://api.github.com/repos/facebook/rocksdb/hooks","issue_events_url":"https://api.github.com/repos/facebook/rocksdb/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/rocksdb/events","assignees_url":"https://api.github.com/repos/facebook/rocksdb/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/rocksdb/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/rocksdb/tags","blobs_url":"https://api.github.com/repos/facebook/rocksdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/rocksdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/rocksdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/rocksdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/rocksdb/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/rocksdb/languages","stargazers_url":"https://api.github.com/repos/facebook/rocksdb/stargazers","contributors_url":"https://api.github.com/repos/facebook/rocksdb/contributors","subscribers_url":"https://api.github.com/repos/facebook/rocksdb/subscribers","subscription_url":"https://api.github.com/repos/facebook/rocksdb/subscription","commits_url":"https://api.github.com/repos/facebook/rocksdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/rocksdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/rocksdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/rocksdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/rocksdb/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/rocksdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/rocksdb/merges","archive_url":"https://api.github.com/repos/facebook/rocksdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/rocksdb/downloads","issues_url":"https://api.github.com/repos/facebook/rocksdb/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/rocksdb/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/rocksdb/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/rocksdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/rocksdb/labels{/name}","releases_url":"https://api.github.com/repos/facebook/rocksdb/releases{/id}","deployments_url":"https://api.github.com/repos/facebook/rocksdb/deployments","created_at":"2012-11-30T06:16:18Z","updated_at":"2018-10-22T17:22:18Z","pushed_at":"2018-10-22T18:32:40Z","git_url":"git://github.com/facebook/rocksdb.git","ssh_url":"git@github.com:facebook/rocksdb.git","clone_url":"https://github.com/facebook/rocksdb.git","svn_url":"https://github.com/facebook/rocksdb","homepage":"http://rocksdb.org","size":119389,"stargazers_count":11847,"watchers_count":11847,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2616,"mirror_url":null,"archived":false,"open_issues_count":234,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2616,"open_issues":234,"watchers":11847,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/4535"},"html":{"href":"https://github.com/facebook/rocksdb/pull/4535"},"issue":{"href":"https://api.github.com/repos/facebook/rocksdb/issues/4535"},"comments":{"href":"https://api.github.com/repos/facebook/rocksdb/issues/4535/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/4535/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/4535/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/rocksdb/statuses/b0513da4280b8ef21f74cd532acf39b29b3f4f26"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"siying"}}