summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/block_actor.cpp7
-rw-r--r--lib/block_handlers.cpp1
-rw-r--r--lib/block_task.cpp21
-rw-r--r--lib/gras_impl/block_actor.hpp14
-rw-r--r--lib/gras_impl/debug.hpp32
5 files changed, 28 insertions, 47 deletions
diff --git a/lib/block_actor.cpp b/lib/block_actor.cpp
index 19f8f97..5b1c5db 100644
--- a/lib/block_actor.cpp
+++ b/lib/block_actor.cpp
@@ -88,16 +88,9 @@ BlockActor::BlockActor(void):
active_thread_pool.reset(); //actors hold this, now its safe to reset, weak_framework only
}
this->register_handlers();
- this->handle_task_count = 0;
- this->work_count = 0;
}
BlockActor::~BlockActor(void)
{
this->mark_done();
- #ifdef WORK_COUNTS
- if (work_count == 0) std::cerr << "\n WORK FAIL!!!" << std::endl;
- std::cerr << name << " handle_task_count " << handle_task_count << std::endl;
- std::cerr << name << " work_count " << work_count << std::endl;
- #endif
}
diff --git a/lib/block_handlers.cpp b/lib/block_handlers.cpp
index 215be6d..f7a6e9e 100644
--- a/lib/block_handlers.cpp
+++ b/lib/block_handlers.cpp
@@ -16,6 +16,7 @@ void BlockActor::handle_top_active(
if (this->block_state != BLOCK_STATE_LIVE)
{
this->block_ptr->start();
+ this->stats.start_time = time_now();
}
this->block_state = BLOCK_STATE_LIVE;
this->active_token = message.token;
diff --git a/lib/block_task.cpp b/lib/block_task.cpp
index 47c0019..9acf525 100644
--- a/lib/block_task.cpp
+++ b/lib/block_task.cpp
@@ -9,6 +9,7 @@ void BlockActor::mark_done(void)
{
if (this->block_state == BLOCK_STATE_DONE) return; //can re-enter checking done first
+ this->stats.stop_time = time_now();
this->block_ptr->stop();
//flush partial output buffers to the downstream
@@ -98,18 +99,13 @@ void BlockActor::output_fail(const size_t i)
void BlockActor::handle_task(void)
{
+ const time_ticks_t task_start = time_now();
//------------------------------------------------------------------
//-- Decide if its possible to continue any processing:
//-- Handle task may get called for incoming buffers,
//-- however, not all ports may have available buffers.
//------------------------------------------------------------------
- this->handle_task_count++;
if GRAS_UNLIKELY(not this->is_work_allowed()) return;
- this->work_count++;
-
- #ifdef WORK_DEBUG
- WorkDebugPrinter WDP(block_ptr->to_string());
- #endif
//------------------------------------------------------------------
//-- Asynchronous notification through atomic variable
@@ -185,7 +181,12 @@ void BlockActor::handle_task(void)
//------------------------------------------------------------------
//-- the work
//------------------------------------------------------------------
+<<<<<<< HEAD
if GRAS_UNLIKELY(this->interruptible_thread)
+=======
+ const time_ticks_t work_start = time_now();
+ if (this->interruptible_thread)
+>>>>>>> gras: working on block stats
{
this->interruptible_thread->call();
}
@@ -193,6 +194,7 @@ void BlockActor::handle_task(void)
{
this->task_work();
}
+ const time_ticks_t work_stop = time_now();
//------------------------------------------------------------------
//-- Flush output buffers downstream
@@ -216,6 +218,13 @@ void BlockActor::handle_task(void)
//still have IO ready? kick off another task
this->task_kicker();
+
+ //save stats
+ const time_ticks_t task_time = time_now() - task_start;
+ const time_ticks_t work_time = work_stop - work_start;
+ this->stats.work_count++;
+ this->stats.total_time_work += work_time;
+ this->stats.total_time_work_other += task_time - work_time;
}
void BlockActor::consume(const size_t i, const size_t items)
diff --git a/lib/gras_impl/block_actor.hpp b/lib/gras_impl/block_actor.hpp
index cec68be..ac0bf46 100644
--- a/lib/gras_impl/block_actor.hpp
+++ b/lib/gras_impl/block_actor.hpp
@@ -22,6 +22,16 @@
namespace gras
{
+struct BlockStats
+{
+ time_ticks_t start_time;
+ time_ticks_t stop_time;
+
+ size_t work_count;
+ time_ticks_t total_time_work;
+ time_ticks_t total_time_work_other;
+};
+
struct BlockActor : Apology::Worker
{
BlockActor(void);
@@ -172,9 +182,7 @@ struct BlockActor : Apology::Worker
std::vector<std::vector<OutputHintMessage> > output_allocation_hints;
- //status keepers
- size_t handle_task_count;
- size_t work_count;
+ BlockStats stats;
};
} //namespace gras
diff --git a/lib/gras_impl/debug.hpp b/lib/gras_impl/debug.hpp
index 61376d5..c01e7d4 100644
--- a/lib/gras_impl/debug.hpp
+++ b/lib/gras_impl/debug.hpp
@@ -24,11 +24,9 @@ extern void *operator new(std::size_t n) throw (std::bad_alloc);
//----------------------------------------------------------------------
//-- define to enable these debugs:
//----------------------------------------------------------------------
-//#define WORK_DEBUG
-//#define ASSERTING
+#define ASSERTING
//#define MESSAGE_TRACING
//#define ITEM_CONSPROD
-//#define WORK_COUNTS
//----------------------------------------------------------------------
//-- time accumulation printer
@@ -68,32 +66,4 @@ extern void *operator new(std::size_t n) throw (std::bad_alloc);
#define ASSERT(x)
#endif
-//----------------------------------------------------------------------
-//-- implementation for work debug
-//----------------------------------------------------------------------
-#ifdef WORK_DEBUG
-
-#include <boost/thread/mutex.hpp>
-
-static boost::mutex work_debug_mutex;
-
-struct WorkDebugPrinter
-{
- WorkDebugPrinter(const std::string &name):
- lock(work_debug_mutex), name(name)
- {
- std::cerr << "-----> begin work on " << name << std::endl;
- }
-
- ~WorkDebugPrinter(void)
- {
- std::cerr << "<----- end work on " << name << std::endl;
- }
-
- boost::mutex::scoped_lock lock;
- std::string name;
-};
-
-#endif
-
#endif /*INCLUDED_LIBGRAS_IMPL_DEBUG_HPP*/