Reduce default concurrency for musl thread over-subscription

https://github.com/lovell/sharp-libvips/issues/229
This commit is contained in:
Lovell Fuller 2024-04-30 19:14:13 +01:00
parent 93c615d39f
commit da655a1859
2 changed files with 5 additions and 0 deletions

View File

@ -8,6 +8,8 @@ Requires libvips v8.15.2
* Remove experimental status from `pipelineColourspace`. * Remove experimental status from `pipelineColourspace`.
* Reduce default concurrency when musl thread over-subscription detected.
* TypeScript: add missing definitions for `OverlayOptions`. * TypeScript: add missing definitions for `OverlayOptions`.
[#4048](https://github.com/lovell/sharp/pull/4048) [#4048](https://github.com/lovell/sharp/pull/4048)
[@ike-gg](https://github.com/ike-gg) [@ike-gg](https://github.com/ike-gg)

View File

@ -153,6 +153,9 @@ function concurrency (concurrency) {
if (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) { if (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) {
// Reduce default concurrency to 1 when using glibc memory allocator // Reduce default concurrency to 1 when using glibc memory allocator
sharp.concurrency(1); 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());
} }
/** /**