impala-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mjac...@apache.org
Subject [1/3] incubator-impala git commit: IMPALA-5643: Add total number of threads created per group to /threadz
Date Tue, 11 Jul 2017 15:36:21 GMT
Repository: incubator-impala
Updated Branches:
  refs/heads/master 7761692fb -> 36cca141e


IMPALA-5643: Add total number of threads created per group to /threadz

Change-Id: I8b532220b6940aa3d6b88a0ebaa247f6914fef53
Reviewed-on: http://gerrit.cloudera.org:8080/7390
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: Impala Public Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/dbdab4a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/dbdab4a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/dbdab4a3

Branch: refs/heads/master
Commit: dbdab4a3385c636a39dce106f8a6854ccc546014
Parents: 7761692
Author: Lars Volker <lv@cloudera.com>
Authored: Wed Jun 28 19:04:32 2017 -0700
Committer: Impala Public Jenkins <impala-public-jenkins@gerrit.cloudera.org>
Committed: Tue Jul 11 05:49:27 2017 +0000

----------------------------------------------------------------------
 be/src/util/thread.cc | 20 ++++++++++++++------
 www/threadz.tmpl      |  2 +-
 2 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/dbdab4a3/be/src/util/thread.cc
----------------------------------------------------------------------
diff --git a/be/src/util/thread.cc b/be/src/util/thread.cc
index b3c7d17..39a344f 100644
--- a/be/src/util/thread.cc
+++ b/be/src/util/thread.cc
@@ -163,7 +163,10 @@ class ThreadMgr {
   // A ThreadCategory is a set of threads that are logically related.
   // TODO: unordered_map is incompatible with boost::thread::id, but would be more
   // efficient here.
-  typedef map<const thread::id, ThreadDescriptor> ThreadCategory;
+  struct ThreadCategory {
+    int64_t num_threads_created;
+    map<const thread::id, ThreadDescriptor> threads_by_id;
+  };
 
   // All thread categorys, keyed on the category name.
   typedef map<string, ThreadCategory> ThreadCategoryMap;
@@ -197,7 +200,9 @@ Status ThreadMgr::StartInstrumentation(MetricGroup* metrics) {
 void ThreadMgr::AddThread(const thread::id& thread, const string& name,
     const string& category, int64_t tid) {
   lock_guard<mutex> l(lock_);
-  thread_categories_[category][thread] = ThreadDescriptor(category, name, tid);
+  ThreadCategory& thread_category = thread_categories_[category];
+  thread_category.threads_by_id[thread] = ThreadDescriptor(category, name, tid);
+  ++thread_category.num_threads_created;
   if (metrics_enabled_) {
     current_num_threads_metric_->Increment(1L);
     total_threads_metric_->Increment(1L);
@@ -208,7 +213,7 @@ void ThreadMgr::RemoveThread(const thread::id& boost_id, const string&
category)
   lock_guard<mutex> l(lock_);
   ThreadCategoryMap::iterator category_it = thread_categories_.find(category);
   DCHECK(category_it != thread_categories_.end());
-  category_it->second.erase(boost_id);
+  category_it->second.threads_by_id.erase(boost_id);
   if (metrics_enabled_) current_num_threads_metric_->Increment(-1L);
 }
 
@@ -222,7 +227,10 @@ void ThreadMgr::GetThreadOverview(Document* document) {
   for (const ThreadCategoryMap::value_type& category: thread_categories_) {
     Value val(kObjectType);
     val.AddMember("name", category.first.c_str(), document->GetAllocator());
-    val.AddMember("size", static_cast<uint64_t>(category.second.size()),
+    val.AddMember("size", static_cast<uint64_t>(category.second.threads_by_id.size()),
+        document->GetAllocator());
+    val.AddMember("num_created",
+        static_cast<uint64_t>(category.second.num_threads_created),
         document->GetAllocator());
     // TODO: URLEncode() name?
     lst.PushBack(val, document->GetAllocator());
@@ -245,7 +253,7 @@ void ThreadMgr::ThreadGroupUrlCallback(const Webserver::ArgumentMap&
args,
     categories_to_print.push_back(&category->second);
     Value val(kObjectType);
     val.AddMember("category", category->first.c_str(), document->GetAllocator());
-    val.AddMember("size", static_cast<uint64_t>(category->second.size()),
+    val.AddMember("size", static_cast<uint64_t>(category->second.threads_by_id.size()),
         document->GetAllocator());
     document->AddMember("thread-group", val, document->GetAllocator());
   } else {
@@ -256,7 +264,7 @@ void ThreadMgr::ThreadGroupUrlCallback(const Webserver::ArgumentMap&
args,
 
   Value lst(kArrayType);
   for (const ThreadCategory* category: categories_to_print) {
-    for (const ThreadCategory::value_type& thread: *category) {
+    for (const auto& thread : category->threads_by_id) {
       Value val(kObjectType);
       val.AddMember("name", thread.second.name().c_str(), document->GetAllocator());
       val.AddMember("id", thread.second.thread_id(), document->GetAllocator());

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/dbdab4a3/www/threadz.tmpl
----------------------------------------------------------------------
diff --git a/www/threadz.tmpl b/www/threadz.tmpl
index 9a9e3c1..cc5ec38 100644
--- a/www/threadz.tmpl
+++ b/www/threadz.tmpl
@@ -30,7 +30,7 @@ under the License.
 
 {{#thread-groups}}
 <a href='/thread-group?group={{name}}'>
-  <h3>{{name}} : {{size}}</h3>
+  <h3>{{name}} : (running: {{size}}, total created: {{num_created}})</h3>
 </a>
 {{/thread-groups}}
 


Mime
View raw message