-
Notifications
You must be signed in to change notification settings - Fork 46
SO 5.6 Tutorials TrickyThreadPool AdvThreadPoolSimulation
To see the result of a simulation with the standard adv_thread_pool dispatcher we have to create a coop with two agents: a_dashboard_t
and a_device_manager_t
. Agent a_device_manager_t
should be bound to an instance of adv_thread_pool dispatcher.
In the code, it will look like:
void run_example(const args_t & args ) {
print_args(args);
so_5::launch([&](so_5::environment_t & env) {
env.introduce_coop([&](so_5::coop_t & coop) {
const auto dashboard_mbox =
coop.make_agent<a_dashboard_t>()->so_direct_mbox();
// Run the device manager on a separate adv_thread_pool-dispatcher.
namespace disp = so_5::disp::adv_thread_pool;
coop.make_agent_with_binder<a_device_manager_t>(
disp::make_dispatcher(env, args.thread_pool_size_).
binder(disp::bind_params_t{}),
args,
dashboard_mbox);
});
});
}
There is a graphical interpretation of a run with 20 worker threads and other params with the default values:
We can see a big peak of blue color in the beginning. This is a massive creation of devices at the start of the simulation. There also big gray peaks in the left part of the diagram. It is because there are too many init_device_t
messages waiting for processing at the start of the work. Some of them wait too much time. Then many perform_io_t
messages are processed by a short time and we start to receive a big amount of reinit_device_t
messages. Some of those messages wait for too long and that produces gray peaks.
We can also see deep green flops. Each green flop is a significant decrease in the count of processed perform_io_t
messages while reinit_device_t
are handled.
Our task is to remove gray peaks and make green flops more shallow.