Record and use only the first Mhz from the CPU fingerprinter.

Assume all cores are the same speed.
This commit is contained in:
Sean Chittenden 2016-06-17 11:06:57 -07:00
parent faea8921d6
commit 686c125fea
No known key found for this signature in database
GPG Key ID: 4EBC9DC16C2E5E16
1 changed files with 4 additions and 11 deletions

View File

@ -28,22 +28,15 @@ func (f *CPUFingerprint) Fingerprint(cfg *config.Config, node *structs.Node) (bo
return false, err
}
// Assume all CPUs found have same Model and MHz. If cpu.Info()
// returns nil above, this loop is still safe.
var mhz float64
var modelName string
// Assume all CPUs found have same Model. Log if not. If cpu.Info()
// returns nil above, this loop is still safe. Don't assume all
// platforms return one entry in cpuInfo per core.
for _, c := range cpuInfo {
mhz += c.Mhz
if modelName != "" && modelName != c.ModelName {
f.logger.Println("[WARN] Found different model names in the same CPU information. Recording last found")
}
mhz = c.Mhz
modelName = c.ModelName
break
}
// Get average CPU frequency
mhz /= float64(len(cpuInfo))
// Allow for a little precision slop
if mhz < 1.0 {