@nxtedition/lib 26.3.0 → 26.3.1

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 CHANGED
@@ -669,6 +669,7 @@ export function makeApp(appConfig, onTerminate) {
669
669
  underPressure: underPressure?.isUnderPressure() ? underPressure.getPressure() : null,
670
670
  cpu,
671
671
  memory,
672
+ affinity: globalThis.__nxt_sched_affinity,
672
673
  resourceLimits,
673
674
  utilization: performance.eventLoopUtilization?.(elu2, elu1),
674
675
  heap: v8.getHeapStatistics(),
package/numa.js CHANGED
@@ -3,7 +3,17 @@ import path from 'node:path'
3
3
 
4
4
  import { sched_setaffinity } from '@nxtedition/sched'
5
5
 
6
+ /**
7
+ *
8
+ * @param {number|number[]} numa
9
+ * @returns {number[]}
10
+ */
6
11
  export function setAffinity(numa) {
12
+ const indices = Array.from(new Set([numa].flat()))
13
+ if (indices.some((x) => !Number.isInteger(x) || x < 0)) {
14
+ throw new Error('NUMA node must be a non-negative integer')
15
+ }
16
+
7
17
  const allNodes = []
8
18
  for (const entry of fs.readdirSync('/sys/devices/system/node')) {
9
19
  if (!entry.startsWith('node')) {
@@ -31,12 +41,11 @@ export function setAffinity(numa) {
31
41
  throw new Error('No NUMA nodes found')
32
42
  }
33
43
 
34
- const indices = Array.from(new Set([numa].flat()))
35
- if (indices.some((x) => !Number.isInteger(x) || x < 0)) {
36
- throw new Error('NUMA node must be a non-negative integer')
37
- }
38
-
39
44
  const affinity = indices.flatMap((i) => allNodes[i % allNodes.length] ?? [])
40
45
  sched_setaffinity(0, affinity)
46
+ globalThis.__nxt_sched_affinity = {
47
+ cpulist: affinity,
48
+ nodelist: indices,
49
+ }
41
50
  return affinity
42
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "26.3.0",
3
+ "version": "26.3.1",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -1,4 +1,4 @@
1
- import { first, timeout as rxTimeout } from 'rxjs'
1
+ import * as rxjs from 'rxjs'
2
2
  import withAbortSignal from './withAbortSignal.js'
3
3
 
4
4
  export default function firstValueFrom(x$, config) {
@@ -11,8 +11,8 @@ export default function firstValueFrom(x$, config) {
11
11
  }
12
12
 
13
13
  if (timeout) {
14
- x$ = x$.pipe(rxTimeout(timeout))
14
+ x$ = x$.pipe(rxjs.timeout(timeout))
15
15
  }
16
16
 
17
- return x$.pipe(first(hasConfig ? config.defaultValue : undefined)).toPromise()
17
+ return rxjs.firstValueFrom(x$, config)
18
18
  }
@@ -150,16 +150,22 @@ class ObservableEntry {
150
150
  this.value = kEmpty
151
151
  this.error = null
152
152
  this.refresh = refresh
153
+ this.sync = true
153
154
  this.subscription = observable.subscribe({
154
155
  next: (value) => {
155
156
  this.value = value
156
- this.refresh()
157
+ if (!this.sync) {
158
+ this.refresh()
159
+ }
157
160
  },
158
161
  error: (err) => {
159
162
  this.error = err
160
- this.refresh()
163
+ if (!this.sync) {
164
+ this.refresh()
165
+ }
161
166
  },
162
167
  })
168
+ this.sync = false
163
169
  }
164
170
 
165
171
  dispose() {