mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Update default broker threading configuration
Now defaults to a max of 4 threads typically indepedent of core count (previously could go up to a hard cap of 8). Also now allow controlling this setting via BRO_BROKER_MAX_THREADS environment variable.
This commit is contained in:
parent
9f12b56105
commit
083947af41
2 changed files with 26 additions and 17 deletions
|
@ -56,9 +56,11 @@ export {
|
||||||
## control mechanisms).
|
## control mechanisms).
|
||||||
const congestion_queue_size = 200 &redef;
|
const congestion_queue_size = 200 &redef;
|
||||||
|
|
||||||
## Max number of threads to use for Broker/CAF functionality.
|
## Max number of threads to use for Broker/CAF functionality. Setting to
|
||||||
## Using zero will cause this to be automatically determined
|
## zero implies using the value of BRO_BROKER_MAX_THREADS environment
|
||||||
## based on number of available CPUs.
|
## variable, if set, or else typically defaults to 4 (actually 2 threads
|
||||||
|
## when simply reading offline pcaps as there's not expected to be any
|
||||||
|
## communication and more threads just adds more overhead).
|
||||||
const max_threads = 0 &redef;
|
const max_threads = 0 &redef;
|
||||||
|
|
||||||
## Max number of microseconds for under-utilized Broker/CAF
|
## Max number of microseconds for under-utilized Broker/CAF
|
||||||
|
|
|
@ -184,22 +184,29 @@ void Manager::InitPostScript()
|
||||||
config.set("scheduler.max-threads", max_threads);
|
config.set("scheduler.max-threads", max_threads);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// On high-core-count systems, spawning one thread per core
|
auto max_threads_env = getenv("BRO_BROKER_MAX_THREADS");
|
||||||
|
|
||||||
|
if ( max_threads_env )
|
||||||
|
config.set("scheduler.max-threads", atoi(max_threads_env));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// On high-core-count systems, letting CAF spawn a thread per core
|
||||||
// can lead to significant performance problems even if most
|
// can lead to significant performance problems even if most
|
||||||
// threads are under-utilized. Related:
|
// threads are under-utilized. Related:
|
||||||
// https://github.com/actor-framework/actor-framework/issues/699
|
// https://github.com/actor-framework/actor-framework/issues/699
|
||||||
if ( reading_pcaps )
|
if ( reading_pcaps )
|
||||||
config.set("scheduler.max-threads", 2u);
|
config.set("scheduler.max-threads", 2u);
|
||||||
else
|
else
|
||||||
{
|
// If the goal was to map threads to actors, 4 threads seems
|
||||||
auto hc = std::thread::hardware_concurrency();
|
// like a minimal default that could make sense -- the main
|
||||||
|
// actors that should be doing work are (1) the core,
|
||||||
if ( hc > 8u )
|
// (2) the subscriber, (3) data stores (actually made of
|
||||||
hc = 8u;
|
// a frontend + proxy actor). Number of data stores may
|
||||||
else if ( hc < 4u)
|
// actually vary, but lumped togather for simplicity. A (4)
|
||||||
hc = 4u;
|
// may be CAF's multiplexing or other internals...
|
||||||
|
// 4 is also the minimum number that CAF uses by default,
|
||||||
config.set("scheduler.max-threads", hc);
|
// even for systems with less than 4 cores.
|
||||||
|
config.set("scheduler.max-threads", 4u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue