From 93202b2e1b64196ce1bf22ceb67ba6287b997952 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Mon, 16 Oct 2017 18:46:35 -0700 Subject: [PATCH] Fix the memory usage math 1. Use RSS, not Cache (shoulda read the source) 2. Convert bytes to megabytes before doing division --- ui/app/models/allocation.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/ui/app/models/allocation.js b/ui/app/models/allocation.js index 1665980e1..e77183202 100644 --- a/ui/app/models/allocation.js +++ b/ui/app/models/allocation.js @@ -30,18 +30,19 @@ export default Model.extend({ return taskGroups && taskGroups.findBy('name', this.get('taskGroupName')); }), - percentMemory: computed( - 'taskGroup.reservedMemory', - 'stats.ResourceUsage.MemoryStats.Cache', - function() { - const used = this.get('stats.ResourceUsage.MemoryStats.Cache'); - const total = this.get('taskGroup.reservedMemory'); - if (!total || !used) { - return 0; - } - return used / total; + memoryUsed: computed.readOnly('stats.ResourceUsage.MemoryStats.RSS'), + cpuUsed: computed('stats.ResourceUsage.CpuStats.TotalTicks', function() { + return Math.floor(this.get('stats.ResourceUsage.CpuStats.TotalTicks')); + }), + + percentMemory: computed('taskGroup.reservedMemory', 'memoryUsed', function() { + const used = this.get('memoryUsed') / 1024 / 1024; + const total = this.get('taskGroup.reservedMemory'); + if (!total || !used) { + return 0; } - ), + return used / total; + }), percentCPU: computed('stats.ResourceUsage.CpuStats.Percent', function() { return this.get('stats.ResourceUsage.CpuStats.Percent') || 0;