Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.3.2
-
None
-
In Spark 3.0, the web UI and log statements now consistently report units in KiB, MiB, etc, (i.e. multiples of 1024) rather than KB and MB (i.e. multiples of 1000). For example, 1024000 bytes is now displayed as 1000 KiB rather than 1024 KB.
Description
In the reported heartbeat information, the unit of the memory data is bytes, which is converted by the formatBytes() function in the utils.js file before being displayed in the interface. The cardinality of the unit conversion in the formatBytes function is 1000, which should be 1024.
function formatBytes(bytes, type)
{ if (type !== 'display') return bytes; if (bytes == 0) return '0.0 B'; var k = 1000; var dm = 1; var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; var i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; }