{"record":{"id":"af3bc3cca159f34d","repo":"nodejs/node","slug":"cpu-cores-have-differing-governor-settings","errorCode":null,"errorMessage":"CPU cores have differing governor settings","messagePattern":"CPU cores have differing governor settings","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"deps/v8/tools/run_perf.py","lineNumber":1124,"sourceCode":"    ret = '/sys/devices/system/cpu/cpu'\n    ret += str(cpu_index)\n    ret += '/cpufreq/scaling_governor'\n    return ret\n\n  @staticmethod\n  def GetCPUGovernor():\n    try:\n      cpu_indices = CustomMachineConfiguration.GetCPUCoresRange()\n      ret = None\n      for cpu_index in cpu_indices:\n        cpu_device = CustomMachineConfiguration.GetCPUPathForId(cpu_index)\n        with open(cpu_device, 'r') as f:\n          # We assume the governors of all CPUs are set to the same value\n          val = f.readline().strip()\n          if ret is None:\n            ret = val\n          elif ret != val:\n            raise Exception('CPU cores have differing governor settings')\n      return ret\n    except Exception:\n      logging.exception('Failed to get the current CPU governor. Is the CPU '\n                        'governor disabled? Check BIOS.')\n      raise\n\n  @staticmethod\n  def SetCPUGovernor(value):\n    try:\n      cpu_indices = CustomMachineConfiguration.GetCPUCoresRange()\n      for cpu_index in cpu_indices:\n        cpu_device = CustomMachineConfiguration.GetCPUPathForId(cpu_index)\n        with open(cpu_device, 'w') as f:\n          f.write(value)\n\n    except Exception:\n      logging.exception('Failed to change CPU governor to %s. Are we '\n                        'running under sudo?', value)","sourceCodeStart":1106,"sourceCodeEnd":1142,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/v8/tools/run_perf.py#L1106-L1142","documentation":"Thrown by CustomMachineConfiguration.GetCPUGovernor in run_perf.py while reading the scaling governor of every CPU core: it assumes all cores share one governor setting, and if any core reports a different value it aborts. Consistent CPU frequency policy is required for benchmark determinism.","triggerScenarios":"Iterating cpu_indices from /sys/devices/system/cpu/present; reading each /sys/devices/system/cpu/cpuN/cpufreq/scaling_governor; the value on one core differs from the first core's value.","commonSituations":"Heterogeneous big.LITTLE or hybrid (P-core/E-core) systems where cores legitimately run different governors; a CPU hotplug/hotplug-offline event leaving a core on a default governor; a partially-applied cpupower/cpufreq-set that only changed some cores.","solutions":["Pin all cores to the same governor before running: sudo cpupower frequency-set -g performance (this sets it cluster-wide; verify each core).","On hybrid systems, either isolate the benchmark to a homogeneous cluster via taskset/cgroups or pre-set the governor on every cpuN individually in a loop.","Check for offline cores (ls /sys/devices/system/cpu/cpu*/online) and bring them online or exclude them so governor reads are consistent."],"exampleFix":"# before: mixed governors across cores\n# after: force one governor on every core\nfor c in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do\n  echo performance | sudo tee \"$c\"\ndone","handlingStrategy":"validation","validationCode":"def governors_consistent() -> bool:\n    import glob\n    vals = {open(f).read().strip() for f in glob.glob('/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor')}\n    return len(vals) == 1","typeGuard":"null","tryCatchPattern":"try:\n    gov = CustomMachineConfiguration.GetCPUGovernor()\nexcept Exception as e:\n    logging.warning('Inconsistent CPU governors (%s); pin all cores first.', e)","preventionTips":["Set the governor on every core before benchmarking: sudo cpupower frequency-set -g performance.","On hybrid systems, isolate the benchmark to one homogeneous cluster via taskset.","Bring offline cores online or exclude them so governor reads are uniform."],"tags":["v8","perf-test","cpu","governor","linux"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}