@nxtedition/lib 26.0.35 → 26.0.37
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 -21
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -38,7 +38,7 @@ import makeUnderPressure from './under-pressure.js'
|
|
|
38
38
|
import undici from '@nxtedition/undici'
|
|
39
39
|
import { isPrimary } from 'node:cluster'
|
|
40
40
|
import path from 'node:path'
|
|
41
|
-
import { nice,
|
|
41
|
+
import { nice, sched_setaffinity } from '@nxtedition/sched'
|
|
42
42
|
|
|
43
43
|
export function makeApp(appConfig, onTerminate) {
|
|
44
44
|
let ds
|
|
@@ -353,31 +353,25 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
353
353
|
numa === 'default'
|
|
354
354
|
) {
|
|
355
355
|
indices = [hashString(JSON.stringify({ serviceName, serviceModule })) % allNodes.length]
|
|
356
|
-
} else {
|
|
357
|
-
throw Object.assign(new Error('invalid numa configuration: ' + numa), {
|
|
358
|
-
data: { numa, allNodes },
|
|
359
|
-
})
|
|
360
356
|
}
|
|
361
357
|
|
|
362
358
|
affinity = indices.flatMap((i) => allNodes[i] ?? [])
|
|
363
|
-
affinity = fp.uniq(affinity)
|
|
364
|
-
affinity = fp.intersection(affinity, sched_getaffinity(0))
|
|
365
|
-
|
|
366
359
|
if (
|
|
367
|
-
|
|
368
|
-
affinity.length
|
|
369
|
-
affinity.
|
|
360
|
+
Array.isArray(affinity) &&
|
|
361
|
+
affinity.length > 0 &&
|
|
362
|
+
affinity.every((x) => Number.isInteger(x) && x >= 0)
|
|
370
363
|
) {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
364
|
+
try {
|
|
365
|
+
sched_setaffinity(0, affinity)
|
|
366
|
+
logger.debug({ data: { numa, affinity, indices } }, 'sched_setaffinity succeeded')
|
|
367
|
+
} catch (err) {
|
|
368
|
+
logger.error(
|
|
369
|
+
{ err, data: { numa, allNodes, indices, affinity } },
|
|
370
|
+
'sched_setaffinity failed',
|
|
371
|
+
)
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
logger.warn({ data: { numa, allNodes, indices, affinity } }, 'sched_setaffinity failed')
|
|
381
375
|
}
|
|
382
376
|
}
|
|
383
377
|
|