0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-03-13 09:57:02 +00:00

Mainloop: Dropped old socket prioritization magic

This is now done in worker threads and the mainloop needs to do other things,
most notably kernel and CLI, with less overhead of repeatedly checking poll.
This commit is contained in:
Maria Matejka 2024-12-22 21:32:28 +01:00
parent 8349536278
commit 3d1f19e335
2 changed files with 8 additions and 15 deletions

View File

@ -1403,7 +1403,7 @@ bool task_still_in_limit(void)
{
static u64 main_counter = 0;
if (this_birdloop == &main_birdloop)
return (++main_counter % 2048); /* This is a hack because of no accounting in mainloop */
return (++main_counter % 512); /* This is a hack because of no accounting in mainloop */
else
return ns_now() < account_last + this_thread->max_loop_time_ns;
}

View File

@ -53,14 +53,15 @@
/* Maximum number of calls of tx handler for one socket in one
* poll iteration. Should be small enough to not monopolize CPU by
* one protocol instance.
* one protocol instance. But as most of the problems are now offloaded
* to worker threads, too low values may actually bring problems with
* latency.
*/
#define MAX_STEPS 4
#define MAX_STEPS 2048
/* Maximum number of calls of rx handler for all sockets in one poll
iteration. RX callbacks are often much more costly so we limit
this to gen small latencies */
#define MAX_RX_STEPS 4
iteration. RX callbacks are often a little bit more costly. */
#define MAX_RX_STEPS 512
/*
@ -2581,8 +2582,6 @@ io_init(void)
srandom((uint) (now ^ (now >> 32)));
}
static int short_loops = 0;
#define SHORT_LOOP_MAX 10
#define WORK_EVENTS_MAX 10
sock *stored_sock;
@ -2670,10 +2669,9 @@ io_loop(void)
{
if (pfd.pfd.data[0].revents & POLLIN)
{
/* IO loop reload requested */
/* Somebody sent an event to mainloop */
pipe_drain(&main_birdloop.thread->wakeup);
atomic_fetch_and_explicit(&main_birdloop.thread_transition, ~LTT_PING, memory_order_acq_rel);
continue;
}
times_update();
@ -2719,11 +2717,6 @@ io_loop(void)
main_birdloop.sock_active = sk_next(s);
}
short_loops++;
if (events && (short_loops < SHORT_LOOP_MAX))
continue;
short_loops = 0;
int count = 0;
main_birdloop.sock_active = stored_sock;
if (main_birdloop.sock_active == NULL)