diff --git a/Dockerfile b/Dockerfile index e286f96b645..daf7b4807e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,26 @@ FROM buildpack-deps:bionic +ARG DEBIAN_FRONTEND=noninteractive +# WARNING: DON'T PUT A SPACE AFTER ANY BACKSLASH OR APT WILL BREAK # One -q produces output suitable for logging (mostly hides # progress indicators) -RUN apt-get -yqq update +RUN apt-get -yqq update && apt-get -yqq install \ + -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ + cloc \ + dstat `# Collect resource usage statistics` \ + git-core \ + libmysqlclient-dev `# Needed for MySQL-python` \ + python-dev \ + python-pip \ + siege \ + software-properties-common -# WARNING: DONT PUT A SPACE AFTER ANY BACKSLASH OR APT WILL BREAK -RUN apt-get -yqq install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ - git-core \ - cloc dstat `# Collect resource usage statistics` \ - python-dev \ - python-pip \ - software-properties-common \ - libmysqlclient-dev `# Needed for MySQL-python` - -RUN pip install colorama==0.3.1 requests MySQL-python psycopg2-binary pymongo docker==4.0.2 psutil - -RUN apt-get install -yqq siege +RUN pip install colorama==0.3.1 docker==4.0.2 MySQL-python psutil psycopg2-binary pymongo requests # Fix for docker-py trying to import one package from the wrong location -RUN cp -r /usr/local/lib/python2.7/dist-packages/backports/ssl_match_hostname/ /usr/lib/python2.7/dist-packages/backports +RUN cp -r /usr/local/lib/python2.7/dist-packages/backports/ssl_match_hostname /usr/lib/python2.7/dist-packages/backports -ENV PYTHONPATH /FrameworkBenchmarks -ENV FWROOT /FrameworkBenchmarks +ENV PYTHONPATH=/FrameworkBenchmarks +ENV FWROOT=/FrameworkBenchmarks ENTRYPOINT ["python", "/FrameworkBenchmarks/toolset/run-tests.py"] diff --git a/frameworks/C/h2o/README.md b/frameworks/C/h2o/README.md index d84c94d79ef..77ab5a515eb 100644 --- a/frameworks/C/h2o/README.md +++ b/frameworks/C/h2o/README.md @@ -17,9 +17,10 @@ The test implementations are located into the `src/handlers` directory - refer t ## Performance tuning If the test environment changes, it will probably be necessary to tune some of the framework -settings in order to achieve the best performance possible. The most significant parameter is -the maximum number of database connections per thread, which is controlled by the `DB_CONN` -variable in the `h2o.sh` script. +settings in order to achieve the best performance possible. The most significant parameters are the +maximum number of database connections per thread and the maximum number of pipelined database +queries per database connection, which are controlled by the `DB_CONN` and the `DB_PIPELINE` +variables respectively in the `h2o.sh` script. ## Performance issues diff --git a/frameworks/C/h2o/h2o.dockerfile b/frameworks/C/h2o/h2o.dockerfile index 0d1cafc3a9a..e133f98ead9 100644 --- a/frameworks/C/h2o/h2o.dockerfile +++ b/frameworks/C/h2o/h2o.dockerfile @@ -3,9 +3,9 @@ FROM ubuntu:22.04 WORKDIR /h2o_app_src COPY ./ ./ -ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && \ - apt-get install -yqq autoconf bison cmake curl file flex g++ git libnuma-dev libpq-dev \ +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get -yqq update && \ + apt-get -yqq install autoconf bison cmake curl file flex g++ git libnuma-dev libpq-dev \ libssl-dev libtool libyajl-dev libz-dev make ninja-build wget ### Install mustache-c @@ -13,7 +13,7 @@ RUN apt-get update && \ ARG MUSTACHE_C_REVISION=c1948c599edfe48c6099ed70ab1d5911d8c3ddc8 ARG MUSTACHE_C_BUILD_DIR=mustache-c-build -ENV MUSTACHE_C_PREFIX /opt/mustache-c +ENV MUSTACHE_C_PREFIX=/opt/mustache-c RUN mkdir -p "$MUSTACHE_C_BUILD_DIR" && \ cd "$MUSTACHE_C_BUILD_DIR" && \ @@ -29,7 +29,7 @@ RUN mkdir -p "$MUSTACHE_C_BUILD_DIR" && \ ARG H2O_VERSION=v2.2.6 ARG H2O_BUILD_DIR=h2o-build -ENV H2O_PREFIX /opt/h2o +ENV H2O_PREFIX=/opt/h2o RUN mkdir -p "${H2O_BUILD_DIR}/build" && \ cd "$H2O_BUILD_DIR" && \ diff --git a/frameworks/C/h2o/h2o.sh b/frameworks/C/h2o/h2o.sh index 581877553dd..a0b2c5976c3 100755 --- a/frameworks/C/h2o/h2o.sh +++ b/frameworks/C/h2o/h2o.sh @@ -25,9 +25,11 @@ if [[ -z "$MUSTACHE_C_PREFIX" ]]; then fi if [[ "$BENCHMARK_ENV" = "Azure" ]]; then - DB_CONN=2 + DB_CONN=1 + DB_PIPELINE=64 else DB_CONN=1 + DB_PIPELINE=64 fi build_h2o_app() @@ -49,7 +51,7 @@ run_curl() run_h2o_app() { LD_LIBRARY_PATH="${MUSTACHE_C_PREFIX}/lib:$LD_LIBRARY_PATH" \ - taskset -c "$1" "$2/h2o_app" -a20 -e32 -f "$3/template" -m "$DB_CONN" "$4" "$5" \ + taskset -c "$1" "$2/h2o_app" -a20 -e "$DB_PIPELINE" -f "$3/template" -m "$DB_CONN" "$4" "$5" \ -d "host=$DBHOST dbname=hello_world user=benchmarkdbuser sslmode=disable \ password=benchmarkdbpass" & } @@ -81,5 +83,6 @@ popd rm -rf "$H2O_APP_BUILD_DIR" echo "Running h2o_app in the $BENCHMARK_ENV environment." echo "Maximum database connections per thread: $DB_CONN" +echo "Maximum pipelined database queries per database connection: $DB_PIPELINE" run_h2o_app 0 "${H2O_APP_PREFIX}/bin" "${H2O_APP_PREFIX}/share/h2o_app" wait diff --git a/frameworks/C/h2o/src/database.c b/frameworks/C/h2o/src/database.c index fa48f3d091c..0fdfb995d2b 100644 --- a/frameworks/C/h2o/src/database.c +++ b/frameworks/C/h2o/src/database.c @@ -186,12 +186,14 @@ static void error_notification(db_conn_pool_t *pool, bool timeout, const char *e static void on_database_connect_error(db_conn_t *conn, bool timeout, const char *error_string) { - error_notification(conn->pool, timeout, error_string); + db_conn_pool_t * const pool = conn->pool; + h2o_timeout_unlink(&conn->timeout); h2o_socket_read_stop(conn->sock); h2o_socket_close(conn->sock); PQfinish(conn->conn); free(conn); + error_notification(pool, timeout, error_string); } static void on_database_connect_read_ready(h2o_socket_t *sock, const char *err) @@ -409,12 +411,10 @@ static void on_database_write_ready(h2o_socket_t *sock, const char *err) LIBRARY_ERROR("PQflush", PQerrorMessage(conn->conn)); on_database_error(conn, DB_ERROR); } - else { - if (send_status) - h2o_socket_notify_write(conn->sock, on_database_write_ready); - + else if (send_status) + h2o_socket_notify_write(conn->sock, on_database_write_ready); + else process_queries(conn); - } } } diff --git a/frameworks/C/h2o/src/handlers/fortune.c b/frameworks/C/h2o/src/handlers/fortune.c index 568941d1748..71a7ed09bfa 100644 --- a/frameworks/C/h2o/src/handlers/fortune.c +++ b/frameworks/C/h2o/src/handlers/fortune.c @@ -41,7 +41,7 @@ #define FORTUNE_TABLE_NAME "Fortune" #define FORTUNE_QUERY "SELECT * FROM " FORTUNE_TABLE_NAME ";" #define ID_FIELD_NAME "id" -#define MAX_IOVEC 64 +#define MAX_IOVEC 128 #define MESSAGE_FIELD_NAME "message" #define NEW_FORTUNE_ID "0" #define NEW_FORTUNE_MESSAGE "Additional fortune added at request time." diff --git a/frameworks/C/h2o/src/main.c b/frameworks/C/h2o/src/main.c index 4533fd3bc4a..80bce2c99c3 100644 --- a/frameworks/C/h2o/src/main.c +++ b/frameworks/C/h2o/src/main.c @@ -46,7 +46,7 @@ "[-b ] " \ "[-c ] " \ "[-d ] " \ - "[-e ] " \ + "[-e ] " \ "[-f