From 84c298465f6360a8694d4837f3420961ea321fa5 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Thu, 19 Jan 2023 10:49:47 +0100 Subject: Decoupling loops from threads to allow fixed thread count On large configurations, too many threads would spawn with one thread per loop. Therefore, threads may now run multiple loops at once. The thread count is configurable and may be changed during run. All threads are spawned on startup. This change helps with memory bloating. BIRD filters need large temporary memory blocks to store their stack and also memory management keeps its hot page storage per-thread. Known bugs: * Thread autobalancing is not yet implemented. * Low latency loops are executed together with standard loops. --- conf/conf.h | 1 + doc/bird.sgml | 6 + doc/reply_codes | 1 + lib/event.c | 2 +- lib/event.h | 1 - lib/locking.h | 4 + lib/rcu.c | 24 +- lib/rcu.h | 16 +- sysdep/unix/config.Y | 11 + sysdep/unix/domain.c | 6 + sysdep/unix/io-loop.c | 773 +++++++++++++++++++++++++++++++++++++------------- sysdep/unix/io-loop.h | 46 ++- sysdep/unix/io.c | 6 +- sysdep/unix/main.c | 4 +- sysdep/unix/unix.h | 3 + test/birdtest.c | 9 +- test/bt-utils.h | 1 - 17 files changed, 671 insertions(+), 243 deletions(-) diff --git a/conf/conf.h b/conf/conf.h index ce4a3c5a..9f011ef7 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -54,6 +54,7 @@ struct config { char *err_file_name; /* File name containing error */ char *file_name; /* Name of main configuration file */ int file_fd; /* File descriptor of main configuration file */ + int thread_count; /* How many worker threads to prefork */ struct sym_scope *root_scope; /* Scope for root symbols */ int obstacle_count; /* Number of items blocking freeing of this config */ diff --git a/doc/bird.sgml b/doc/bird.sgml index 3675d2e8..37028a3b 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -532,6 +532,12 @@ include "tablename.conf";; killed by abort signal. The timeout has effective granularity of seconds, zero means disabled. Default: disabled (0). +