Commit 448117a4 authored by Sebastian Woelke's avatar Sebastian Woelke

Add debug feature, count steals and sched events

parent fa5f795c
...@@ -66,6 +66,14 @@ public: ...@@ -66,6 +66,14 @@ public:
return "execution unit has no description yet"; return "execution unit has no description yet";
} }
virtual size_t num_of_scheduling_events() const {
return 0;
}
virtual void add_scheduling_event() {
// nop
}
protected: protected:
actor_system* system_; actor_system* system_;
proxy_registry* proxies_; proxy_registry* proxies_;
......
...@@ -361,6 +361,8 @@ public: ...@@ -361,6 +361,8 @@ public:
atom_value actor_pinning_entity; atom_value actor_pinning_entity;
atom_value wws_start_entity; atom_value wws_start_entity;
size_t start_steal_group_idx; size_t start_steal_group_idx;
size_t num_of_steal_attempts = 0;
size_t num_of_successfully_steals = 0;
}; };
/// Create x workers. /// Create x workers.
...@@ -502,8 +504,11 @@ public: ...@@ -502,8 +504,11 @@ public:
// try to steal every X poll attempts // try to steal every X poll attempts
if ((i % strat.steal_interval) == 0) { if ((i % strat.steal_interval) == 0) {
job = try_steal(self, steal_group_idx, steal_cnt); job = try_steal(self, steal_group_idx, steal_cnt);
if (job) ++d(self).num_of_steal_attempts;
if (job) {
++d(self).num_of_successfully_steals;
return job; return job;
}
} }
if (strat.sleep_duration.count() > 0) if (strat.sleep_duration.count() > 0)
std::this_thread::sleep_for(strat.sleep_duration); std::this_thread::sleep_for(strat.sleep_duration);
......
...@@ -57,6 +57,8 @@ public: ...@@ -57,6 +57,8 @@ public:
explicit worker_data(scheduler::abstract_coordinator*) { explicit worker_data(scheduler::abstract_coordinator*) {
// nop // nop
} }
size_t num_of_steal_attempts = 0;
size_t num_of_successfully_steals = 0;
}; };
// Create x workers. // Create x workers.
......
...@@ -102,6 +102,8 @@ public: ...@@ -102,6 +102,8 @@ public:
std::default_random_engine rengine; std::default_random_engine rengine;
std::uniform_int_distribution<size_t> uniform; std::uniform_int_distribution<size_t> uniform;
std::vector<poll_strategy> strategies; std::vector<poll_strategy> strategies;
size_t num_of_steal_attempts = 0;
size_t num_of_successfully_steals = 0;
}; };
// Create x workers. // Create x workers.
...@@ -179,8 +181,11 @@ public: ...@@ -179,8 +181,11 @@ public:
// try to steal every X poll attempts // try to steal every X poll attempts
if ((i % strat.steal_interval) == 0) { if ((i % strat.steal_interval) == 0) {
job = try_steal(self); job = try_steal(self);
if (job) ++d(self).num_of_steal_attempts;
if (job) {
++d(self).num_of_successfully_steals;
return job; return job;
}
} }
if (strat.sleep_duration.count() > 0) if (strat.sleep_duration.count() > 0)
std::this_thread::sleep_for(strat.sleep_duration); std::this_thread::sleep_for(strat.sleep_duration);
......
...@@ -121,6 +121,19 @@ protected: ...@@ -121,6 +121,19 @@ protected:
for (auto& w : data_.workers) { for (auto& w : data_.workers) {
w->get_thread().join(); w->get_thread().join();
} }
// accumululate statistics
size_t sum_num_of_steal_attempts = 0;
size_t sum_num_of_successfully_steals = 0;
size_t sum_num_of_scheduling_events = 0;
for (auto& w : data_.workers) {
sum_num_of_steal_attempts += w->data().num_of_steal_attempts;
sum_num_of_successfully_steals += w->data().num_of_successfully_steals;
sum_num_of_scheduling_events += w->num_of_scheduling_events();
}
std::cerr<< sum_num_of_scheduling_events << ", " << sum_num_of_steal_attempts << ", " << sum_num_of_successfully_steals << std::endl;
// run cleanup code for each resumable // run cleanup code for each resumable
auto f = &abstract_coordinator::cleanup_and_release; auto f = &abstract_coordinator::cleanup_and_release;
for (auto& w : data_.workers) for (auto& w : data_.workers)
......
...@@ -48,7 +48,8 @@ public: ...@@ -48,7 +48,8 @@ public:
, id_(worker_id) , id_(worker_id)
, parent_(worker_parent) , parent_(worker_parent)
, all_workers_are_neighbors_(true) , all_workers_are_neighbors_(true)
, data_(worker_parent) { , data_(worker_parent)
, num_of_scheduling_events_(0) {
// nop // nop
} }
...@@ -131,6 +132,14 @@ public: ...@@ -131,6 +132,14 @@ public:
all_workers_are_neighbors_ = x; all_workers_are_neighbors_ = x;
} }
size_t num_of_scheduling_events() const override {
return num_of_scheduling_events_;
}
void add_scheduling_event() override {
++num_of_scheduling_events_;
}
private: private:
void run() { void run() {
CAF_SET_LOGGER_SYS(&system()); CAF_SET_LOGGER_SYS(&system());
...@@ -183,6 +192,8 @@ private: ...@@ -183,6 +192,8 @@ private:
policy_data data_; policy_data data_;
// instance of our policy object // instance of our policy object
Policy policy_; Policy policy_;
size_t num_of_scheduling_events_;
}; };
} // namespace scheduler } // namespace scheduler
......
...@@ -249,6 +249,7 @@ scheduled_actor::resume(execution_unit* ctx, size_t max_throughput) { ...@@ -249,6 +249,7 @@ scheduled_actor::resume(execution_unit* ctx, size_t max_throughput) {
return resumable::awaiting_message; return resumable::awaiting_message;
} }
} while (!ptr); } while (!ptr);
ctx->add_scheduling_event();
switch (reactivate(*ptr)) { switch (reactivate(*ptr)) {
case activation_result::terminated: case activation_result::terminated:
return resume_result::done; return resume_result::done;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment