@nxtedition/lib 26.0.31 → 26.0.33
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/app.js +15 -14
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -317,11 +317,9 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
let affinity = null
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
appConfig.affinity !== false
|
|
324
|
-
) {
|
|
320
|
+
|
|
321
|
+
const numa = appConfig.numa ?? config.numa
|
|
322
|
+
if (process.platform === 'linux' && (isMainThread || numa != null) && numa !== false) {
|
|
325
323
|
const allNodes = []
|
|
326
324
|
for (const entry of fs.readdirSync('/sys/devices/system/node')) {
|
|
327
325
|
if (!entry.startsWith('node')) {
|
|
@@ -346,12 +344,18 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
346
344
|
}
|
|
347
345
|
|
|
348
346
|
let indices = []
|
|
349
|
-
if (Number.isInteger(
|
|
350
|
-
indices = [
|
|
351
|
-
} else if (
|
|
347
|
+
if (Number.isInteger(numa)) {
|
|
348
|
+
indices = [numa % allNodes.length]
|
|
349
|
+
} else if (
|
|
350
|
+
numa == null ||
|
|
351
|
+
numa === true ||
|
|
352
|
+
numa === 'auto' ||
|
|
353
|
+
numa === 'hash' ||
|
|
354
|
+
numa === 'default'
|
|
355
|
+
) {
|
|
352
356
|
indices = [hashString(serviceName) % allNodes.length]
|
|
353
357
|
} else {
|
|
354
|
-
throw new Error('invalid
|
|
358
|
+
throw new Error('invalid numa configuration: ' + numa)
|
|
355
359
|
}
|
|
356
360
|
|
|
357
361
|
affinity = indices.flatMap((i) => allNodes[i] ?? [])
|
|
@@ -363,15 +367,12 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
363
367
|
affinity.length === 0 ||
|
|
364
368
|
affinity.some((x) => !Number.isInteger(x) || x < 0)
|
|
365
369
|
) {
|
|
366
|
-
throw new Error('invalid
|
|
370
|
+
throw new Error('invalid numa configuration: ' + numa)
|
|
367
371
|
}
|
|
368
372
|
|
|
369
373
|
try {
|
|
370
374
|
sched_setaffinity(0, affinity)
|
|
371
|
-
logger.debug(
|
|
372
|
-
{ data: { value: appConfig.affinity, affinity, indices } },
|
|
373
|
-
'sched_setaffinity succeeded',
|
|
374
|
-
)
|
|
375
|
+
logger.debug({ data: { numa, affinity, indices } }, 'sched_setaffinity succeeded')
|
|
375
376
|
} catch (err) {
|
|
376
377
|
logger.error({ err }, 'sched_setaffinity failed')
|
|
377
378
|
}
|