diff --git a/src/media.js b/src/media.js index 409ab2d3..5c506559 100644 --- a/src/media.js +++ b/src/media.js @@ -18,12 +18,6 @@ const knex = require('./knex'); const http = require('./utils/http'); const { get } = require('./utils/qu'); -function getMemoryUsage() { - return process.memoryUsage().rss / (10 ** 6); -} - -let peakMemoryUsage = getMemoryUsage(); - function sampleMedias(medias, limit = config.media.limit, preferLast = true) { // limit media sets, use extras as fallbacks if (medias.length <= limit) { @@ -314,9 +308,7 @@ async function storeImageFile(media, hashDir, hashSubDir, filename, filedir, fil await fsPromises.unlink(media.file.path); } - const memoryUsage = getMemoryUsage(); - peakMemoryUsage = Math.max(memoryUsage, peakMemoryUsage); - logger.silly(`Stored thumbnail and media from ${media.src}, memory usage ${memoryUsage.toFixed(2)} MB`); + logger.silly(`Stored thumbnail, lazy and permanent media file for ${media.id} from ${media.src} at ${filepath}`); return { ...media, @@ -358,7 +350,7 @@ async function storeFile(media) { await fsPromises.rename(media.file.path, path.join(config.media.path, filepath)); - logger.silly(`Stored media file at permanent location ${filepath}`); + logger.silly(`Stored permanent media file for ${media.id} from ${media.src} at ${filepath}`); return { ...media, @@ -482,10 +474,6 @@ async function fetchMedia(baseMedia, existingMedias) { Promise.reject(new Error()), ); - const memoryUsage = getMemoryUsage(); - peakMemoryUsage = Math.max(memoryUsage, peakMemoryUsage); - logger.silly(`Fetched media from ${source.src}, memory usage ${memoryUsage.toFixed(2)} MB`); - return { ...baseMedia, ...source, @@ -614,8 +602,6 @@ async function associateReleaseMedia(releases) { await knex.raw(`${knex(`releases_${role}`).insert(associations)} ON CONFLICT DO NOTHING`); } }, Promise.resolve()); - - logger.debug(`Peak media fetching memory usage: ${peakMemoryUsage.toFixed(2)} MB`); } module.exports = {