소스 검색

H2O: Use unlimited number of pipelined database queries (#8713)

Also, update libpq to revision a37bb7c13.
Anton Kirilov 1 년 전
부모
커밋
a0bc288d4a
3개의 변경된 파일14개의 추가작업 그리고 10개의 파일을 삭제
  1. 1 5
      frameworks/C/h2o/h2o.dockerfile
  2. 11 3
      frameworks/C/h2o/src/handlers/world.c
  3. 2 2
      frameworks/C/h2o/src/main.c

+ 1 - 5
frameworks/C/h2o/h2o.dockerfile

@@ -26,7 +26,6 @@ RUN apt-get -yqq update && \
       libz-dev \
       make \
       ninja-build \
-      patch \
       pkg-config \
       systemtap-sdt-dev
 
@@ -54,13 +53,11 @@ RUN curl -LSs "https://github.com/x86-64/mustache-c/archive/${MUSTACHE_C_REVISIO
     CFLAGS="-flto -march=native -mtune=native -O3" ./autogen.sh && \
     make -j "$(nproc)" install
 
-ARG POSTGRESQL_VERSION=c1ec02be1d79eac95160dea7ced32ace84664617
+ARG POSTGRESQL_VERSION=a37bb7c13995b834095d9d064cad1023a6f99b10
 
 WORKDIR /tmp/postgresql-build
 RUN curl -LSs "https://github.com/postgres/postgres/archive/${POSTGRESQL_VERSION}.tar.gz" | \
       tar --strip-components=1 -xz && \
-    curl -LSs "https://www.postgresql.org/message-id/attachment/152078/v5-0001-Add-PQsendPipelineSync-to-libpq.patch" | \
-      patch -Np1 && \
     CFLAGS="-flto -march=native -mtune=native -O3" ./configure \
       --includedir=/usr/local/include/postgresql \
       --prefix=/usr/local \
@@ -106,7 +103,6 @@ CMD ["taskset", \
      "-a20", \
      "-d", \
      "dbname=hello_world host=tfb-database password=benchmarkdbpass sslmode=disable user=benchmarkdbuser", \
-     "-e256", \
      "-f", \
      "/opt/h2o_app/share/h2o_app/template", \
      "-m1"]

+ 11 - 3
frameworks/C/h2o/src/handlers/world.c

@@ -238,7 +238,7 @@ static int do_multiple_queries(bool do_update, bool use_cache, h2o_req_t *req)
 
 	// MAX_QUERIES is a relatively small number, so assume no overflow in the following
 	// arithmetic operations.
-	assert(num_query <= MAX_QUERIES);
+	assert(num_query && num_query <= MAX_QUERIES);
 
 	size_t base_size = offsetof(multiple_query_ctx_t, res) + num_query * sizeof(query_result_t);
 
@@ -246,8 +246,16 @@ static int do_multiple_queries(bool do_update, bool use_cache, h2o_req_t *req)
 	base_size = base_size * _Alignof(query_param_t);
 
 	const config_t * const config = ctx->global_thread_data->config;
-	const size_t num_query_in_progress =
-		MIN(num_query, config->max_db_conn_num * config->max_pipeline_query_num);
+	size_t num_query_in_progress = config->max_db_conn_num * config->max_pipeline_query_num;
+
+	if (num_query_in_progress < config->max_db_conn_num ||
+	    num_query_in_progress < config->max_pipeline_query_num)
+		num_query_in_progress = num_query;
+	else
+		num_query_in_progress = MIN(num_query, num_query_in_progress);
+
+	assert(num_query_in_progress);
+
 	size_t sz = base_size + num_query_in_progress * sizeof(query_param_t);
 
 	if (do_update) {

+ 2 - 2
frameworks/C/h2o/src/main.c

@@ -176,10 +176,10 @@ static int parse_options(int argc, char *argv[], config_t *config)
 	do { \
 		errno = 0; \
 		\
-		const long long n = strtoll(optarg, NULL, 10); \
+		const long n = strtol(optarg, NULL, 10); \
 		\
 		if (errno) { \
-			print_library_error(__FILE__, __LINE__, "strtoll", errno); \
+			print_library_error(__FILE__, __LINE__, "strtol", errno); \
 			return 1; \
 		} \
 		\