@nxtedition/lib 27.1.6 → 27.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/numa.js +15 -9
- package/package.json +2 -2
package/numa.js
CHANGED
|
@@ -50,21 +50,23 @@ function parseRange(value) {
|
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
*
|
|
53
|
-
* @param {null|number|number[]} numa
|
|
53
|
+
* @param {null|undefined|number|number[]} numa
|
|
54
54
|
* @returns {number[]}
|
|
55
55
|
*/
|
|
56
56
|
export function setAffinity(numa) {
|
|
57
57
|
let affinity
|
|
58
58
|
|
|
59
|
-
if (numa
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
if (numa.some((x) => !Number.isInteger(x) || x < 0)) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
'NUMA node must be null, a non-negative integer or array of non-negative integers',
|
|
65
|
-
)
|
|
66
|
-
}
|
|
59
|
+
if (Number.isInteger(numa) && numa >= 0) {
|
|
60
|
+
numa = [numa]
|
|
61
|
+
}
|
|
67
62
|
|
|
63
|
+
if (numa == null) {
|
|
64
|
+
affinity = parseRange(fs.readFileSync('/sys/devices/system/cpu/present', 'utf8').trim())
|
|
65
|
+
} else if (
|
|
66
|
+
Array.isArray(numa) &&
|
|
67
|
+
numa.length > 0 &&
|
|
68
|
+
numa.every((x) => Number.isInteger(x) && x >= 0)
|
|
69
|
+
) {
|
|
68
70
|
const allNodes = []
|
|
69
71
|
for (const entry of fs.readdirSync('/sys/devices/system/node')) {
|
|
70
72
|
if (!/^node\d+$/.test(entry)) {
|
|
@@ -83,6 +85,10 @@ export function setAffinity(numa) {
|
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
affinity = numa.flatMap((i) => allNodes[i % allNodes.length] ?? [])
|
|
88
|
+
} else {
|
|
89
|
+
throw new Error(
|
|
90
|
+
'NUMA node must be undefined, null, a non-negative integer or non-empty array of non-negative integers',
|
|
91
|
+
)
|
|
86
92
|
}
|
|
87
93
|
|
|
88
94
|
const isolated = parseRange(fs.readFileSync('/sys/devices/system/cpu/isolated', 'utf8').trim())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "27.1.
|
|
3
|
+
"version": "27.1.7",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"pino": ">=7.0.0",
|
|
93
93
|
"rxjs": "^7.0.0"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "f2cf9a710d64115dcdb6dbf57b7876d2a30fa0e2"
|
|
96
96
|
}
|