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:
return "execution unit has no description yet";
}
virtual size_t num_of_scheduling_events() const {
return 0;
}
virtual void add_scheduling_event() {
// nop
}
protected:
actor_system* system_;
proxy_registry* proxies_;
......
......@@ -361,6 +361,8 @@ public:
atom_value actor_pinning_entity;
atom_value wws_start_entity;
size_t start_steal_group_idx;
size_t num_of_steal_attempts = 0;
size_t num_of_successfully_steals = 0;
};
/// Create x workers.
......@@ -502,9 +504,12 @@ public:
// try to steal every X poll attempts
if ((i % strat.steal_interval) == 0) {
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;
}
}
if (strat.sleep_duration.count() > 0)
std::this_thread::sleep_for(strat.sleep_duration);
}
......
......@@ -57,6 +57,8 @@ public:
explicit worker_data(scheduler::abstract_coordinator*) {
// nop
}
size_t num_of_steal_attempts = 0;
size_t num_of_successfully_steals = 0;
};
// Create x workers.
......
......@@ -102,6 +102,8 @@ public:
std::default_random_engine rengine;
std::uniform_int_distribution<size_t> uniform;
std::vector<poll_strategy> strategies;
size_t num_of_steal_attempts = 0;
size_t num_of_successfully_steals = 0;
};
// Create x workers.
......@@ -179,9 +181,12 @@ public:
// try to steal every X poll attempts
if ((i % strat.steal_interval) == 0) {
job = try_steal(self);
if (job)
++d(self).num_of_steal_attempts;
if (job) {
++d(self).num_of_successfully_steals;
return job;
}
}
if (strat.sleep_duration.count() > 0)
std::this_thread::sleep_for(strat.sleep_duration);
}
......
......@@ -121,6 +121,19 @@ protected:
for (auto& w : data_.workers) {
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
auto f = &abstract_coordinator::cleanup_and_release;
for (auto& w : data_.workers)
......
......@@ -48,7 +48,8 @@ public:
, id_(worker_id)
, parent_(worker_parent)
, all_workers_are_neighbors_(true)
, data_(worker_parent) {
, data_(worker_parent)
, num_of_scheduling_events_(0) {
// nop
}
......@@ -131,6 +132,14 @@ public:
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:
void run() {
CAF_SET_LOGGER_SYS(&system());
......@@ -183,6 +192,8 @@ private:
policy_data data_;
// instance of our policy object
Policy policy_;
size_t num_of_scheduling_events_;
};
} // namespace scheduler
......
......@@ -249,6 +249,7 @@ scheduled_actor::resume(execution_unit* ctx, size_t max_throughput) {
return resumable::awaiting_message;
}
} while (!ptr);
ctx->add_scheduling_event();
switch (reactivate(*ptr)) {
case activation_result::terminated:
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