client: don't run timeout code too often for performance

This commit is contained in:
Thomas Schoebel-Theuer 2016-01-27 12:32:55 +01:00
parent be54077864
commit e38814e320
2 changed files with 10 additions and 2 deletions

View File

@ -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;

View File

@ -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 {