gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: make thread pool size configurab


From: gnunet
Subject: [taler-exchange] branch master updated: make thread pool size configurable via command line argument, default to #CPUs available
Date: Tue, 18 Aug 2020 16:07:26 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 1cd3f328 make thread pool size configurable via command line argument, 
default to #CPUs available
1cd3f328 is described below

commit 1cd3f3281b19e2b739eca02a4b21f756e962f78c
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Tue Aug 18 19:37:12 2020 +0530

    make thread pool size configurable via command line argument, default to 
#CPUs available
---
 src/exchange/taler-exchange-httpd.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/exchange/taler-exchange-httpd.c 
b/src/exchange/taler-exchange-httpd.c
index bca7a623..73cc3530 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -24,6 +24,7 @@
 #include <gnunet/gnunet_util_lib.h>
 #include <jansson.h>
 #include <microhttpd.h>
+#include <sched.h>
 #include <pthread.h>
 #include <sys/resource.h>
 #include "taler_mhd_lib.h"
@@ -116,6 +117,13 @@ struct TALER_EXCHANGEDB_Plugin *TEH_plugin;
  */
 static unsigned int connection_timeout = 30;
 
+/**
+ * How many threads to use.
+ * The default value (0) sets the actual number of threads
+ * based on the number of available cores.
+ */
+static unsigned int num_threads = 0;
+
 /**
  * The HTTP Daemon.
  */
@@ -1137,6 +1145,8 @@ run_main_loop (int fh,
 {
   int ret;
 
+  GNUNET_assert (0 < num_threads);
+
   mhd
     = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN
                         | MHD_USE_DEBUG | MHD_USE_DUAL_STACK
@@ -1145,7 +1155,7 @@ run_main_loop (int fh,
                         (-1 == fh) ? serve_port : 0,
                         NULL, NULL,
                         &handle_mhd_request, NULL,
-                        MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) 4,
+                        MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) 
num_threads,
                         MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 1024,
                         MHD_OPTION_LISTEN_SOCKET, fh,
                         MHD_OPTION_EXTERNAL_LOGGER, &TALER_MHD_handle_logs,
@@ -1267,6 +1277,11 @@ main (int argc,
                                &connection_timeout),
     GNUNET_GETOPT_option_timetravel ('T',
                                      "timetravel"),
+    GNUNET_GETOPT_option_uint ('n',
+                               "num-threads",
+                               "NUM_THREADS",
+                               "size of the thread pool",
+                               &num_threads),
 #if HAVE_DEVELOPER
     GNUNET_GETOPT_option_filename ('f',
                                    "file-input",
@@ -1292,6 +1307,15 @@ main (int argc,
                          options,
                          argc, argv))
     return 1;
+  if (0 == num_threads)
+  {
+    cpu_set_t mask;
+    GNUNET_assert (0 ==
+                   sched_getaffinity (0,
+                                      sizeof (cpu_set_t),
+                                      &mask));
+    num_threads = CPU_COUNT (&mask);
+  }
   go = TALER_MHD_GO_NONE;
   if (connection_close)
     go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]