@nxtedition/lib 26.3.0 → 26.3.2
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 +1 -0
- package/numa.js +14 -5
- package/package.json +1 -1
- package/rxjs/firstValueFrom.js +3 -3
- package/util/template/index.test.js +13 -0
- package/util/template/javascript.js +8 -2
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
package/rxjs/firstValueFrom.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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(
|
|
14
|
+
x$ = x$.pipe(rxjs.timeout(timeout))
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
return x
|
|
17
|
+
return rxjs.firstValueFrom(x$, config)
|
|
18
18
|
}
|
|
@@ -79,3 +79,16 @@ test('string concat', async (t) => {
|
|
|
79
79
|
'pre body post',
|
|
80
80
|
)
|
|
81
81
|
})
|
|
82
|
+
|
|
83
|
+
test('syntax error', async (t) => {
|
|
84
|
+
const { resolveTemplate } = makeTemplateCompiler({})
|
|
85
|
+
const x = '{{#js $.test + }}'
|
|
86
|
+
await assert.rejects(
|
|
87
|
+
async () => {
|
|
88
|
+
await resolveTemplate(x, { test: 1 })
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'Error',
|
|
92
|
+
},
|
|
93
|
+
)
|
|
94
|
+
})
|
|
@@ -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.
|
|
157
|
+
if (!this.sync) {
|
|
158
|
+
this.refresh()
|
|
159
|
+
}
|
|
157
160
|
},
|
|
158
161
|
error: (err) => {
|
|
159
162
|
this.error = err
|
|
160
|
-
this.
|
|
163
|
+
if (!this.sync) {
|
|
164
|
+
this.refresh()
|
|
165
|
+
}
|
|
161
166
|
},
|
|
162
167
|
})
|
|
168
|
+
this.sync = false
|
|
163
169
|
}
|
|
164
170
|
|
|
165
171
|
dispose() {
|