Skip to content

Use all available CPUs in CI instead of a fixed -j3 - #938

Merged
NWilson merged 6 commits into
PCRE2Project:mainfrom
mattst88:ci-nproc
Aug 9, 2026
Merged

Use all available CPUs in CI instead of a fixed -j3#938
NWilson merged 6 commits into
PCRE2Project:mainfrom
mattst88:ci-nproc

Conversation

@mattst88

@mattst88 mattst88 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Every CI job hard-codes -j3 for make and ctest. GitHub's hosted Linux runners currently have four CPUs, and larger or self-hosted runners have more, so this leaves capacity unused.

There is no portable way to ask for the CPU count, so each platform gets the spelling it supports:

Platform Expression
Linux hosts, containers, MSYS2, run-on-arch $(nproc)
macOS $(sysctl -n hw.ncpu)
FreeBSD, OpenBSD NPROC=sysctl -n hw.ncpu`` once per VM script
Solaris NPROC=getconf NPROCESSORS_ONLN``
Windows (PowerShell) -j $env:NUMBER_OF_PROCESSORS

On the BSDs and Solaris the count is computed once at the top of the VM script and reused, rather than repeating the command at each call site.

One commit per platform, so the unusual ones can be reviewed or dropped individually.

No functional change: the same jobs run the same builds and tests.

Two things deliberately left alone:

  • The z/OS ctest -j3. I don't know whether nproc exists in the zopen environment, and that line has a pre-existing syntax error (--output-on-failure; &&) which I've included a patch to fix
  • The Solaris compilation steps, which were already serial and stay that way. Only its ctest changes.

GitHub's hosted Linux runners currently have four CPUs, and larger or
self-hosted runners have more, so -j3 leaves capacity unused. Use
$(nproc) instead of a fixed number.

This covers the jobs which run on Linux hosts or in Linux containers,
where nproc is available. The other platforms are handled separately.
macOS has no nproc, so query the CPU count with sysctl instead.
The BSDs have no nproc. Query the CPU count once with sysctl at the top
of each VM script and reuse it, rather than repeating the command at
every call site.
Solaris has neither nproc nor sysctl -n hw.ncpu, but getconf reports the
number of online processors. The compilation steps are left serial, as
they were before.
These steps run under PowerShell, so take the CPU count from
NUMBER_OF_PROCESSORS rather than from a shell command.
A stray semicolon before && makes the line unparseable. The whole remote
script is a single argument to "bash -c", which is parsed before
anything is executed, so this stops the entire job rather than just that
line: neither the autoconf nor the CMake build ever starts.

The job only runs on workflow_dispatch, which is presumably why this has
gone unnoticed.
@NWilson

NWilson commented Aug 9, 2026

Copy link
Copy Markdown
Member

Thank you! These changes are a nice maintenance improvement.

@NWilson
NWilson merged commit 9bf43da into PCRE2Project:main Aug 9, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants