You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
All.
What operating system and processor architecture are you using (go env)?
OpenBSD 6.4 and later.
What did you do?
By default, OpenBSD has hw.smt=0 (hyperthreading disabled) which causes hw.ncpu to be twice as high as the actual CPUs running, hw.cpuonline. Go tries to schedule this many threads and they end up fighting each other.
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. But at least it's less wrong.
(This sysctl was added in 6.4.)
Apologies for pasted patch. I think it conveys the idea. I'm not sure how you want to handle backwards compatibility.
--- 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
The text was updated successfully, but these errors were encountered:
mikioh
changed the title
go uses too many CPUs on OpenBSD
runtime: go uses too many CPUs on OpenBSD
Feb 8, 2019
As far as I can see, the function hw_sysctl in sys/kern/kern_sysctl.c returns an error for unknown state. It`s fine to test the kernel states one after another, HW_NCPUONLINE then HW_NCPU.
tklauser
added
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
NeedsFix
The path to resolution is known, but the work has not been done.
and removed
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
labels
Feb 8, 2019
What version of Go are you using (
go version
)?1.11
Does this issue reproduce with the latest release?
All.
What operating system and processor architecture are you using (
go env
)?OpenBSD 6.4 and later.
What did you do?
By default, OpenBSD has hw.smt=0 (hyperthreading disabled) which causes hw.ncpu to be twice as high as the actual CPUs running, hw.cpuonline. Go tries to schedule this many threads and they end up fighting each other.
See also: https://marc.info/?l=openbsd-ports&m=154960265529993&w=2
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. But at least it's less wrong.
(This sysctl was added in 6.4.)
Apologies for pasted patch. I think it conveys the idea. I'm not sure how you want to handle backwards compatibility.
The text was updated successfully, but these errors were encountered: