Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3F298200CC5 for ; Tue, 11 Jul 2017 17:36:33 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3DCA6165689; Tue, 11 Jul 2017 15:36:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5E3B716566E for ; Tue, 11 Jul 2017 17:36:32 +0200 (CEST) Received: (qmail 85239 invoked by uid 500); 11 Jul 2017 15:36:30 -0000 Mailing-List: contact commits-help@impala.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@impala.incubator.apache.org Delivered-To: mailing list commits@impala.incubator.apache.org Received: (qmail 85167 invoked by uid 99); 11 Jul 2017 15:36:30 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jul 2017 15:36:30 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 004C0180412 for ; Tue, 11 Jul 2017 15:36:30 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.221 X-Spam-Level: X-Spam-Status: No, score=-4.221 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id GlLaIR4HOOge for ; Tue, 11 Jul 2017 15:36:28 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 9010F623E9 for ; Tue, 11 Jul 2017 15:36:22 +0000 (UTC) Received: (qmail 84122 invoked by uid 99); 11 Jul 2017 15:36:21 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jul 2017 15:36:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 36AA5E9687; Tue, 11 Jul 2017 15:36:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mjacobs@apache.org To: commits@impala.incubator.apache.org Date: Tue, 11 Jul 2017 15:36:21 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/3] incubator-impala git commit: IMPALA-5643: Add total number of threads created per group to /threadz archived-at: Tue, 11 Jul 2017 15:36:33 -0000 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 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 Authored: Wed Jun 28 19:04:32 2017 -0700 Committer: Impala Public Jenkins 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 ThreadCategory; + struct ThreadCategory { + int64_t num_threads_created; + map threads_by_id; + }; // All thread categorys, keyed on the category name. typedef map 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 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 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(category.second.size()), + val.AddMember("size", static_cast(category.second.threads_by_id.size()), + document->GetAllocator()); + val.AddMember("num_created", + static_cast(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(category->second.size()), + val.AddMember("size", static_cast(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}} -

{{name}} : {{size}}

+

{{name}} : (running: {{size}}, total created: {{num_created}})

{{/thread-groups}}