diff --git a/docs/changelog.md b/docs/changelog.md index 1b07a15b2..2df84e5cb 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -8,6 +8,8 @@ Requires libvips v8.15.2 * Remove experimental status from `pipelineColourspace`. +* Reduce default concurrency when musl thread over-subscription detected. + * TypeScript: add missing definitions for `OverlayOptions`. [#4048](https://github.com/lovell/sharp/pull/4048) [@ike-gg](https://github.com/ike-gg) diff --git a/lib/utility.js b/lib/utility.js index 3af1b69ac..32738a635 100644 --- a/lib/utility.js +++ b/lib/utility.js @@ -153,6 +153,9 @@ function concurrency (concurrency) { if (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) { // Reduce default concurrency to 1 when using glibc memory allocator sharp.concurrency(1); +} else if (detectLibc.familySync() === detectLibc.MUSL && sharp.concurrency() === 1024) { + // Reduce default concurrency when musl thread over-subscription detected + sharp.concurrency(require('node:os').availableParallelism()); } /**