Skip to content

[librespot] Cap build parallelism to RAM and raise the rustc thread stack - #28

Merged
moodeaudio merged 2 commits into
moode-player:mainfrom
Gjuju:feat/rebuilder-cargo-check
Sep 9, 2026
Merged

moodeaudio merged 2 commits into
moode-player:mainfrom
Gjuju:feat/rebuilder-cargo-check

Conversation

@Gjuju

@Gjuju Gjuju commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Two independent failures on the on-demand librespot build, one fix each.
Measured on Pi 3B, 3B+, 3A+, Zero 2 W, Pi 4 and Pi 5, all rustc 1.96.0.

Both are plain environment variables, set in packages/librespot/build.sh
before rbl_check_cargo so they also cover the cargo install cargo-deb it
may trigger, itself a build of some 200 crates.

Jobs

cargo defaults to one rustc per core. On a 1 GB Pi 3B that stacks four rustc
and drives the board into SD thrash. Budget 512 MB per parallel rustc, clamped
to [1, nproc], so 2 GB and up keeps today's default; an explicit
CARGO_BUILD_JOBS still wins. One board, one variable:

jobs time written to card
1 53m10 1931 MB
2 39m42 3635 MB
3 39m26 4705 MB

Two is the knee — a third job saves 16 s and writes 29% more.

Stack

On aarch64 a codegen worker thread can overflow its stack and take rustc down
with SIGSEGV inside LLVM while compiling librespot-protocol. It is not the
OOM killer and not governed by the job count, so it strikes at random.
RUST_MIN_STACK=16777216 is the remedy rustc's own diagnostic suggests, and it
costs no measurable time: the same board run twice, once each way, gave 21m19
against 21m16 on a Pi 4 and 7m13 against 7m12 on a Pi 5.

Together they bring back builds that had stopped completing: a Pi 3A+ and a
Zero 2 W (512 MB) finish at one job, and a 1 GB Pi 3B+ that had failed several
attempts finished the same way. Not a guarantee — one 512 MB board has still
failed with both applied.

@Gjuju
Gjuju force-pushed the feat/rebuilder-cargo-check branch 2 times, most recently from d402d46 to 63329a0 Compare August 5, 2026 08:49
@Gjuju
Gjuju force-pushed the feat/rebuilder-cargo-check branch 2 times, most recently from e7008c1 to 9498f0c Compare August 14, 2026 16:22
@Gjuju
Gjuju force-pushed the feat/rebuilder-cargo-check branch from 9498f0c to 47051ea Compare August 25, 2026 08:28
@Gjuju
Gjuju force-pushed the feat/rebuilder-cargo-check branch 2 times, most recently from 9754a28 to cd528de Compare September 2, 2026 12:42
@Gjuju Gjuju changed the title [rebuilder.lib.sh] Fix the cargo toolchain check, and cap librespot's build parallelism [librespot] Cap build parallelism to RAM and raise the rustc thread stack Sep 2, 2026
@Gjuju
Gjuju force-pushed the feat/rebuilder-cargo-check branch from cd528de to dc8ef7d Compare September 8, 2026 07:45
cargo defaults to one rustc per core. On a 4-core 512 MB Pi (3A+, Zero 2 W)
that stacks four rustc and drives the board into swap thrash. Budget 512 MB
per parallel rustc, clamped to [1, nproc], so boards with 2 GB and up keep
the current default. An explicit CARGO_BUILD_JOBS still wins.
On aarch64 a codegen worker thread can overflow its 8 MiB stack and take rustc
down with SIGSEGV inside LLVM while compiling librespot-protocol, whose
generated functions are very large. It is not the OOM killer and not governed
by the job count, so it strikes at random. 16 MiB is the remedy rustc's own
diagnostic names, and it costs no measurable time: same board twice, 21m19 vs
21m16 on a Pi 4 and 7m13 vs 7m12 on a Pi 5.
@Gjuju
Gjuju force-pushed the feat/rebuilder-cargo-check branch from dc8ef7d to 1c6d071 Compare September 9, 2026 17:45
@moodeaudio
moodeaudio merged commit 7b02abb into moode-player:main Sep 9, 2026
@Gjuju
Gjuju deleted the feat/rebuilder-cargo-check branch September 12, 2026 06:47
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