backups: remove periodic dumping of heap info

this has not been as useful as I expected
This commit is contained in:
Girish Ramakrishnan
2022-11-05 08:32:36 +01:00
parent 549cb92ce7
commit aae52ec795

View File

@@ -11,8 +11,7 @@ const backuptask = require('../backuptask.js'),
database = require('../database.js'),
debug = require('debug')('box:backupupload'),
safe = require('safetydance'),
settings = require('../settings.js'),
v8 = require('v8');
settings = require('../settings.js');
// Main process starts here
const remotePath = process.argv[2];
@@ -43,35 +42,14 @@ function throttledProgressCallback(msecs) {
};
}
// https://github.com/josefzamrzla/gc-heap-stats#readme
// https://stackoverflow.com/questions/41541843/nodejs-v8-getheapstatistics-method
function dumpMemoryInfo() {
const mu = process.memoryUsage();
const hs = v8.getHeapStatistics();
function h(bytes) { // human readable
const i = Math.floor(Math.log(bytes) / Math.log(1024)),
sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
return (bytes / Math.pow(1024, i)).toFixed(2) * 1 + '' + sizes[i];
}
debug(`process: rss=${h(mu.rss)} heapUsed=${h(mu.heapUsed)} heapTotal=${h(mu.heapTotal)} external=${h(mu.external)}`
+ ` v8 heap: used=${h(hs.used_heap_size)} total=${h(hs.total_heap_size)} max=${h(hs.heap_size_limit)}`);
}
(async function main() {
await database.initialize();
await settings.initCache();
dumpMemoryInfo();
const timerId = setInterval(dumpMemoryInfo, 180 * 1000);
const [uploadError] = await safe(backuptask.upload(remotePath, format, dataLayoutString, throttledProgressCallback(5000)));
debug('upload completed. error: ', uploadError);
process.send({ result: uploadError ? uploadError.message : '' });
clearInterval(timerId);
// https://nodejs.org/api/process.html are exit codes used by node. apps.js uses the value below
// to check apptask crashes