diff --git a/src/utils/configuration/index.mjs b/src/utils/configuration/index.mjs index fd3d210d..acedda6c 100644 --- a/src/utils/configuration/index.mjs +++ b/src/utils/configuration/index.mjs @@ -5,6 +5,7 @@ import { coerce } from 'semver'; import { CHANGELOG_URL, populate } from './templates.mjs'; import { allGenerators } from '../../generators/index.mjs'; +import logger from '../../logger/index.mjs'; import { parseChangelog, parseIndex } from '../../parsers/markdown.mjs'; import { enforceArray } from '../array.mjs'; import { leftHandAssign } from '../generators.mjs'; @@ -33,7 +34,11 @@ export const getDefaultConfig = lazy(() => }), }, - threads: cpus().length, + // The number of wasm memory instances is severely limited on + // riscv64 with sv39. Running multiple generators that use wasm in + // parallel could cause failures to allocate new wasm instance. + // See also https://github.com/nodejs/node/pull/60591 + threads: process.arch === 'riscv64' ? 1 : cpus().length, chunkSize: 10, }) ) @@ -121,6 +126,14 @@ export const createRunConfiguration = async options => { merged.threads = Math.max(merged.threads, 1); merged.chunkSize = Math.max(merged.chunkSize, 1); + if (process.arch === 'riscv64' && merged.threads > 1) { + logger.warn( + `Using ${merged.threads} threads might cause failures when` + + 'allocating wasm memory due to insufficient virtual address space' + + 'on riscv64 with sv39. Please consider using only a single thread.' + ); + } + // Transform global config if it wasn't already done await transformConfig(merged.global); diff --git a/src/utils/highlighter.mjs b/src/utils/highlighter.mjs index dee6acad..985b9c3c 100644 --- a/src/utils/highlighter.mjs +++ b/src/utils/highlighter.mjs @@ -37,9 +37,10 @@ function isCodeBlock(node) { } export const highlighter = await createHighlighter({ - // s390x machines throw memory issues on WASM builds - // https://github.com/nodejs/node/blob/c9acf345922bd758fbb3f16ee6256aa165260219/test/common/sea.js#L55 - wasm: process.arch !== 's390x', + // riscv64 with sv39 has limited virtual memory space, where creating + // too many (>20) wasm memory instances fails. + // https://github.com/nodejs/node/pull/60591 + wasm: process.arch !== 'riscv64', }); /**