Skip to content

Commit 3a17176

Browse files
authored
fix: disable wasm highlighter on riscv64 (#691)
* fix: disable wasm highlighter on riscv64 riscv64 with sv39 has limited virtual memory space, where creating too many (>=20) wasm memory instances fails. See nodejs/node#60591 for more details. This PR fixes the following error encountered during `make test-only` on riscv64: [07:02:55.797] ERROR: WebAssembly.instantiate(): Out of memory: Cannot allocate Wasm memory for new instance RangeError: WebAssembly.instantiate(): Out of memory: Cannot allocate Wasm memory for new instancemake[1]: *** [Makefile:392: test/addons/.docbuildstamp] Error 1 make: *** [Makefile:352: test-only] Error 2 Signed-off-by: Levi Zim <rsworktech@outlook.com> * fix: enable wasm highlighter for s390x The bug for s390x has been fixed. * fix: limit threads to 1 on riscv64 And warn user if they set it to a larger value. --------- Signed-off-by: Levi Zim <rsworktech@outlook.com>
1 parent 8966c6a commit 3a17176

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
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

src/utils/highlighter.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ function isCodeBlock(node) {
3737
}
3838

3939
export const highlighter = await createHighlighter({
40-
// s390x machines throw memory issues on WASM builds
41-
// https://github.com/nodejs/node/blob/c9acf345922bd758fbb3f16ee6256aa165260219/test/common/sea.js#L55
42-
wasm: process.arch !== 's390x',
40+
// riscv64 with sv39 has limited virtual memory space, where creating
41+
// too many (>20) wasm memory instances fails.
42+
// https://github.com/nodejs/node/pull/60591
43+
wasm: process.arch !== 'riscv64',
4344
});
4445

4546
/**

0 commit comments

Comments
 (0)