Skip to content

Commit

Permalink
Respect Linux cgroup CPU number for --threads value (#2083)
Browse files Browse the repository at this point in the history
We want to respect cgroup constraints so that when we run in a container, we respect the limits set for the container rather than use the host OS's number of cores.

We check both `/sys/fs/cgroup/cpuset.cpus.effective` (`cgroup v2`) and `/sys/fs/cgroup/cpuset.cpus` (`cgroup v1`) to find the number of cores available. We also check `sys/fs/cgroup/cpu.max` (v1, v2) to calculate the number of cores from the limits set in this file.

The max threads value is set to the minimum of these values, and if no values were found in these files, we default to the original value of the host OS.
  • Loading branch information
angelapwen committed Jan 23, 2024
1 parent 2eaf014 commit 65c7496
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -6,7 +6,7 @@ Note that the only difference between `v2` and `v3` of the CodeQL Action is the

## [UNRELEASED]

No user facing changes.
- On Linux, the maximum possible value for the `--threads` option now respects the CPU count as specified in `cgroup` files to more accurately reflect the number of available cores when running in containers.

## 3.23.1 - 17 Jan 2024

Expand Down
63 changes: 62 additions & 1 deletion lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 65c7496

Please sign in to comment.