ui: fix alloc memory stats to match CLI output (#15909)

This commit is contained in:
Luiz Aoqui 2023-01-26 17:08:13 -05:00 committed by GitHub
parent ce3eef8037
commit 09fc054c82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 16 deletions

3
.changelog/15909.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: Fix allocation memory chart to display the same value as the CLI
```

View File

@ -29,6 +29,13 @@ const sortMap = [
const taskPrioritySort = (a, b) => const taskPrioritySort = (a, b) =>
sortMap[a.lifecycleName] - sortMap[b.lifecycleName]; sortMap[a.lifecycleName] - sortMap[b.lifecycleName];
// Select the value for memory usage.
// Must match logic in command/alloc_status.go.
const memoryUsed = (frame) =>
frame.ResourceUsage.MemoryStats.RSS ||
frame.ResourceUsage.MemoryStats.Usage ||
0;
@classic @classic
class AllocationStatsTracker extends EmberObject.extend(AbstractStatsTracker) { class AllocationStatsTracker extends EmberObject.extend(AbstractStatsTracker) {
// Set via the stats computed property macro // Set via the stats computed property macro
@ -49,15 +56,11 @@ class AllocationStatsTracker extends EmberObject.extend(AbstractStatsTracker) {
percent: percent(cpuUsed, this.reservedCPU), percent: percent(cpuUsed, this.reservedCPU),
}); });
const memoryUsed = const memUsed = memoryUsed(frame);
frame.ResourceUsage.MemoryStats.Usage ||
frame.ResourceUsage.MemoryStats.RSS ||
0;
this.memory.pushObject({ this.memory.pushObject({
timestamp, timestamp,
used: memoryUsed, used: memUsed,
percent: percent(memoryUsed / 1024 / 1024, this.reservedMemory), percent: percent(memUsed / 1024 / 1024, this.reservedMemory),
}); });
let aggregateCpu = 0; let aggregateCpu = 0;
@ -84,11 +87,7 @@ class AllocationStatsTracker extends EmberObject.extend(AbstractStatsTracker) {
percentStack: percentCpuTotal + aggregateCpu, percentStack: percentCpuTotal + aggregateCpu,
}); });
const taskMemoryUsed = const taskMemoryUsed = memoryUsed(taskFrame);
taskFrame.ResourceUsage.MemoryStats.Usage ||
taskFrame.ResourceUsage.MemoryStats.RSS ||
0;
const percentMemoryTotal = percent( const percentMemoryTotal = percent(
taskMemoryUsed / 1024 / 1024, taskMemoryUsed / 1024 / 1024,
this.reservedMemory this.reservedMemory

View File

@ -54,7 +54,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
}, },
MemoryStats: { MemoryStats: {
RSS: (step + 400) * 1024 * 1024, RSS: (step + 400) * 1024 * 1024,
Usage: (step + 400) * 1024 * 1024, Usage: (step + 800) * 1024 * 1024,
}, },
}, },
Tasks: { Tasks: {
@ -65,7 +65,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
}, },
MemoryStats: { MemoryStats: {
RSS: (step + 100) * 1024 * 1024, RSS: (step + 100) * 1024 * 1024,
Usage: (step + 100) * 1024 * 1024, Usage: (step + 200) * 1024 * 1024,
}, },
}, },
Timestamp: refDate + step, Timestamp: refDate + step,
@ -77,7 +77,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
}, },
MemoryStats: { MemoryStats: {
RSS: (step + 50) * 1024 * 1024, RSS: (step + 50) * 1024 * 1024,
Usage: (step + 50) * 1024 * 1024, Usage: (step + 100) * 1024 * 1024,
}, },
}, },
Timestamp: refDate + step * 10, Timestamp: refDate + step * 10,
@ -89,7 +89,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
}, },
MemoryStats: { MemoryStats: {
RSS: (step + 51) * 1024 * 1024, RSS: (step + 51) * 1024 * 1024,
Usage: (step + 51) * 1024 * 1024, Usage: (step + 101) * 1024 * 1024,
}, },
}, },
Timestamp: refDate + step * 100, Timestamp: refDate + step * 100,