Skip to content

Commit 2ce69e3

Browse files
committed
fix: limit threads to 1 on riscv64
And warn user if they set it to a larger value.
1 parent de9922a commit 2ce69e3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/utils/configuration/index.mjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { coerce } from 'semver';
55

66
import { CHANGELOG_URL, populate } from './templates.mjs';
77
import { allGenerators } from '../../generators/index.mjs';
8+
import logger from '../../logger/index.mjs';
89
import { parseChangelog, parseIndex } from '../../parsers/markdown.mjs';
910
import { enforceArray } from '../array.mjs';
1011
import { leftHandAssign } from '../generators.mjs';
@@ -33,7 +34,11 @@ export const getDefaultConfig = lazy(() =>
3334
}),
3435
},
3536

36-
threads: cpus().length,
37+
// The number of wasm memory instances is severely limited on
38+
// riscv64 with sv39. Running multiple generators that use wasm in
39+
// parallel could cause failures to allocate new wasm instance.
40+
// See also https://github.com/nodejs/node/pull/60591
41+
threads: process.arch === 'riscv64' ? 1 : cpus().length,
3742
chunkSize: 10,
3843
})
3944
)
@@ -121,6 +126,14 @@ export const createRunConfiguration = async options => {
121126
merged.threads = Math.max(merged.threads, 1);
122127
merged.chunkSize = Math.max(merged.chunkSize, 1);
123128

129+
if (process.arch === 'riscv64' && merged.threads > 1) {
130+
logger.warn(
131+
`Using ${merged.threads} threads might cause failures when` +
132+
'allocating wasm memory due to insufficient virtual address space' +
133+
'on riscv64 with sv39. Please consider using only a single thread.'
134+
);
135+
}
136+
124137
// Transform global config if it wasn't already done
125138
await transformConfig(merged.global);
126139

0 commit comments

Comments
 (0)