git » gofer » commit a5ec3c0

test/perf: Adjust parameters for more consistent results

author Alberto Bertogli
2022-09-25 00:23:03 UTC
committer Alberto Bertogli
2022-10-07 10:59:43 UTC
parent 68843b78b9abd7895f14d58deefbd5eb794cc0ab

test/perf: Adjust parameters for more consistent results

The performance tests are useful to get a general sense of performance
in comparison with nginx, but they're meant to run on a single machine,
which can make them very noisy, especially on machines with few CPUs.

This patch does some minor adjustments to them, to make results more
consistent and less dependent on kernel scheduling decisions and
processor layout.

As a downside, the results become less representative in the total
requests per second, and won't highlight concurrency-related
bottlenecks. But it makes the tests much more useful for profiling and
catching large regressions.

The changes are:

- Run wrk with 1 thread, 1 request at a time. This improves consistency
  of measurement and drastically reduces measurement noise due to kernel
  decisions on machines with few CPUs.
- Enable sendfile on nginx, which gives it a significant latency
  improvement on large files.
- Cap Go runtime to 2 CPUs. This is to match nginx config, which also
  limits it to 2 CPUs.

test/perf/nginx.conf +2 -3
test/perf/perf.sh +2 -2

diff --git a/test/perf/nginx.conf b/test/perf/nginx.conf
index 0579284..ea64d42 100644
--- a/test/perf/nginx.conf
+++ b/test/perf/nginx.conf
@@ -17,9 +17,10 @@ http {
 	include       /etc/nginx/mime.types;
 	charset       utf-8;
 
-	# access_log    .logs/access.log  combined;
 	access_log off;
 
+	sendfile on;
+
 	server {
 		server_name   localhost;
 		listen        127.0.0.1:8077;
@@ -27,7 +28,5 @@ http {
 		location      / {
 			root      testdata/dir;
 		}
-
 	}
-
 }
diff --git a/test/perf/perf.sh b/test/perf/perf.sh
index 31d30c9..e887eb3 100755
--- a/test/perf/perf.sh
+++ b/test/perf/perf.sh
@@ -13,14 +13,14 @@ function nginx_bg() {
 export DURATION=${DURATION:-5s}
 
 function runwrk() {
-	wrk -d $DURATION -s perf/report.lua "$@"
+	wrk -t 1 -c 1 -d $DURATION -s perf/report.lua "$@"
 }
 
 echo "## Performance"
 
 echo "### Setup"
 
-gofer_bg -logfile=.perf.log -configfile=perf/gofer.yaml
+GOMAXPROCS=2 gofer_bg -logfile=.perf.log -configfile=perf/gofer.yaml
 GOFER_PID=$PID
 wait_until_ready 8450