Skip to content

Commit c9d5943

Browse files
committed
Cap parallel example builds at 4
Unbounded nproc can overwhelm machines with many cores. Cap at 4 to keep resource usage reasonable while still getting parallelism benefits. Extract the capped value into a PARALLEL variable for readability.
1 parent 3d3935f commit c9d5943

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ EXAMPLES_SOURCE_FILES := $(shell find $(EXAMPLES_DIR) -name "*.pony")
4343
EXAMPLES_BINARIES := $(addprefix $(BUILD_DIR)/,$(EXAMPLES))
4444

4545
mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
46+
PARALLEL := $(shell n=$$(nproc); echo $$(( n < 4 ? n : 4 )))
4647

4748
test: unit-tests build-examples
4849

@@ -55,7 +56,7 @@ $(tests_binary): $(SOURCE_FILES) | $(BUILD_DIR)
5556

5657
build-examples:
5758
$(GET_DEPENDENCIES_WITH)
58-
@$(MAKE) -j$(shell nproc) _build_examples GET_DEPENDENCIES_WITH=true
59+
@$(MAKE) -j$(PARALLEL) _build_examples GET_DEPENDENCIES_WITH=true
5960

6061
_build_examples: $(EXAMPLES_BINARIES)
6162

0 commit comments

Comments
 (0)