@nxtedition/lib 21.0.3 → 21.0.5
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,20 @@ 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: { data, id } }) => {
|
|
450
|
+
memoryUsageMap.set(id, data)
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
setInterval(() => {
|
|
455
|
+
memoryUsageBC.postMessage({ data: process.memoryUsage(), id: serviceWorkerId })
|
|
456
|
+
}, 1e3).unref()
|
|
457
|
+
|
|
444
458
|
const startTime = Date.now()
|
|
445
459
|
stats$ = stats$.pipe(
|
|
446
460
|
rx.map((x) => ({
|
|
@@ -453,15 +467,36 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
453
467
|
rxjs.timer(0, 1e3).pipe(
|
|
454
468
|
rx.map(() => performance.eventLoopUtilization?.()),
|
|
455
469
|
rx.pairwise(),
|
|
456
|
-
rx.map(([elu1, elu2]) =>
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
470
|
+
rx.map(([elu1, elu2]) => {
|
|
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: process.memoryUsage(),
|
|
495
|
+
totalMemory,
|
|
496
|
+
utilization: performance.eventLoopUtilization?.(elu2, elu1),
|
|
497
|
+
heap: v8.getHeapStatistics(),
|
|
498
|
+
}
|
|
499
|
+
}),
|
|
465
500
|
),
|
|
466
501
|
),
|
|
467
502
|
rx.map(([serviceStats, appStats]) => ({
|