Go isn’t my favourit language, but I find it is interesting for some things. It comes with a tool for benchmarking. By default tool runs benchmarks in multiple threads, depending on number of available CPU cores (see here). This produces unpredictable results when testing small functions. There are few ways to control this behaviour and one of them is to set GOMAXPROCS environment variable to 1. It seems that also -test.cpu 1 option needs to be added to the command line.

Nevertheless, results that I’ve got by using GOMAXPROCS where fluctuating from run to run. Most stable results were produced when process has been bound to CPU. This can be done with taskset:

sudo taskset 2 ./sidh.test -test.v -test.bench="BenchmarkBobKeyGenPub" -test.run="^A" -test.cpu 1


In this case I’ve found out that CPU 1 was getting low number of IRQ’s on my system (is there a way to configure IRQ’s so that they are delivered to CPU 0?).

Before testing I’m changing the CPUs scaling governor to performance

echo "performance" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
echo 0 > /sys/devices/system/cpu/cpu2/online
echo 0 > /sys/devices/system/cpu/cpu3/online


TODO: * GODEBUGCPU (https://go-review.googlesource.com/c/go/+/91737) * benchmem * benchcmp

Resources: [1] Profiling with go [2] Benchmarking go programs