Skip to content

Commit

Permalink
Reduce default concurrency for musl thread over-subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Apr 30, 2024
1 parent 93c615d commit da655a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand Down

0 comments on commit da655a1

Please sign in to comment.