optimize queue-full case, reduce max queue size due to O(n) operation
authorChristian Grothoff <christian@grothoff.org>
Thu, 23 Feb 2017 14:32:06 +0000 (15:32 +0100)
committerChristian Grothoff <christian@grothoff.org>
Thu, 23 Feb 2017 14:32:06 +0000 (15:32 +0100)
src/datastore/datastore_api.c
src/fs/fs.conf.in
src/fs/gnunet-service-fs.c

index 311a612832ec4067b9e578428be060a1828fd52a..b2fc189475a5d6851e5c3021bf36a600ff6d3b5f 100644 (file)
@@ -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) &&
index 3534378ae6dc530d82a1f7fb8b9acc2bdec64953..d46de387f27389716894ec5b1b000d1dfd57bb94 100644 (file)
@@ -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
index 8c605c6a2c55f199d8e1dbf7c6fda1f6aae99123..256d0c2b8d6f676bdea084b7119214ee9cc61ecc 100644 (file)
@@ -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 =