@nxtedition/lib 26.0.32 → 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 +13 -18
- 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,18 +344,18 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
346
344
|
}
|
|
347
345
|
|
|
348
346
|
let indices = []
|
|
349
|
-
if (Number.isInteger(
|
|
350
|
-
indices = [
|
|
347
|
+
if (Number.isInteger(numa)) {
|
|
348
|
+
indices = [numa % allNodes.length]
|
|
351
349
|
} else if (
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
350
|
+
numa == null ||
|
|
351
|
+
numa === true ||
|
|
352
|
+
numa === 'auto' ||
|
|
353
|
+
numa === 'hash' ||
|
|
354
|
+
numa === 'default'
|
|
357
355
|
) {
|
|
358
356
|
indices = [hashString(serviceName) % allNodes.length]
|
|
359
357
|
} else {
|
|
360
|
-
throw new Error('invalid
|
|
358
|
+
throw new Error('invalid numa configuration: ' + numa)
|
|
361
359
|
}
|
|
362
360
|
|
|
363
361
|
affinity = indices.flatMap((i) => allNodes[i] ?? [])
|
|
@@ -369,15 +367,12 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
369
367
|
affinity.length === 0 ||
|
|
370
368
|
affinity.some((x) => !Number.isInteger(x) || x < 0)
|
|
371
369
|
) {
|
|
372
|
-
throw new Error('invalid
|
|
370
|
+
throw new Error('invalid numa configuration: ' + numa)
|
|
373
371
|
}
|
|
374
372
|
|
|
375
373
|
try {
|
|
376
374
|
sched_setaffinity(0, affinity)
|
|
377
|
-
logger.debug(
|
|
378
|
-
{ data: { value: appConfig.affinity, affinity, indices } },
|
|
379
|
-
'sched_setaffinity succeeded',
|
|
380
|
-
)
|
|
375
|
+
logger.debug({ data: { numa, affinity, indices } }, 'sched_setaffinity succeeded')
|
|
381
376
|
} catch (err) {
|
|
382
377
|
logger.error({ err }, 'sched_setaffinity failed')
|
|
383
378
|
}
|