-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest-uv-threadpool-size-auto.js
More file actions
42 lines (36 loc) · 1.03 KB
/
test-uv-threadpool-size-auto.js
File metadata and controls
42 lines (36 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
require('../common');
const { spawnSyncAndAssert } = require('../common/child_process');
const assert = require('assert');
const os = require('os');
const expectedSize = Math.min(Math.max(4, os.availableParallelism()), 1024);
// When UV_THREADPOOL_SIZE is not set, Node.js should auto-size it based on
// uv_available_parallelism(), with a minimum of 4 and a maximum of 1024.
{
const env = { ...process.env };
delete env.UV_THREADPOOL_SIZE;
spawnSyncAndAssert(
process.execPath,
['-e', 'console.log(process.env.UV_THREADPOOL_SIZE)'],
{ env },
{
stdout(output) {
assert.strictEqual(output.trim(), String(expectedSize));
},
},
);
}
// When UV_THREADPOOL_SIZE is explicitly set, Node.js should not override it.
{
const env = { ...process.env, UV_THREADPOOL_SIZE: '8' };
spawnSyncAndAssert(
process.execPath,
['-e', 'console.log(process.env.UV_THREADPOOL_SIZE)'],
{ env },
{
stdout(output) {
assert.strictEqual(output.trim(), '8');
},
},
);
}