diff options
author | Dimitri Staessens <[email protected]> | 2020-11-23 20:01:19 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2020-11-25 15:35:27 +0100 |
commit | 4194300ec0af4e268bdb722ba13266352408009c (patch) | |
tree | f4b59c1a7dc914008de39543109d4c4cd9059a31 /src | |
parent | 4c01338e4fb8aee6b28603e7e5f7459f59db9561 (diff) | |
download | ouroboros-4194300ec0af4e268bdb722ba13266352408009c.tar.gz ouroboros-4194300ec0af4e268bdb722ba13266352408009c.zip |
lib: Reduce timerwheel CPU consumption
The timerwheel is checked during IPC calls (fevent, flow_read),
causing huge load on CPU consumption in IPCPs, since they have a lot
of fevent() threads for QoS. The timerwheel will need further
optimization), but for now I reduced the default tick time to 5 ms and
added a boolean to check that the wheel is actually used.
Signed-off-by: Dimitri Staessens <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/lib/timerwheel.c | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index e6d175d3..76d0530d 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -200,7 +200,7 @@ set(FRCT_START_WINDOW 64 CACHE STRING "Start window, must be a power of 2") set(FRCT_RTO_MIN 250 CACHE STRING "Minimum Retransmission Timeout (RTO) for FRCT (us)") -set(FRCT_TICK_TIME 500 CACHE STRING +set(FRCT_TICK_TIME 5000 CACHE STRING "Tick time for FRCT activity (retransmission, acknowledgments) (us)") set(RXM_BUFFER_ON_HEAP FALSE CACHE BOOL "Store packets for retransmission on the heap instead of in packet buffer") diff --git a/src/lib/timerwheel.c b/src/lib/timerwheel.c index cd3074cb..a9f3c72a 100644 --- a/src/lib/timerwheel.c +++ b/src/lib/timerwheel.c @@ -65,6 +65,8 @@ struct { size_t prv_rxm; /* Last processed rxm slot at lvl 0. */ size_t prv_ack; /* Last processed ack slot. */ pthread_mutex_t lock; + + bool in_use; } rw; static void timerwheel_fini(void) @@ -140,6 +142,9 @@ static void timerwheel_move(void) size_t i; size_t j; + if (!__sync_bool_compare_and_swap(&rw.in_use, true, true)) + return; + pthread_mutex_lock(&rw.lock); pthread_cleanup_push((void (*) (void *)) pthread_mutex_unlock, @@ -373,6 +378,8 @@ static int timerwheel_rxm(struct frcti * frcti, #endif pthread_mutex_unlock(&rw.lock); + __sync_bool_compare_and_swap(&rw.in_use, false, true); + return 0; } @@ -416,5 +423,7 @@ static int timerwheel_ack(int fd, pthread_mutex_unlock(&rw.lock); + __sync_bool_compare_and_swap(&rw.in_use, false, true); + return 0; } |