Switch default CAF scheduler policy to work sharing

It may generally be better for our default use-case, as workers may
save a few percent cpu utilization as this policy does not have to
use any polling like the stealing policy does.

This also helps avoid a potential issue with the implementation of
spinlocks used in the work-stealing policy in current CAF versions,
where there's some conditions where lock contention causes a thread
to spin for long periods without relinquishing the cpu to others.
This commit is contained in:
Jon Siwek 2019-06-28 16:34:33 -07:00
parent 9795782ecb
commit 5b64c35185
2 changed files with 27 additions and 7 deletions

View file

@ -178,6 +178,15 @@ void Manager::InitPostScript()
BrokerConfig config{std::move(options)};
auto scheduler_policy = get_option("Broker::scheduler_policy")->AsString()->CheckString();
if ( streq(scheduler_policy, "sharing") )
config.set("scheduler.policy", caf::atom("sharing"));
else if ( streq(scheduler_policy, "stealing") )
config.set("scheduler.policy", caf::atom("stealing"));
else
reporter->FatalError("Invalid Broker::scheduler_policy: %s", scheduler_policy);
auto max_threads_env = zeekenv("ZEEK_BROKER_MAX_THREADS");
if ( max_threads_env )