From: Christian Grothoff Date: Thu, 23 Feb 2017 14:32:06 +0000 (+0100) Subject: optimize queue-full case, reduce max queue size due to O(n) operation X-Git-Tag: taler-0.2.1~70^2~24 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=427b846c6c52194e5246bc913c65ac632f54f604;p=oweals%2Fgnunet.git optimize queue-full case, reduce max queue size due to O(n) operation --- diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 311a61283..b2fc18947 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c @@ -498,6 +498,17 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h, struct GNUNET_DATASTORE_QueueEntry *pos; unsigned int c; + if ( (h->queue_size == max_queue_size) && + (h->queue_tail->priority >= queue_priority) ) + { + GNUNET_STATISTICS_update (h->stats, + gettext_noop ("# queue overflows"), + 1, + GNUNET_NO); + GNUNET_MQ_discard (env); + return NULL; + } + c = 0; pos = h->queue_head; while ( (NULL != pos) && diff --git a/src/fs/fs.conf.in b/src/fs/fs.conf.in index 3534378ae..d46de387f 100644 --- a/src/fs/fs.conf.in +++ b/src/fs/fs.conf.in @@ -36,7 +36,7 @@ MAX_PENDING_REQUESTS = 65536 # How many requests do we have at most waiting in the queue towards # the datastore? (important for memory consumption) -DATASTORE_QUEUE_SIZE = 1024 +DATASTORE_QUEUE_SIZE = 32 # Maximum frequency we're allowed to poll the datastore # for content for migration (can be used to reduce diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 8c605c6a2..256d0c2b8 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -1349,7 +1349,7 @@ run (void *cls, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_INFO, "fs", "DATASTORE_QUEUE_SIZE"); - dqs = 1024; + dqs = 32; } GSF_datastore_queue_size = (unsigned int) dqs; GSF_enable_randomized_delays =