improve admin rpc for diagnosing memory used by the cache

pull/1/head
ansuz 5 years ago
parent 77961e3954
commit e6ec891d9a

@ -20,22 +20,36 @@ var getFileDescriptorLimit = function (env, server, cb) {
}; };
var getCacheStats = function (env, server, cb) { var getCacheStats = function (env, server, cb) {
var metaSize = 0;
var channelSize = 0;
var metaCount = 0; var metaCount = 0;
var channelCount = 0; var channelCount = 0;
try {
var meta = env.metadata_cache; var meta = env.metadata_cache;
for (var x in meta) { for (var x in meta) {
if (meta.hasOwnProperty(x)) { metaCount++; } if (meta.hasOwnProperty(x)) {
metaCount++;
metaSize += JSON.stringify(meta[x]).length;
}
} }
var channels = env.channel_cache; var channels = env.channel_cache;
for (var y in channels) { for (var y in channels) {
if (channels.hasOwnProperty(y)) { channelCount++; } if (channels.hasOwnProperty(y)) {
channelCount++;
channelSize += JSON.stringify(channels[y]).length;
}
}
} catch (err) {
return void cb(err && err.message);
} }
cb(void 0, { cb(void 0, {
metadata: metaCount, metadata: metaCount,
metaSize: metaSize,
channel: channelCount, channel: channelCount,
channelSize: channelSize,
}); });
}; };

Loading…
Cancel
Save