From e38814e320e37c05c84e232569145c481e25328f Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Wed, 27 Jan 2016 12:32:55 +0100 Subject: [PATCH] client: don't run timeout code too often for performance --- kernel/mars_client.c | 8 ++++++++ kernel/mars_client.h | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/mars_client.c b/kernel/mars_client.c index 67f9b767..2f8ea2ff 100644 --- a/kernel/mars_client.c +++ b/kernel/mars_client.c @@ -767,6 +767,14 @@ void _do_timeout(struct client_output *output, struct list_head *anchor, int *ro get_real_lamport(&timeout_stamp); timeout_stamp.tv_sec -= io_timeout; + /* Don't run more than once per second */ + if (!force && + lamport_time_compare(&timeout_stamp, &brick->last_timeout_stamp) <= 0) + return; + + memcpy(&brick->last_timeout_stamp, &timeout_stamp, sizeof(brick->last_timeout_stamp)); + brick->last_timeout_stamp.tv_sec += 1; + mutex_lock(&output->mutex); for (tmp = anchor->prev, prev = tmp->prev; tmp != anchor; tmp = prev, prev = tmp->prev) { struct client_mref_aspect *mref_a; diff --git a/kernel/mars_client.h b/kernel/mars_client.h index c8a91b42..7060aaff 100644 --- a/kernel/mars_client.h +++ b/kernel/mars_client.h @@ -54,14 +54,14 @@ struct client_brick { bool allow_permuting_writes; bool separate_reads; // readonly from outside - int connection_state; // 0 = switched off, 1 = not connected, 2 = connected - /* internal */ + int connection_state; // 0 = switched off, 1 = connected atomic_t sender_count; atomic_t receiver_count; int socket_count; atomic_t fly_count; atomic_t timeout_count; struct lamport_time hang_stamp; /* submit stamp of eldest request */ + struct lamport_time last_timeout_stamp; }; struct client_input {