Skip to content

Make the SDK build parallelism configurable - #293

Open
artem-from-ua wants to merge 2 commits into
jamesyc:mainfrom
artem-from-ua:feature/parallel-sdk-build
Open

Make the SDK build parallelism configurable#293
artem-from-ua wants to merge 2 commits into
jamesyc:mainfrom
artem-from-ua:feature/parallel-sdk-build

Conversation

@artem-from-ua

Copy link
Copy Markdown

Neither build.sh tools nor build.sh distribution was ever passed a -j, so the SDK builds one job at a time no matter how many cores the host has. On a four-core guest the distribution phase takes over an hour at a load average of about 1.

This adds SDK_JOBS, passed through to build.sh -j, defaulting to 1 so behaviour is unchanged unless the caller opts in:

SDK_JOBS=4 ./build/bootstrap.sh distribution

build.sh turns -j N into parallel="-j N" and hands it to make, so this is the interface NetBSD already expects.

Samba needs no change — SAMBA4X_JOBS was already overridable from the environment. The two knobs are now symmetric and independent: SDK_JOBS for the cross toolchain and sysroot, SAMBA4X_JOBS for Samba and its GnuTLS dependency chain.

Measured

Two full runs from a pristine NetBSD 10.1/aarch64 image under QEMU with hvf acceleration, -smp 4, 4 GB RAM, on an Apple M1 Pro. Same image, same mirrors, nothing preinstalled in either — the bare starting point was asserted rather than assumed.

Stage SDK_JOBS=1, SAMBA4X_JOBS=2 SDK_JOBS=4, SAMBA4X_JOBS=4 speedup
bootstrap.sh tools 9m48s 5m37s 1.75x
bootstrap.sh distribution 66m17s 22m41s 2.9x
samba4x.sh 7m23s 4m30s 1.6x
build total ~83m ~33m 2.5x

Source download is excluded from both columns: git clone is single-threaded either way and varies with the network, so it says nothing about parallelism.

Parallelism was confirmed at runtime rather than inferred from the flag — 2-3 concurrent cc1 and 6-7 nbmake during the distribution phase, at a load average of 3.13 against roughly 1.0 serially.

The samba4x.sh row moves because SAMBA4X_JOBS differs between the two runs, not because of anything this change does.

Why the default stays at 1

Parallel NetBSD builds have historically been racy on some subtrees. Both phases completed cleanly at -j4 across several runs here, but that is evidence, not proof — and the caller knows their host better than the script does. Anyone on a host where a parallel build misbehaves simply does not set the variable.

The SDK was built strictly serially: neither `build.sh tools` nor
`build.sh distribution` was ever given a `-j`, so both ran one job at a
time regardless of how many cores the build host had. On a four-core
NetBSD guest the `distribution` phase took 63 minutes at a load average
of about 1.

Pass `-j "$SDK_JOBS"` to both phases and default `SDK_JOBS` to 1, so the
serial behaviour is unchanged unless the caller asks for more:

    SDK_JOBS=4 ./build/bootstrap.sh distribution

`build.sh` turns `-j N` into `parallel="-j N"` and hands it to make, so
this is the interface NetBSD already expects for this.

Samba needed no change: `SAMBA4X_JOBS` (default 2, via `SAMBA4_JOBS`)
was already overridable from the environment. The two knobs are now
symmetric and independent — `SDK_JOBS` for the cross toolchain and
sysroot, `SAMBA4X_JOBS` for Samba and its GnuTLS dependency chain.

Nothing here picks a value automatically. Parallel NetBSD builds have
historically been racy on some subtrees, so raising the default is left
to the caller, who knows the host.
@artem-from-ua
artem-from-ua marked this pull request as ready for review August 31, 2026 01:53
@jamesyc

jamesyc commented Sep 3, 2026

Copy link
Copy Markdown
Owner

'SDK_JOBS' defaulting to 1 means this now always passes '-j 1'. NetBSD make documents say that any '-j' enables jobs mode and disables compatibility mode, changing target commands from separate shells to one shell.

This is not behavior-preserving and may break previously working makefiles, especially in the NetBSD 4 lanes, which I'm not going to fully audit. Leave 'SDK_JOBS' unset by default and add '-j' only when explicitly configured.

@artem-from-ua
artem-from-ua marked this pull request as draft September 3, 2026 12:34
The previous version defaulted SDK_JOBS to 1, which meant build.sh was
always given -j 1. That is not behavior-preserving: any -j turns off
make(1) compatibility mode, and the whole script for a target is then fed
to a single shell instead of one shell per line.

SDK_JOBS is now unset by default and the flag is built conditionally, so
an unset SDK_JOBS reproduces the original invocation exactly. Confirmed
against the real tree with build.sh -n:

    SDK_JOBS unset -> nbmake-evbarm obj-tools
    SDK_JOBS=4     -> nbmake-evbarm -j 4 obj-tools

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@artem-from-ua
artem-from-ua marked this pull request as ready for review September 3, 2026 12:55
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