lab4: компенсация без потери объекта при потере ответа COMMIT, полный декод изображений (sharp) в proxy и direct complete

This commit is contained in:
2026-10-23 16:37:13 +03:00
parent b32ce9a75d
commit 4badd5a7b9
33 changed files with 1932 additions and 861 deletions
+22
View File
@@ -0,0 +1,22 @@
// Peak RSS of one full decode check (same sharp options as ImageDecoder) on
// worst-case inputs near MAX_IMAGE_PIXELS. Run from app/: node ../scripts/lab4/decode_memory.mjs <files...>
import { readFileSync } from 'node:fs';
import { createRequire } from 'node:module';
const sharp = createRequire(`${process.cwd()}/`)('sharp');
sharp.cache(false);
sharp.concurrency(1);
for (const file of process.argv.slice(2)) {
const data = readFileSync(file);
const meta = await sharp(data).metadata();
const base = process.memoryUsage().rss;
let peak = base;
const timer = setInterval(() => {
peak = Math.max(peak, process.memoryUsage().rss);
}, 10);
const started = Date.now();
await sharp(data, { failOn: 'warning', sequentialRead: true, limitInputPixels: 40_000_000 }).stats();
clearInterval(timer);
console.log(
`${meta.format} ${meta.width}x${meta.height}${meta.isProgressive ? ' progressive' : ''} bytes=${data.length} decode_ms=${Date.now() - started} peak_delta_rss_mib=${((peak - base) / 1048576).toFixed(1)}`,
);
}