@nxtedition/lib 26.0.36 → 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 -23
- 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,33 +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
|
-
const prev = sched_getaffinity(0)
|
|
363
|
-
|
|
364
358
|
affinity = indices.flatMap((i) => allNodes[i] ?? [])
|
|
365
|
-
affinity = fp.uniq(affinity)
|
|
366
|
-
affinity = fp.intersection(affinity, prev)
|
|
367
|
-
|
|
368
359
|
if (
|
|
369
|
-
|
|
370
|
-
affinity.length
|
|
371
|
-
affinity.
|
|
360
|
+
Array.isArray(affinity) &&
|
|
361
|
+
affinity.length > 0 &&
|
|
362
|
+
affinity.every((x) => Number.isInteger(x) && x >= 0)
|
|
372
363
|
) {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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')
|
|
383
375
|
}
|
|
384
376
|
}
|
|
385
377
|
|