Skip to content

Commit 930e6b6

Browse files
vladargatsbybot
and
gatsbybot
authored
perf(gatsby-plugin-sharp): change approach to concurrency for image processing (#28575)
Co-authored-by: gatsbybot <[email protected]>
1 parent f11adbb commit 930e6b6

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

packages/gatsby-plugin-sharp/src/gatsby-worker.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require(`path`)
22
const queue = require(`async/queue`)
3+
const { cpuCoreCount } = require(`gatsby-core-utils`)
34
const { processFile } = require(`./process-file`)
45

56
exports.IMAGE_PROCESSING_JOB_NAME = `IMAGE_PROCESSING`
@@ -31,7 +32,7 @@ const q = queue(
3132
args.pluginOptions
3233
)
3334
),
34-
1
35+
cpuCoreCount()
3536
)
3637

3738
/**

packages/gatsby-plugin-sharp/src/process-file.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ const imageminMozjpeg = require(`imagemin-mozjpeg`)
88
const imageminPngquant = require(`imagemin-pngquant`)
99
const { healOptions } = require(`./plugin-options`)
1010
const { SharpError } = require(`./sharp-error`)
11-
const { cpuCoreCount, createContentDigest } = require(`gatsby-core-utils`)
11+
const { createContentDigest } = require(`gatsby-core-utils`)
1212

1313
// Try to enable the use of SIMD instructions. Seems to provide a smallish
1414
// speedup on resizing heavy loads (~10%). Sharp disables this feature by
1515
// default as there's been problems with segfaulting in the past but we'll be
1616
// adventurous and see what happens with it on.
1717
sharp.simd(true)
1818

19-
// Handle Sharp's concurrency based on the Gatsby CPU count
20-
// See: http://sharp.pixelplumbing.com/en/stable/api-utility/#concurrency
21-
// See: https://www.gatsbyjs.org/docs/multi-core-builds/
22-
sharp.concurrency(cpuCoreCount())
19+
// Concurrency is handled in gatsby-worker queue instead
20+
sharp.concurrency(1)
2321

2422
/**
2523
* @typedef DuotoneArgs

0 commit comments

Comments
 (0)