Go tries to use NCPU cpus. Unfortunately, half of them are turned off because
hw.smt=0 by default, and then go spends a lot of time fighting against itself.
The diff below, against go/src/runtime, changes to use the number of CPUs
online. It's possible for this number to change, and thus become stale, but
that's unlikely, and not the default.
(This sysctl was added in 6.4.)
--- os_openbsd.go.orig Fri Feb 8 00:02:27 2019
+++ os_openbsd.go Fri Feb 8 00:06:21 2019
@@ -85,8 +85,8 @@
_KERN_OSREV = 3
_CTL_HW = 6
- _HW_NCPU = 3
_HW_PAGESIZE = 7
+ _HW_NCPUONLINE = 25
)
func sysctlInt(mib []uint32) (int32, bool) {
@@ -101,7 +101,7 @@
func getncpu() int32 {
// Fetch hw.ncpu via sysctl.
- if ncpu, ok := sysctlInt([]uint32{_CTL_HW, _HW_NCPU}); ok {
+ if ncpu, ok := sysctlInt([]uint32{_CTL_HW, _HW_NCPUONLINE}); ok {
return int32(ncpu)
}
return 1