diff options
-rw-r--r-- | lib/gras_impl/query_common.hpp | 21 | ||||
-rw-r--r-- | lib/json_parser.cpp | 5 | ||||
-rw-r--r-- | lib/pmc_to_ptree.cpp | 5 | ||||
-rw-r--r-- | lib/top_block_query.cpp | 35 | ||||
-rw-r--r-- | query/chart_global_counters.js | 23 |
5 files changed, 66 insertions, 23 deletions
diff --git a/lib/gras_impl/query_common.hpp b/lib/gras_impl/query_common.hpp new file mode 100644 index 0000000..3111d11 --- /dev/null +++ b/lib/gras_impl/query_common.hpp @@ -0,0 +1,21 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#ifndef INCLUDED_LIBGRAS_IMPL_QUERY_COMMON_HPP +#define INCLUDED_LIBGRAS_IMPL_QUERY_COMMON_HPP + +#include <PMC/PMC.hpp> +#include <boost/property_tree/ptree.hpp> +#include <vector> + +// misc functions used in the implementation cpp files + +namespace gras +{ + PMCC ptree_to_pmc(const boost::property_tree::ptree &value, const std::type_info &hint); + boost::property_tree::ptree pmc_to_ptree(const PMCC &value); + + boost::property_tree::ptree json_to_ptree(const std::string &s); + std::string ptree_to_json(const boost::property_tree::ptree &p); +} + +#endif /*INCLUDED_LIBGRAS_IMPL_QUERY_COMMON_HPP*/ diff --git a/lib/json_parser.cpp b/lib/json_parser.cpp index d66297f..eef70f3 100644 --- a/lib/json_parser.cpp +++ b/lib/json_parser.cpp @@ -9,6 +9,7 @@ #endif //--------- end bullshit --------------// +#include "gras_impl/query_common.hpp" #include "gras_impl/debug.hpp" #include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/ptree.hpp> @@ -16,7 +17,7 @@ #include <sstream> #include <string> -boost::property_tree::ptree json_to_ptree(const std::string &s) +boost::property_tree::ptree gras::json_to_ptree(const std::string &s) { std::stringstream ss(s); boost::property_tree::ptree pt; @@ -25,7 +26,7 @@ boost::property_tree::ptree json_to_ptree(const std::string &s) } //http://stackoverflow.com/questions/13464383/boost-property-write-json-incorrect-behaviour -std::string ptree_to_json(const boost::property_tree::ptree &p) +std::string gras::ptree_to_json(const boost::property_tree::ptree &p) { boost::regex exp("\"(null|true|false|[0-9]+(\\.[0-9]+)?)\""); std::stringstream ss; diff --git a/lib/pmc_to_ptree.cpp b/lib/pmc_to_ptree.cpp index 1037d7e..6565fa6 100644 --- a/lib/pmc_to_ptree.cpp +++ b/lib/pmc_to_ptree.cpp @@ -1,5 +1,6 @@ // Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. +#include "gras_impl/query_common.hpp" #include "gras_impl/debug.hpp" #include <PMC/PMC.hpp> #include <PMC/Containers.hpp> @@ -11,7 +12,7 @@ using namespace boost::property_tree; -PMCC ptree_to_pmc(const ptree &value, const std::type_info &hint) +PMCC gras::ptree_to_pmc(const ptree &value, const std::type_info &hint) { //if the type is PMCC - educated guess and recursively call if (hint == typeid(PMCC) or hint == typeid(PMC)) @@ -82,7 +83,7 @@ PMCC ptree_to_pmc(const ptree &value, const std::type_info &hint) return PMC(); } -ptree pmc_to_ptree(const PMCC &value) +ptree gras::pmc_to_ptree(const PMCC &value) { ptree v; #define pmc_to_ptree_try(type) \ diff --git a/lib/top_block_query.cpp b/lib/top_block_query.cpp index 79dadfb..e1ade67 100644 --- a/lib/top_block_query.cpp +++ b/lib/top_block_query.cpp @@ -1,18 +1,17 @@ // Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. #include "element_impl.hpp" -#include <gras/top_block.hpp> +#include "gras_impl/query_common.hpp" #include <boost/foreach.hpp> #include <boost/property_tree/ptree.hpp> #include <Theron/DefaultAllocator.h> #include <algorithm> +#include <set> using namespace gras; using namespace boost::property_tree; -ThreadPool get_active_thread_pool(void); - struct GetStatsReceiver : Theron::Receiver { GetStatsReceiver(void) @@ -107,15 +106,25 @@ static ptree query_stats(ElementImpl *self, const ptree &query) root.put("default_allocator_allocation_count", allocator->GetAllocationCount()); } - ThreadPool tp = get_active_thread_pool(); - if (tp) + //thread pool counts + std::set<ThreadPool> thread_pools; + BOOST_FOREACH(Apology::Worker *w, self->executor->get_workers()) { - root.put("framework_counter_messages_processed", tp->GetCounterValue(Theron::COUNTER_MESSAGES_PROCESSED)); - root.put("framework_counter_yields", tp->GetCounterValue(Theron::COUNTER_YIELDS)); - root.put("framework_counter_local_pushes", tp->GetCounterValue(Theron::COUNTER_LOCAL_PUSHES)); - root.put("framework_counter_shared_pushes", tp->GetCounterValue(Theron::COUNTER_SHARED_PUSHES)); - root.put("framework_counter_mailbox_queue_max", tp->GetCounterValue(Theron::COUNTER_MAILBOX_QUEUE_MAX)); + BlockActor *actor = dynamic_cast<BlockActor *>(w->get_actor()); + thread_pools.insert(actor->thread_pool); } + ptree tp_e; + BOOST_FOREACH(const ThreadPool &tp, thread_pools) + { + ptree t; + t.put("framework_counter_messages_processed", tp->GetCounterValue(Theron::COUNTER_MESSAGES_PROCESSED)); + t.put("framework_counter_yields", tp->GetCounterValue(Theron::COUNTER_YIELDS)); + t.put("framework_counter_local_pushes", tp->GetCounterValue(Theron::COUNTER_LOCAL_PUSHES)); + t.put("framework_counter_shared_pushes", tp->GetCounterValue(Theron::COUNTER_SHARED_PUSHES)); + t.put("framework_counter_mailbox_queue_max", tp->GetCounterValue(Theron::COUNTER_MAILBOX_QUEUE_MAX)); + tp_e.push_back(std::make_pair("", t)); + } + root.push_back(std::make_pair("thread_pools", tp_e)); //iterate through blocks ptree blocks; @@ -162,9 +171,6 @@ static ptree query_stats(ElementImpl *self, const ptree &query) return root; } -PMCC ptree_to_pmc(const ptree &value, const std::type_info &hint); -ptree pmc_to_ptree(const PMCC &value); - static ptree query_props(ElementImpl *self, const ptree &query) { ptree root; @@ -193,9 +199,6 @@ static ptree query_props(ElementImpl *self, const ptree &query) return root; } -ptree json_to_ptree(const std::string &s); -std::string ptree_to_json(const ptree &p); - std::string TopBlock::query(const std::string &args) { //convert json args into property tree diff --git a/query/chart_global_counters.js b/query/chart_global_counters.js index 1708c01..cd5309d 100644 --- a/query/chart_global_counters.js +++ b/query/chart_global_counters.js @@ -29,11 +29,12 @@ GrasChartGlobalCounts.prototype.update = function(point) ul.append(li); } - var stuff = [ + var allocator_stuff = [ ['Allocated', 'bytes', 'default_allocator_bytes_allocated'], ['Peak size', 'bytes', 'default_allocator_peak_bytes_allocated'], ['Num mallocs', '', 'default_allocator_allocation_count'], - + ]; + var framework_stuff = [ ['Total msgs', '', 'framework_counter_messages_processed'], ['Thread yields', '', 'framework_counter_yields'], ['Local pushes', '', 'framework_counter_local_pushes'], @@ -42,7 +43,7 @@ GrasChartGlobalCounts.prototype.update = function(point) ]; var entries = 0; - $.each(stuff, function(contents_i, contents) + $.each(allocator_stuff, function(contents_i, contents) { var dir = contents[0]; var units = contents[1]; @@ -54,5 +55,21 @@ GrasChartGlobalCounts.prototype.update = function(point) entries++; } }); + $.each(point.thread_pools, function(tp_i, tp_info) + { + make_entry('ThreadPool' + tp_i.toString(), ''); + $.each(framework_stuff, function(contents_i, contents) + { + var dir = contents[0]; + var units = contents[1]; + var key = contents[2]; + var count = (key in tp_info)? tp_info[key] : 0; + if (count > 0) + { + make_entry(dir, count.toString() + ' ' + units); + entries++; + } + }); + }); if (entries == 0) make_entry("Counts", "none"); } |