Skip to content

Commit 370bedb

Browse files
authored
Add option for number of threads used by build system (#8346)
* Add option for number of threads used by build system Attempt to fix #6907 * Add CPUTHREADS to replace USEALLTHREADS Defaults to 150% as was always the case, otherwise allow user to override number of threads.
1 parent 3a9babe commit 370bedb

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/functions/configuration/compilation-config.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ function prepare_compilation_vars() {
2424
# moved from config: this does not belong in configuration. it's a compilation thing.
2525
# optimize build time with 100% CPU usage
2626
CPUS=$(grep -c 'processor' /proc/cpuinfo)
27-
if [[ $USEALLCORES != no ]]; then
28-
CTHREADS="-j$((CPUS + CPUS / 2))"
29-
else
30-
CTHREADS="-j1"
27+
28+
# Default to 150% of CPUs to maximize compilation speed
29+
CTHREADS="-j$((CPUS + CPUS / 2))"
30+
31+
# If CPUTHREADS is defined and a valid positive integer allow user to override CTHREADS
32+
# This is useful for limiting Armbian build to a specific number of threads, e.g. for build servers
33+
if [[ "$CPUTHREADS" =~ ^[1-9][0-9]*$ ]]; then
34+
CTHREADS="-j$CPUTHREADS"
35+
echo "Using user-defined thread count: $CTHREADS"
3136
fi
3237

3338
call_extension_method "post_determine_cthreads" "config_post_determine_cthreads" <<- 'POST_DETERMINE_CTHREADS'

lib/functions/configuration/main-config.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ function do_main_configuration() {
9595
TZDATA="Etc/UTC" # If not /etc/timezone at host, default to UTC.
9696
fi
9797

98-
USEALLCORES=yes # Use all CPU cores for compiling
99-
10098
[[ -z $EXIT_PATCHING_ERROR ]] && EXIT_PATCHING_ERROR="" # exit patching if failed
10199
[[ -z $HOST ]] && HOST="$BOARD"
102100
cd "${SRC}" || exit

0 commit comments

Comments
 (0)