@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.
Files changed (2) hide show
  1. package/app.js +13 -18
  2. 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
- if (
321
- process.platform === 'linux' &&
322
- (isMainThread || appConfig.affinity != null) &&
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(appConfig.affinity)) {
350
- indices = [appConfig.affinity % allNodes.length]
347
+ if (Number.isInteger(numa)) {
348
+ indices = [numa % allNodes.length]
351
349
  } else if (
352
- appConfig.affinity == null ||
353
- appConfig.affinity === true ||
354
- appConfig.affinity === 'auto' ||
355
- appConfig.affinity === 'hash' ||
356
- appConfig.affinity === 'default'
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 affinity configuration: ' + appConfig.affinity)
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 affinity configuration: ' + appConfig.affinity)
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "26.0.32",
3
+ "version": "26.0.33",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",