@nxtedition/lib 21.0.3 → 21.0.4
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 +44 -9
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -441,6 +441,16 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
441
441
|
stats$ = rxjs.timer(0, 10e3).pipe(rx.map(() => ({})))
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
+
const memoryUsageBC = new BroadcastChannel('nxt:memoryUsage')
|
|
445
|
+
|
|
446
|
+
let memoryUsageMap
|
|
447
|
+
if (isMainThread) {
|
|
448
|
+
memoryUsageMap = new Map()
|
|
449
|
+
memoryUsageBC.onmessage = ({ data, id }) => {
|
|
450
|
+
memoryUsageMap.set(id, data)
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
444
454
|
const startTime = Date.now()
|
|
445
455
|
stats$ = stats$.pipe(
|
|
446
456
|
rx.map((x) => ({
|
|
@@ -453,15 +463,40 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
453
463
|
rxjs.timer(0, 1e3).pipe(
|
|
454
464
|
rx.map(() => performance.eventLoopUtilization?.()),
|
|
455
465
|
rx.pairwise(),
|
|
456
|
-
rx.map(([elu1, elu2]) =>
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
466
|
+
rx.map(([elu1, elu2]) => {
|
|
467
|
+
const memory = process.memoryUsage()
|
|
468
|
+
|
|
469
|
+
memoryUsageBC.postMessage({ data: memory, id: threadId })
|
|
470
|
+
|
|
471
|
+
let totalMemory
|
|
472
|
+
if (memoryUsageMap) {
|
|
473
|
+
totalMemory = {
|
|
474
|
+
rss: 0,
|
|
475
|
+
heapTotal: 0,
|
|
476
|
+
heapUsed: 0,
|
|
477
|
+
external: 0,
|
|
478
|
+
arrayBuffers: 0,
|
|
479
|
+
}
|
|
480
|
+
for (const memoryUsage of memoryUsageMap.values()) {
|
|
481
|
+
totalMemory.rss += memoryUsage.rss
|
|
482
|
+
totalMemory.heapTotal += memoryUsage.heapTotal
|
|
483
|
+
totalMemory.heapUsed += memoryUsage.heapUsed
|
|
484
|
+
totalMemory.external += memoryUsage.external
|
|
485
|
+
totalMemory.arrayBuffers += memoryUsage.arrayBuffers
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
return {
|
|
490
|
+
ds: ds?.stats,
|
|
491
|
+
couch: couch?.stats,
|
|
492
|
+
lag: toobusy?.lag(),
|
|
493
|
+
version: process.version,
|
|
494
|
+
memory,
|
|
495
|
+
totalMemory,
|
|
496
|
+
utilization: performance.eventLoopUtilization?.(elu2, elu1),
|
|
497
|
+
heap: v8.getHeapStatistics(),
|
|
498
|
+
}
|
|
499
|
+
}),
|
|
465
500
|
),
|
|
466
501
|
),
|
|
467
502
|
rx.map(([serviceStats, appStats]) => ({
|