瀏覽代碼

update facil.io version (#4366)

facil.io version 0.7.0.beta7 is probably the last beta version before an 0.7.0 version release.

It includes changes to the hash map data structure, added security features, and numerous fixes, such as unaligned memory access fix for SipHash.

These changes could effect performance (some for the better and some might negatively impact performance in favor of security or memory consumption).
Bo 6 年之前
父節點
當前提交
85f5df99a4
共有 3 個文件被更改,包括 28 次插入22 次删除
  1. 23 18
      frameworks/C/facil.io/bench_app.c
  2. 3 2
      frameworks/C/facil.io/facil.io.dockerfile
  3. 2 2
      frameworks/C/facil.io/setup-common.sh

+ 23 - 18
frameworks/C/facil.io/bench_app.c

@@ -116,21 +116,26 @@ CLI
 
 /* initialize CLI helper and manage it's default options */
 static void cli_init(int argc, char const *argv[]) {
-  fio_cli_start(
-      argc, argv, 0, 0,
-      "This is a facil.io framework benchmark application.\n"
-      "\nFor details about the benchmarks visit:\n"
-      "http://frameworkbenchmarks.readthedocs.io/en/latest/\n"
-      "\nThe following arguments are supported:",
-      "-threads -t The number of threads to use. System dependent default.",
-      FIO_CLI_TYPE_INT,
-      "-workers -w The number of processes to use. System dependent default.",
-      FIO_CLI_TYPE_INT,
-      "-port -p The port number to listen to (set to 0 for Unix Sockets.",
-      FIO_CLI_TYPE_INT, "-address -b The address to bind to.",
-      "-public -www A public folder for serve an HTTP static file service.",
-      "-log -v Turns logging on (logs to terminal).", FIO_CLI_TYPE_BOOL,
-      "-database -db The database adrress (URL).");
+  fio_cli_start(argc, argv, 0, 0,
+                "This is a facil.io framework benchmark application.\n"
+                "\nFor details about the benchmarks visit:\n"
+                "http://frameworkbenchmarks.readthedocs.io/en/latest/\n"
+                "\nThe following arguments are supported:",
+                FIO_CLI_PRINT_HEADER("Concurrency:"),
+                FIO_CLI_INT("-threads -t The number of threads to use. "
+                            "System dependent default."),
+                FIO_CLI_INT("-workers -w The number of processes to use. "
+                            "System dependent default."),
+                FIO_CLI_PRINT_HEADER("Address Binding:"),
+                FIO_CLI_INT("-port -p The port number to listen to "
+                            "(set to 0 for Unix Sockets."),
+                FIO_CLI_STRING("-address -b The address to bind to."),
+                FIO_CLI_PRINT_HEADER("HTTP Settings:"),
+                FIO_CLI_STRING("-public -www A public folder for serve an HTTP "
+                               "static file service."),
+                FIO_CLI_BOOL("-log -v Turns logging on (logs to terminal)."),
+                FIO_CLI_PRINT_HEADER("Misc:"),
+                FIO_CLI_STRING("-database -db The database adrress (URL)."));
 
   /* setup default port */
   if (!fio_cli_get("-p")) {
@@ -169,7 +174,8 @@ static fio_router_s routes;
 static void route_add(char *path, void (*handler)(http_s *)) {
   /* add handler to the hash map */
   fio_str_s tmp = FIO_STR_INIT_STATIC(path);
-  fio_router_insert(&routes, fio_str_hash(&tmp), tmp, handler, NULL);
+  /* fio hash maps support up to 96 full collisions, we can use len as hash */
+  fio_router_insert(&routes, fio_str_len(&tmp), tmp, handler, NULL);
 }
 
 /* routes a request to the correct handler */
@@ -179,8 +185,7 @@ static void route_perform(http_s *h) {
   /* collect path from hash map */
   fio_str_info_s tmp_i = fiobj_obj2cstr(h->path);
   fio_str_s tmp = FIO_STR_INIT_EXISTING(tmp_i.data, tmp_i.len, 0);
-  fio_router_handler_fn handler =
-      fio_router_find(&routes, fio_str_hash(&tmp), tmp);
+  fio_router_handler_fn handler = fio_router_find(&routes, tmp_i.len, tmp);
   /* forward request or send error */
   if (handler) {
     handler(h);

+ 3 - 2
frameworks/C/facil.io/facil.io.dockerfile

@@ -5,8 +5,9 @@ COPY ./ ./
 # using a common installation script will allow implementation variations (in future updates)
 RUN ./setup-common.sh
 
-# we don't need more than 32K concurrent connections
-ENV CFLAGS="-DFIO_MAX_SOCK_CAPACITY=65536"
+# 1. we don't need more than 32K concurrent connections
+# 2. facil.io hash maps are resistant to hash flooding, we can use a faster hashing function.
+ENV CFLAGS="-DFIO_MAX_SOCK_CAPACITY=65536 -DFIO_USE_RISKY_HASH=1"
 
 # compile test
 RUN cp -f bench_app.c facil_app/src/app.c

+ 2 - 2
frameworks/C/facil.io/setup-common.sh

@@ -17,8 +17,8 @@ if [[ (! -d facil_app) ||  (-n "${FIO_EDGE}") ]] ; then
 	# Setting FIO_EDGE will test against the master branch on the development machine. i.e.:
 	#     $ FIO_EDGE=1 tfb --mode verify --test facil.io
 	if [[ -z "${FIO_EDGE}" ]]; then
-		echo "INFO: loading facil.io version 0.7.0.beta3"
-	  FIO_URL="https://api.github.com/repos/boazsegev/facil.io/tarball/0.7.0.beta3"
+		echo "INFO: loading facil.io version 0.7.0.beta7"
+	  FIO_URL="https://api.github.com/repos/boazsegev/facil.io/tarball/0.7.0.beta7"
 	else
 		echo "INFO: development mode detected, loading facil.io from master."
 		FIO_URL="https://github.com/boazsegev/facil.io/archive/master.tar.gz"