87 lines
2.7 KiB
Plaintext
87 lines
2.7 KiB
Plaintext
From 3d1f19e335f55c8cfa3cb7ca9d7b88ca03173d8e Mon Sep 17 00:00:00 2001
|
|
From: Maria Matejka <mq@ucw.cz>
|
|
Date: Sun, 22 Dec 2024 21:32:28 +0100
|
|
Subject: [PATCH] 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.
|
|
---
|
|
sysdep/unix/io-loop.c | 2 +-
|
|
sysdep/unix/io.c | 21 +++++++--------------
|
|
2 files changed, 8 insertions(+), 15 deletions(-)
|
|
|
|
diff --git a/sysdep/unix/io-loop.c b/sysdep/unix/io-loop.c
|
|
index f69189e06..a72c69a03 100644
|
|
--- sysdep/unix/io-loop.c
|
|
+++ sysdep/unix/io-loop.c
|
|
@@ -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;
|
|
}
|
|
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
|
|
index f9785c074..51395e1e9 100644
|
|
--- sysdep/unix/io.c
|
|
+++ sysdep/unix/io.c
|
|
@@ -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)
|
|
--
|
|
GitLab
|
|
|