diff --git a/.env.example b/.env.example index 87462e2..fd34091 100644 --- a/.env.example +++ b/.env.example @@ -68,7 +68,10 @@ S3_CONNECT_TIMEOUT_MS=1000 S3_REQUEST_TIMEOUT_MS=15000 MAX_UPLOAD_BYTES=10485760 MAX_IMAGE_PIXELS=40000000 -UPLOAD_MAX_IN_FLIGHT=32 +# Каждая загрузка держит копию файла (≤ MAX_UPLOAD_BYTES) до полного декода: +# память реплики ≈ UPLOAD_MAX_IN_FLIGHT × 10 MiB + IMAGE_DECODE_MAX_CONCURRENT декодов. +UPLOAD_MAX_IN_FLIGHT=16 +IMAGE_DECODE_MAX_CONCURRENT=2 DIRECT_UPLOAD_MAX_PENDING_PER_USER=10 # UPLOAD_TIMEOUT_MS, DIRECT_UPLOAD_URL_TTL_SECONDS, ATTACHMENT_SWEEP_GRACE_SECONDS, # ATTACHMENT_SWEEP_INTERVAL_MS задаются в compose.yaml (environment) с умолчаниями diff --git a/app/package-lock.json b/app/package-lock.json index 4338b4b..32fbef7 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -26,6 +26,7 @@ "redis": "^6.3.0", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1", + "sharp": "^0.35.5", "zod": "^4.6.5" }, "devDependencies": { @@ -553,6 +554,16 @@ "node": ">=0.1.90" } }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@epic-web/invariant": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@epic-web/invariant/-/invariant-1.0.0.tgz", @@ -1200,6 +1211,506 @@ "node": ">= 10" } }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.5.tgz", + "integrity": "sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.5.tgz", + "integrity": "sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-freebsd-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.5.tgz", + "integrity": "sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==", + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.4.tgz", + "integrity": "sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.4.tgz", + "integrity": "sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.4.tgz", + "integrity": "sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==", + "cpu": [ + "arm" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.4.tgz", + "integrity": "sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.4.tgz", + "integrity": "sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==", + "cpu": [ + "ppc64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.4.tgz", + "integrity": "sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==", + "cpu": [ + "riscv64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.4.tgz", + "integrity": "sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==", + "cpu": [ + "s390x" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.4.tgz", + "integrity": "sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.4.tgz", + "integrity": "sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.4.tgz", + "integrity": "sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.5.tgz", + "integrity": "sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==", + "cpu": [ + "arm" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.5.tgz", + "integrity": "sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.5.tgz", + "integrity": "sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==", + "cpu": [ + "ppc64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.5.tgz", + "integrity": "sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==", + "cpu": [ + "riscv64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.5.tgz", + "integrity": "sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==", + "cpu": [ + "s390x" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.5.tgz", + "integrity": "sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.5.tgz", + "integrity": "sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.5.tgz", + "integrity": "sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz", + "integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==", + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.11.3" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-webcontainers-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.5.tgz", + "integrity": "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.5.tgz", + "integrity": "sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.5.tgz", + "integrity": "sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.5.tgz", + "integrity": "sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, "node_modules/@inquirer/ansi": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-2.0.8.tgz", @@ -4014,7 +4525,6 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", - "dev": true, "license": "Apache-2.0", "engines": { "node": ">=8" @@ -6842,6 +7352,55 @@ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", "license": "ISC" }, + "node_modules/sharp": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.5.tgz", + "integrity": "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==", + "license": "Apache-2.0", + "dependencies": { + "@img/colour": "^1.1.0", + "detect-libc": "^2.1.2", + "semver": "^7.8.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.35.5", + "@img/sharp-darwin-x64": "0.35.5", + "@img/sharp-freebsd-wasm32": "0.35.5", + "@img/sharp-libvips-darwin-arm64": "1.3.4", + "@img/sharp-libvips-darwin-x64": "1.3.4", + "@img/sharp-libvips-linux-arm": "1.3.4", + "@img/sharp-libvips-linux-arm64": "1.3.4", + "@img/sharp-libvips-linux-ppc64": "1.3.4", + "@img/sharp-libvips-linux-riscv64": "1.3.4", + "@img/sharp-libvips-linux-s390x": "1.3.4", + "@img/sharp-libvips-linux-x64": "1.3.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4", + "@img/sharp-libvips-linuxmusl-x64": "1.3.4", + "@img/sharp-linux-arm": "0.35.5", + "@img/sharp-linux-arm64": "0.35.5", + "@img/sharp-linux-ppc64": "0.35.5", + "@img/sharp-linux-riscv64": "0.35.5", + "@img/sharp-linux-s390x": "0.35.5", + "@img/sharp-linux-x64": "0.35.5", + "@img/sharp-linuxmusl-arm64": "0.35.5", + "@img/sharp-linuxmusl-x64": "0.35.5", + "@img/sharp-webcontainers-wasm32": "0.35.5", + "@img/sharp-win32-arm64": "0.35.5", + "@img/sharp-win32-ia32": "0.35.5", + "@img/sharp-win32-x64": "0.35.5" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", diff --git a/app/package.json b/app/package.json index 3b58c6c..30a2c2b 100644 --- a/app/package.json +++ b/app/package.json @@ -44,6 +44,7 @@ "redis": "^6.3.0", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1", + "sharp": "^0.35.5", "zod": "^4.6.5" }, "devDependencies": { diff --git a/app/src/attachments/attachments.module.ts b/app/src/attachments/attachments.module.ts index 32305df..951c8d6 100644 --- a/app/src/attachments/attachments.module.ts +++ b/app/src/attachments/attachments.module.ts @@ -8,6 +8,8 @@ import { StorageModule } from '../storage/storage.module.js'; import { AttachmentSweeper } from './attachment-sweeper.service.js'; import { AttachmentsController } from './attachments.controller.js'; import { AttachmentsRepository } from './attachments.repository.js'; +import { ImageDecoder } from './image/image-decoder.js'; +import { UploadSlots } from './upload-slots.js'; import { DirectUploadsService } from './direct-uploads.service.js'; import { AttachmentsService } from './attachments.service.js'; @@ -25,6 +27,8 @@ import { AttachmentsService } from './attachments.service.js'; AttachmentsRepository, AttachmentsService, DirectUploadsService, + ImageDecoder, + UploadSlots, AttachmentSweeper, ], exports: [AttachmentsRepository], diff --git a/app/src/attachments/attachments.repository.ts b/app/src/attachments/attachments.repository.ts index a3cea2c..d5f36c0 100644 --- a/app/src/attachments/attachments.repository.ts +++ b/app/src/attachments/attachments.repository.ts @@ -75,13 +75,38 @@ export class AttachmentsRepository { ); } - async rejectPending(id: string): Promise { - await this.database.query( + async rejectPending(id: string): Promise { + const result = await this.database.query( 'attachments.reject_pending', `UPDATE attachments SET status = 'rejected', updated_at = now() WHERE id = $1 AND status = 'pending'`, [id], ); + return result.rowCount === 1; + } + + /** + * Takes a pending row out of play before its object is deleted. The object + * is deleted only when this returns true: a row that is already `ready` + * (its commit succeeded even if the reply was lost) keeps its object. + */ + async claimForCompensation(id: string): Promise { + const result = await this.database.query( + 'attachments.claim_for_compensation', + `UPDATE attachments SET status = 'deleting', updated_at = now() + WHERE id = $1 AND status = 'pending'`, + [id], + ); + return result.rowCount === 1; + } + + async findById(id: string): Promise { + const result = await this.database.query( + 'attachments.find_by_id', + 'SELECT * FROM attachments WHERE id = $1', + [id], + ); + return result.rows[0]; } async findVisible( diff --git a/app/src/attachments/attachments.service.spec.ts b/app/src/attachments/attachments.service.spec.ts new file mode 100644 index 0000000..77b0478 --- /dev/null +++ b/app/src/attachments/attachments.service.spec.ts @@ -0,0 +1,113 @@ +import { readFileSync } from 'node:fs'; +import { dirname, join } from 'node:path'; +import { Readable } from 'node:stream'; +import { fileURLToPath } from 'node:url'; +import { describe, expect, it, vi } from 'vitest'; +import type { AttachmentRow } from './attachment.js'; +import { AttachmentsService } from './attachments.service.js'; + +const here = dirname(fileURLToPath(import.meta.url)); +const png = readFileSync(join(here, '../../../tests/fixtures/sample.png')); +const lostReply = () => + Object.assign(new Error('Connection terminated unexpectedly'), {}); + +const settings: Record = { + MAX_UPLOAD_BYTES: 10_485_760, + MAX_IMAGE_PIXELS: 40_000_000, + UPLOAD_TIMEOUT_MS: 10_000, +}; + +function setup(repository: Record) { + const storage = { + objectKey: (id: string) => `attachments/${id}/original`, + putStream: vi.fn(async (_key: string, body: Readable) => { + for await (const _chunk of body) { + // drain like S3 does + } + }), + delete: vi.fn().mockResolvedValue(undefined), + }; + const service = new AttachmentsService( + { getOrThrow: (key: string) => settings[key] } as never, + { + insertPending: vi.fn(), + deleteClaimed: vi.fn(), + ...repository, + } as never, + storage as never, + { getForUser: vi.fn() } as never, + { increment: vi.fn(), add: vi.fn() } as never, + { verify: vi.fn() } as never, + { run: (work: () => Promise) => work() } as never, + ); + const upload = () => + service.uploadProxy( + 'chat', + { id: 'user' } as never, + 'a.png', + 'image/png', + String(png.length), + Readable.from([png]), + ); + return { storage, upload }; +} + +const readyRow = (id: string): AttachmentRow => ({ + id, + chat_id: 'chat', + owner_id: 'user', + filename: 'a.png', + content_type: 'image/png', + upload_mode: 'proxy', + status: 'ready', + object_key: `attachments/${id}/original`, + size_bytes: png.length, + sha256: 'a'.repeat(64), + width: 320, + height: 200, + expires_at: null, + created_at: new Date(), + updated_at: new Date(), +}); + +describe('AttachmentsService compensation', () => { + it('keeps the object and answers 201 when ready was committed but its reply was lost', async () => { + const { storage, upload } = setup({ + markReady: vi.fn().mockRejectedValue(lostReply()), + claimForCompensation: vi.fn().mockResolvedValue(false), + findById: vi.fn((id: string) => Promise.resolve(readyRow(id))), + }); + const attachment = await upload(); + expect(attachment.status).toBe('ready'); + expect(storage.delete).not.toHaveBeenCalled(); + }); + + it('deletes nothing while PostgreSQL is unreachable', async () => { + const { storage, upload } = setup({ + markReady: vi.fn().mockRejectedValue(lostReply()), + claimForCompensation: vi.fn().mockRejectedValue(lostReply()), + findById: vi.fn().mockRejectedValue(lostReply()), + }); + await expect(upload()).rejects.toThrow(); + expect(storage.delete).not.toHaveBeenCalled(); + }); + + it('deletes the object only after claiming the pending row', async () => { + const order: string[] = []; + const { storage, upload } = setup({ + markReady: vi.fn().mockRejectedValue(lostReply()), + claimForCompensation: vi.fn(async () => { + order.push('claim'); + return true; + }), + deleteClaimed: vi.fn(async () => { + order.push('delete-row'); + }), + }); + storage.delete.mockImplementation(async () => { + order.push('delete-object'); + }); + await expect(upload()).rejects.toThrow(); + expect(order).toEqual(['claim', 'delete-object', 'delete-row']); + }); +}); diff --git a/app/src/attachments/attachments.service.ts b/app/src/attachments/attachments.service.ts index e46b77d..7a7fa4e 100644 --- a/app/src/attachments/attachments.service.ts +++ b/app/src/attachments/attachments.service.ts @@ -30,6 +30,8 @@ import { ImageRejectedError, } from './image/image-inspector.js'; import { AttachmentsRepository } from './attachments.repository.js'; +import { ImageDecoder } from './image/image-decoder.js'; +import { UploadSlots } from './upload-slots.js'; const MEDIA_TYPES = new Set(['image/png', 'image/jpeg']); @@ -49,11 +51,9 @@ class UploadInterruptedError extends Error {} @Injectable() export class AttachmentsService { private readonly logger = new Logger(AttachmentsService.name); - private inFlight = 0; private readonly maxUploadBytes: number; private readonly maxPixels: number; private readonly uploadTimeoutMs: number; - private readonly maxInFlight: number; constructor( config: ConfigService, @@ -61,11 +61,12 @@ export class AttachmentsService { private readonly storage: ObjectStorage, private readonly chats: ChatsService, private readonly metrics: MetricsService, + private readonly decoder: ImageDecoder, + private readonly slots: UploadSlots, ) { this.maxUploadBytes = config.getOrThrow('MAX_UPLOAD_BYTES'); this.maxPixels = config.getOrThrow('MAX_IMAGE_PIXELS'); this.uploadTimeoutMs = config.getOrThrow('UPLOAD_TIMEOUT_MS'); - this.maxInFlight = config.getOrThrow('UPLOAD_MAX_IN_FLIGHT'); } async uploadProxy( @@ -93,15 +94,9 @@ export class AttachmentsService { if (contentLength > this.maxUploadBytes) throw new PayloadTooLargeException('Image is too large'); - if (this.inFlight >= this.maxInFlight) - throw new HttpException( - { message: 'Too many concurrent uploads', retryAfter: 1 }, - 429, - ); - this.inFlight += 1; - try { + return this.slots.run(async () => { await this.chats.getForUser(chatId, user); - return await this.receive( + return this.receive( chatId, user, filename, @@ -109,9 +104,7 @@ export class AttachmentsService { contentLength, body, ); - } finally { - this.inFlight -= 1; - } + }); } private async receive( @@ -193,8 +186,12 @@ export class AttachmentsService { }); const sha256 = createHash('sha256'); + const decoder = this.decoder; + // Copy for the full decode check; bounded by MAX_UPLOAD_BYTES and + // UPLOAD_MAX_IN_FLIGHT, released as soon as the decode starts. + const copy: Buffer[] = []; let total = 0; - const account = (chunk: Buffer, inspect: boolean): void => { + const account = (chunk: Buffer, inspect: boolean): boolean => { total += chunk.length; if (total > contentLength) throw new UploadInterruptedError( @@ -203,19 +200,26 @@ export class AttachmentsService { if (inspect) inspector.push(chunk); sha256.update(chunk); this.metrics.add('attachments.proxy.bytes_in', chunk.length); - // Validate before the last bytes reach S3: it cannot commit an - // object whose body is incomplete. - if (total === contentLength) inspector.finish(); + copy.push(chunk); + return total === contentLength; + }; + // Validate before the last bytes reach S3: it cannot commit an object + // whose body is incomplete, so an invalid image never becomes an object. + const finalize = async (): Promise => { + inspector.finish(); + const data = Buffer.concat(copy, total); + copy.length = 0; + await decoder.verify(data); }; async function* generate(): AsyncGenerator { for (const chunk of head) { - account(chunk, false); + if (account(chunk, false)) await finalize(); yield chunk; } for (;;) { const step = await next(); if (step.done) break; - account(step.value, true); + if (account(step.value, true)) await finalize(); yield step.value; } if (total < contentLength) @@ -238,6 +242,7 @@ export class AttachmentsService { // `rejection`; the listener also keeps a late error from crashing us. readable.on('error', () => controller.abort()); let claimed = false; + let stored = false; try { await this.storage.putStream( key, @@ -250,6 +255,7 @@ export class AttachmentsService { 'attachments.proxy.bytes_to_s3', contentLength, ); + stored = true; const row = await this.repository.markReady(id, { sizeBytes: total, sha256: sha256.digest('hex'), @@ -264,7 +270,23 @@ export class AttachmentsService { return toAttachment(row); } catch (error) { readable.destroy(); - if (!claimed) await this.compensate(id, key); + if (!claimed) { + const outcome = await this.compensate(id, key); + // markReady failed on our side, but the row is no longer + // pending: the commit may have succeeded with its reply lost. + // If so, the upload is complete and 201 is the truth. + if (outcome === 'not_pending' && stored) { + const row = await this.repository + .findById(id) + .catch(() => undefined); + if (row?.status === 'ready') { + this.metrics.increment( + 'attachments.upload.recovered', + ); + return toAttachment(row); + } + } + } throw this.mapUploadError(rejection ?? error, timedOut); } } finally { @@ -279,16 +301,33 @@ export class AttachmentsService { return error; } - async compensate(id: string, key: string): Promise { + /** + * Undoes an upload that did not reach `ready`. The row is claimed first + * (pending -> deleting) and the object is deleted only after a successful + * claim: if PostgreSQL committed `ready` but the reply was lost, the claim + * matches nothing and the object stays. If PostgreSQL is unreachable, + * nothing is deleted; the sweeper finishes the job after expiry + grace + * (a row stuck in `deleting` is re-claimed after a minute). + */ + async compensate( + id: string, + key: string, + ): Promise<'compensated' | 'not_pending' | 'deferred'> { try { + if (!(await this.repository.claimForCompensation(id))) { + this.metrics.increment('attachments.compensation_skipped'); + return 'not_pending'; + } await this.storage.delete(key); - await this.repository.deletePending(id); + await this.repository.deleteClaimed(id); this.metrics.increment('attachments.compensated'); + return 'compensated'; } catch (error) { this.metrics.increment('attachments.compensation_deferred'); this.logger.warn( `Compensation of attachment ${id} deferred: ${error instanceof Error ? error.message : 'unknown error'}`, ); + return 'deferred'; } } diff --git a/app/src/attachments/direct-uploads.service.ts b/app/src/attachments/direct-uploads.service.ts index 4229436..c35cdc4 100644 --- a/app/src/attachments/direct-uploads.service.ts +++ b/app/src/attachments/direct-uploads.service.ts @@ -22,8 +22,9 @@ import { AttachmentsRepository } from './attachments.repository.js'; import { imageRejection } from './attachments.service.js'; import type { CreateDirectUploadDto } from './dto/create-direct-upload.dto.js'; import { validateFilename } from './filename.js'; +import { ImageDecoder } from './image/image-decoder.js'; +import { UploadSlots } from './upload-slots.js'; import { - IMAGE_HEADER_MAX_BYTES, ImageInspector, ImageRejectedError, type ImageHeader, @@ -37,7 +38,6 @@ export type DirectUpload = { expires_at: string; }; -const FIRST_RANGE_BYTES = 65_536; const MEDIA_TYPES = new Set(['image/png', 'image/jpeg']); @Injectable() @@ -53,6 +53,8 @@ export class DirectUploadsService { private readonly storage: ObjectStorage, private readonly chats: ChatsService, private readonly metrics: MetricsService, + private readonly decoder: ImageDecoder, + private readonly slots: UploadSlots, ) { this.maxUploadBytes = config.getOrThrow('MAX_UPLOAD_BYTES'); this.maxPixels = config.getOrThrow('MAX_IMAGE_PIXELS'); @@ -136,7 +138,10 @@ export class DirectUploadsService { ); if (!row) throw new NotFoundException(); if (row.status === 'ready') return toAttachment(row); + return this.slots.run(() => this.verifyAndMarkReady(row)); + } + private async verifyAndMarkReady(row: AttachmentRow): Promise { const size = Number(row.size_bytes); const expectedChecksum = Buffer.from( row.sha256 as string, @@ -152,10 +157,9 @@ export class DirectUploadsService { ); } - // Only the header is read: the signed checksum already pins every byte. let header: ImageHeader; try { - header = await this.readHeader(row.object_key, size); + header = await this.verifyObject(row.object_key, size); } catch (error) { if (error instanceof ImageRejectedError) { await this.reject(row); @@ -181,40 +185,41 @@ export class DirectUploadsService { } /** - * Reads a small first range and widens it only when the header is not in it, - * so the usual `complete` costs one short ranged GET. A range that covers the - * whole object is also checked for structural completeness. + * Reads the whole object: a correct signed checksum only proves that the + * bytes are the ones the client declared, not that they form an image. The + * stream goes through ImageInspector (structure, CRCs, completeness), then + * the copy is fully decoded. Memory is bounded like a proxy upload. */ - private async readHeader(key: string, size: number): Promise { - const ceiling = Math.min(size, IMAGE_HEADER_MAX_BYTES); - let range = Math.min(size, FIRST_RANGE_BYTES); - for (;;) { - const inspector = new ImageInspector(this.maxPixels); - const stream = await this.storage.getStream( - key, - `bytes=0-${range - 1}`, - ); - if (stream === null) - throw new ConflictException('Upload has not been received'); - let verified = 0; - try { - for await (const chunk of stream as AsyncIterable) { - verified += chunk.length; - inspector.push(chunk); - } - } finally { - stream.destroy(); - this.metrics.add('attachments.direct.verify_bytes', verified); + private async verifyObject( + key: string, + size: number, + ): Promise { + const stream = await this.storage.getStream(key); + if (stream === null) + throw new ConflictException('Upload has not been received'); + const inspector = new ImageInspector(this.maxPixels); + const chunks: Buffer[] = []; + let read = 0; + try { + for await (const chunk of stream as AsyncIterable) { + read += chunk.length; + if (read > size) + throw new ImageRejectedError( + 'unsupported_media_type', + 'Object is larger than declared', + ); + inspector.push(chunk); + chunks.push(chunk); } - if (range === size) return inspector.finish(); - if (inspector.header !== undefined) return inspector.header; - if (range >= ceiling) - throw new ImageRejectedError( - 'unsupported_media_type', - 'Image header is missing', - ); - range = ceiling; + } finally { + stream.destroy(); + this.metrics.add('attachments.direct.verify_bytes', read); } + const header = inspector.finish(); + const data = Buffer.concat(chunks, read); + chunks.length = 0; + await this.decoder.verify(data); + return header; } /** @@ -223,7 +228,9 @@ export class DirectUploadsService { * object that no row refers to. The sweeper removes both after expiry + grace. */ private async reject(row: AttachmentRow): Promise { - await this.repository.rejectPending(row.id); + // Row first: a row that is not pending any more (ready after a parallel + // complete, or claimed by the sweeper) keeps its object. + if (!(await this.repository.rejectPending(row.id))) return; try { await this.storage.delete(row.object_key); } catch { diff --git a/app/src/attachments/image/image-decoder.spec.ts b/app/src/attachments/image/image-decoder.spec.ts new file mode 100644 index 0000000..9b36dbe --- /dev/null +++ b/app/src/attachments/image/image-decoder.spec.ts @@ -0,0 +1,51 @@ +import { readFileSync } from 'node:fs'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { describe, expect, it } from 'vitest'; +import { jpegWithoutScanData } from '../../../test/support/jpeg.js'; +import { noisePng, pngWithGarbageIdat } from '../../../test/support/png.js'; +import { ImageDecoder } from './image-decoder.js'; +import { ImageInspector, ImageRejectedError } from './image-inspector.js'; + +const here = dirname(fileURLToPath(import.meta.url)); +const png = readFileSync(join(here, '../../../../tests/fixtures/sample.png')); +const jpeg = readFileSync(join(here, '../../../test/fixtures/sample.jpg')); +const progressive = readFileSync( + join(here, '../../../test/fixtures/sample-progressive.jpg'), +); + +const settings: Record = { + MAX_IMAGE_PIXELS: 40_000_000, + IMAGE_DECODE_MAX_CONCURRENT: 1, +}; +const decoder = new ImageDecoder( + { getOrThrow: (key: string) => settings[key] } as never, + { increment: () => undefined, add: () => undefined } as never, +); + +describe('ImageDecoder', () => { + it('accepts valid PNG and JPEG files, also concurrently', async () => { + await Promise.all( + [png, jpeg, progressive, noisePng(1_048_576)].map((data) => + decoder.verify(data), + ), + ); + }); + + // These files pass the structural inspector; only a decode catches them. + it.each([ + ['PNG with a garbage zlib stream', pngWithGarbageIdat()], + ['JPEG without scan data', jpegWithoutScanData(jpeg)], + [ + 'progressive JPEG without scan data', + jpegWithoutScanData(progressive), + ], + ])('rejects a %s', async (_name, data) => { + const inspector = new ImageInspector(40_000_000); + inspector.push(data); + expect(inspector.finish().width).toBe(320); + await expect(decoder.verify(data)).rejects.toBeInstanceOf( + ImageRejectedError, + ); + }); +}); diff --git a/app/src/attachments/image/image-decoder.ts b/app/src/attachments/image/image-decoder.ts new file mode 100644 index 0000000..8dfe35f --- /dev/null +++ b/app/src/attachments/image/image-decoder.ts @@ -0,0 +1,72 @@ +import { Injectable } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; +import sharp from 'sharp'; +import type { AppConfig } from '../../config/app-config.schema.js'; +import { MetricsService } from '../../metrics/metrics.service.js'; +import { ImageRejectedError } from './image-inspector.js'; + +// One libvips worker per decode and no operation cache: decodes are one-off, +// and memory must stay predictable under the per-replica limit. +sharp.cache(false); +sharp.concurrency(1); + +/** + * Full decode check. ImageInspector only proves the container structure + * (signature, chunk CRCs, markers, dimensions); a PNG with a garbage zlib stream + * or a JPEG without scan data passes it. Decoding every pixel with + * failOn=warning rejects those, including truncated or corrupted entropy data. + * Decodes are bounded by IMAGE_DECODE_MAX_CONCURRENT; callers wait for a slot. + */ +@Injectable() +export class ImageDecoder { + private readonly maxPixels: number; + private readonly maxConcurrent: number; + private active = 0; + private readonly waiting: (() => void)[] = []; + + constructor( + config: ConfigService, + private readonly metrics: MetricsService, + ) { + this.maxPixels = config.getOrThrow('MAX_IMAGE_PIXELS'); + this.maxConcurrent = config.getOrThrow('IMAGE_DECODE_MAX_CONCURRENT'); + } + + async verify(data: Buffer): Promise { + await this.acquire(); + const started = performance.now(); + try { + await sharp(data, { + failOn: 'warning', + sequentialRead: true, + limitInputPixels: this.maxPixels, + }).stats(); + } catch { + this.metrics.increment('attachments.decode.rejected'); + throw new ImageRejectedError( + 'unsupported_media_type', + 'Image data cannot be decoded', + ); + } finally { + this.metrics.add( + 'attachments.decode.ms', + performance.now() - started, + ); + this.release(); + } + } + + private async acquire(): Promise { + if (this.active < this.maxConcurrent) { + this.active += 1; + return; + } + await new Promise((resolve) => this.waiting.push(resolve)); + } + + private release(): void { + const next = this.waiting.shift(); + if (next) next(); + else this.active -= 1; + } +} diff --git a/app/src/attachments/image/image-inspector.ts b/app/src/attachments/image/image-inspector.ts index eb04126..64a2f0e 100644 --- a/app/src/attachments/image/image-inspector.ts +++ b/app/src/attachments/image/image-inspector.ts @@ -59,7 +59,9 @@ function unsupported(message: string): ImageRejectedError { /** * Streaming structural validator for PNG and JPEG. It never buffers the body: * only fixed-size fields (chunk headers, IHDR, SOF) are accumulated, and - * nothing is decompressed. + * nothing is decompressed. It is the early gate (type, dimensions, pixel limit + * before anything is stored), not proof of a valid image: compressed pixel + * data is checked by ImageDecoder. */ export class ImageInspector { private state: State = 'start'; diff --git a/app/src/attachments/upload-slots.ts b/app/src/attachments/upload-slots.ts new file mode 100644 index 0000000..528c483 --- /dev/null +++ b/app/src/attachments/upload-slots.ts @@ -0,0 +1,31 @@ +import { HttpException, Injectable } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; +import type { AppConfig } from '../config/app-config.schema.js'; + +/** + * Per-replica cap on requests that hold an image in memory (proxy upload, + * direct complete): each may keep up to MAX_UPLOAD_BYTES for the decode check. + */ +@Injectable() +export class UploadSlots { + private inFlight = 0; + private readonly max: number; + + constructor(config: ConfigService) { + this.max = config.getOrThrow('UPLOAD_MAX_IN_FLIGHT'); + } + + async run(work: () => Promise): Promise { + if (this.inFlight >= this.max) + throw new HttpException( + { message: 'Too many concurrent uploads', retryAfter: 1 }, + 429, + ); + this.inFlight += 1; + try { + return await work(); + } finally { + this.inFlight -= 1; + } + } +} diff --git a/app/src/config/app-config.schema.ts b/app/src/config/app-config.schema.ts index 9ab02a1..e115501 100644 --- a/app/src/config/app-config.schema.ts +++ b/app/src/config/app-config.schema.ts @@ -85,7 +85,13 @@ export const appConfigSchema = z MAX_UPLOAD_BYTES: numeric('MAX_UPLOAD_BYTES', 1, 10485760, 10485760), MAX_IMAGE_PIXELS: numeric('MAX_IMAGE_PIXELS', 1, 40000000, 40000000), UPLOAD_TIMEOUT_MS: numeric('UPLOAD_TIMEOUT_MS', 1000, undefined, 25000), - UPLOAD_MAX_IN_FLIGHT: numeric('UPLOAD_MAX_IN_FLIGHT', 1, 1024, 32), + UPLOAD_MAX_IN_FLIGHT: numeric('UPLOAD_MAX_IN_FLIGHT', 1, 1024, 16), + IMAGE_DECODE_MAX_CONCURRENT: numeric( + 'IMAGE_DECODE_MAX_CONCURRENT', + 1, + 64, + 2, + ), // 0 отключает фоновый проход уборщика (остаётся ручной CLI). ATTACHMENT_SWEEP_INTERVAL_MS: numeric( 'ATTACHMENT_SWEEP_INTERVAL_MS', diff --git a/app/test/attachments.e2e-spec.ts b/app/test/attachments.e2e-spec.ts index 1241258..0758ba6 100644 --- a/app/test/attachments.e2e-spec.ts +++ b/app/test/attachments.e2e-spec.ts @@ -21,7 +21,13 @@ import { upload, uploadRaw, } from './support/e2e.js'; -import { noisePng, padPngTo, pixelBombPng } from './support/png.js'; +import { jpegWithoutScanData } from './support/jpeg.js'; +import { + noisePng, + padPngTo, + pixelBombPng, + pngWithGarbageIdat, +} from './support/png.js'; const png = readFileSync( new URL('../../tests/fixtures/sample.png', import.meta.url), @@ -167,6 +173,8 @@ describe('attachments (proxy upload)', () => { flipped, Buffer.concat([png.subarray(0, 8), randomBytes(2048)]), Buffer.alloc(0), + // Structure and CRCs are fine; the pixel data does not decode. + pngWithGarbageIdat(), ]; for (const data of cases) expectError( @@ -176,6 +184,24 @@ describe('attachments (proxy upload)', () => { ); }); + it.each([ + ['baseline', jpeg], + ['progressive', progressive], + ])('rejects a %s JPEG without scan data', async (_name, data) => { + expectError( + await upload( + alice.token, + leftoverChatId, + jpegWithoutScanData(data), + { + contentType: 'image/jpeg', + }, + ), + 415, + 'unsupported_media_type', + ); + }); + it('rejects a content type that does not match the bytes', async () => { const gif = Buffer.from('GIF89a' + 'x'.repeat(64)); const cases: [Buffer, string][] = [ diff --git a/app/test/dependency-failures.e2e-spec.ts b/app/test/dependency-failures.e2e-spec.ts index 95cfae6..c44822c 100644 --- a/app/test/dependency-failures.e2e-spec.ts +++ b/app/test/dependency-failures.e2e-spec.ts @@ -944,12 +944,13 @@ describe.skipIf(!enabled)('dependency outages', () => { expect((await request('/health/ready')).response.status).toBe( 200, ); - // Compensation could not reach S3, so the row stays for the sweeper. + // Compensation claimed the row but could not delete the object: + // the row stays in `deleting`, tracked for the sweeper. expect( await psql( - `select count(*) from attachments where chat_id = '${chat.id}' and status = 'pending' and filename = 's3down-${runId}.png'`, + `select status from attachments where chat_id = '${chat.id}' and filename = 's3down-${runId}.png'`, ), - ).toBe('1'); + ).toBe('deleting'); } finally { await compose('start', s3Service); } @@ -966,18 +967,27 @@ describe.skipIf(!enabled)('dependency outages', () => { const after = await upload(samplePng, `s3after-${runId}.png`); expect(after.response.status).toBe(201); - const filter = `chat_id = '${chat.id}' and status = 'pending' and filename = 's3down-${runId}.png'`; - await waitUntilExpired(filter); - await sweepNow(); - expect( - await psql(`select count(*) from attachments where ${filter}`), - ).toBe('0'); + // A `deleting` row is re-claimed one minute after its last change + // (an in-flight compensation is never raced), then swept. + const filter = `chat_id = '${chat.id}' and filename = 's3down-${runId}.png'`; + await waitFor( + async () => { + await sweepNow(); + return ( + (await psql( + `select count(*) from attachments where ${filter}`, + )) === '0' + ); + }, + async () => 'deleting row was not swept', + 90_000, + ); }, outagedRequestBudgetMs, ); it( - 'compensates the S3 write when PostgreSQL fails before ready', + 'keeps the object while PostgreSQL is down before ready and sweeps it afterwards', async () => { const data = noisePng(1024 * 1024); const filename = `pgfault-${runId}.png`; @@ -1017,13 +1027,16 @@ describe.skipIf(!enabled)('dependency outages', () => { `select object_key from attachments where ${filter}`, ); expect(key).toMatch(/^attachments\/[0-9a-f-]{36}\/original$/u); - expect(await objectExists(key)).toBe(false); + // Without PostgreSQL the API cannot tell a lost commit from a failed + // one, so it deletes nothing; the pending row keeps the object tracked. + expect(await objectExists(key)).toBe(true); await waitUntilExpired(filter); await sweepNow(); expect( await psql(`select count(*) from attachments where ${filter}`), ).toBe('0'); + expect(await objectExists(key)).toBe(false); }, outagedRequestBudgetMs, ); diff --git a/app/test/direct-upload.e2e-spec.ts b/app/test/direct-upload.e2e-spec.ts index f448dae..0411595 100644 --- a/app/test/direct-upload.e2e-spec.ts +++ b/app/test/direct-upload.e2e-spec.ts @@ -18,7 +18,7 @@ import { json, postMessage, } from './support/e2e.js'; -import { pixelBombPng } from './support/png.js'; +import { noisePng, pixelBombPng } from './support/png.js'; const png = readFileSync( new URL('../../tests/fixtures/sample.png', import.meta.url), @@ -243,6 +243,34 @@ describe('direct upload (presigned PUT)', () => { ); }); + it.each([ + ['truncated PNG', () => png.subarray(0, png.length - 100)], + [ + 'PNG damaged after the first 64 KiB', + () => { + const data = noisePng(1_048_576); + data[700_000] ^= 0xff; + return data; + }, + ], + ])('rejects a %s even with a matching checksum', async (_name, make) => { + // The declaration and the signed checksum match the bytes exactly: + // only a check of the whole image can tell they are not an image. + const data = make(); + const ticket = await initOk(data); + expect((await put(ticket, data)).status).toBe(200); + expectError( + await complete(alice.token, ticket.attachment_id), + 415, + 'unsupported_media_type', + ); + expectError( + await complete(alice.token, ticket.attachment_id), + 404, + 'not_found', + ); + }); + it('rejects a pixel bomb on complete', async () => { const bomb = pixelBombPng(); const ticket = await initOk(bomb); diff --git a/app/test/support/jpeg.ts b/app/test/support/jpeg.ts new file mode 100644 index 0000000..ea60571 --- /dev/null +++ b/app/test/support/jpeg.ts @@ -0,0 +1,10 @@ +/** Keeps every segment through the SOS header and drops the scan data. */ +export function jpegWithoutScanData(jpeg: Buffer): Buffer { + let offset = 2; + for (;;) { + const marker = jpeg[offset + 1]; + offset += 2 + jpeg.readUInt16BE(offset + 2); + if (marker === 0xda) break; + } + return Buffer.concat([jpeg.subarray(0, offset), Buffer.from([0xff, 0xd9])]); +} diff --git a/app/test/support/png.ts b/app/test/support/png.ts index 9dd29a4..714ce8a 100644 --- a/app/test/support/png.ts +++ b/app/test/support/png.ts @@ -93,3 +93,14 @@ export function noisePng(size: number): Buffer { return padPngTo(png, size); } } + +/** Valid signature, IHDR, CRCs and IEND around a zlib stream of random bytes. */ +export function pngWithGarbageIdat(): Buffer { + return buildPng({ + width: 320, + height: 200, + colorType: 2, + bitDepth: 8, + idat: randomBytes(5000), + }); +} diff --git a/evidence/lab4/bench/direct-1048576-c10.json b/evidence/lab4/bench/direct-1048576-c10.json index e6f9e3f..3ea6569 100644 --- a/evidence/lab4/bench/direct-1048576-c10.json +++ b/evidence/lab4/bench/direct-1048576-c10.json @@ -1,6 +1,6 @@ { - "date": "2026-10-22T20:02:21+00:00", - "git": "f048a37", + "date": "2026-10-23T13:32:53+00:00", + "git": "b32ce9a", "params": { "mode": "direct", "size_bytes": 1048576, @@ -21,187 +21,193 @@ "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 0.542, + "duration_s": 0.939, "latency_ms": { - "p50": 69.2, - "p95": 101.4, - "p99": 125.5 + "p50": 168.0, + "p95": 249.0, + "p99": 276.8 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 1732876, - "delta_tx_bytes": 185102, - "baseline_rss_bytes": 192851968, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 32727785, + "delta_tx_bytes": 202005, + "baseline_rss_bytes": 227401728, "peak_memory_bytes": { - "rss": 192983040, - "heap_used": 51764168, - "external": 7874039, - "array_buffers": 4083695 + "rss": 237686784, + "heap_used": 55834912, + "external": 36616919, + "array_buffers": 32826575 }, - "delta_rss_bytes": 131072, + "delta_rss_bytes": 10285056, "counters": { - "attachments.count_pending_direct": 26, - "attachments.insert_pending": 26, - "attachments.direct.initiated": 26, - "attachments.find_for_complete": 24, - "attachments.direct.verify_bytes": 1572864, - "attachments.mark_ready": 24, - "attachments.direct.completed": 24 + "attachments.count_pending_direct": 19, + "attachments.insert_pending": 19, + "attachments.direct.initiated": 19, + "attachments.find_for_complete": 31, + "attachments.direct.verify_bytes": 32505856, + "attachments.decode.ms": 1715.4081129999686, + "attachments.mark_ready": 31, + "attachments.direct.completed": 31 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 1868893, - "delta_tx_bytes": 186494, - "baseline_rss_bytes": 181489664, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 20096072, + "delta_tx_bytes": 188541, + "baseline_rss_bytes": 215158784, "peak_memory_bytes": { - "rss": 182013952, - "heap_used": 53099792, - "external": 7642630, - "array_buffers": 3852254 + "rss": 219668480, + "heap_used": 53068512, + "external": 26447857, + "array_buffers": 22657513 }, - "delta_rss_bytes": 524288, + "delta_rss_bytes": 4509696, + "counters": { + "attachments.count_pending_direct": 31, + "attachments.insert_pending": 31, + "attachments.direct.initiated": 31, + "attachments.find_for_complete": 19, + "attachments.direct.verify_bytes": 19922944, + "attachments.decode.ms": 711.329723999952, + "attachments.mark_ready": 19, + "attachments.direct.completed": 19 + } + } + ], + "total_delta_rx_bytes": 52823857, + "total_delta_tx_bytes": 390546, + "rx_bytes_per_upload": 1056477, + "tx_bytes_per_upload": 7811, + "max_delta_rss_bytes": 10285056 + }, + { + "uploads": 50, + "succeeded": 50, + "failed": 0, + "duration_s": 0.91, + "latency_ms": { + "p50": 151.5, + "p95": 258.3, + "p99": 269.0 + }, + "replicas": [ + { + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 27461632, + "delta_tx_bytes": 190483, + "baseline_rss_bytes": 235499520, + "peak_memory_bytes": { + "rss": 235499520, + "heap_used": 55890664, + "external": 36465919, + "array_buffers": 32675575 + }, + "delta_rss_bytes": 0, "counters": { "attachments.count_pending_direct": 24, "attachments.insert_pending": 24, "attachments.direct.initiated": 24, "attachments.find_for_complete": 26, - "attachments.direct.verify_bytes": 1703936, + "attachments.direct.verify_bytes": 27262976, + "attachments.decode.ms": 1528.2079319999611, "attachments.mark_ready": 26, "attachments.direct.completed": 26 } + }, + { + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 25359054, + "delta_tx_bytes": 191385, + "baseline_rss_bytes": 209186816, + "peak_memory_bytes": { + "rss": 224399360, + "heap_used": 55409152, + "external": 31990072, + "array_buffers": 25029140 + }, + "delta_rss_bytes": 15212544, + "counters": { + "attachments.count_pending_direct": 26, + "attachments.insert_pending": 26, + "attachments.direct.initiated": 26, + "attachments.find_for_complete": 24, + "attachments.direct.verify_bytes": 25165824, + "attachments.decode.ms": 1024.5066690000385, + "attachments.mark_ready": 24, + "attachments.direct.completed": 24 + } } ], - "total_delta_rx_bytes": 3601769, - "total_delta_tx_bytes": 371596, - "rx_bytes_per_upload": 72035, - "tx_bytes_per_upload": 7432, - "max_delta_rss_bytes": 524288 + "total_delta_rx_bytes": 52820686, + "total_delta_tx_bytes": 381868, + "rx_bytes_per_upload": 1056414, + "tx_bytes_per_upload": 7637, + "max_delta_rss_bytes": 15212544 }, { "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 0.685, + "duration_s": 0.936, "latency_ms": { - "p50": 111.1, - "p95": 137.0, - "p99": 142.2 + "p50": 164.5, + "p95": 215.8, + "p99": 221.0 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 1800815, - "delta_tx_bytes": 186876, - "baseline_rss_bytes": 192983040, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 27463159, + "delta_tx_bytes": 187686, + "baseline_rss_bytes": 226234368, "peak_memory_bytes": { - "rss": 193507328, - "heap_used": 51579728, - "external": 6754919, - "array_buffers": 2800370 + "rss": 231608320, + "heap_used": 55751432, + "external": 34449311, + "array_buffers": 30658967 }, - "delta_rss_bytes": 524288, + "delta_rss_bytes": 5373952, "counters": { - "attachments.count_pending_direct": 25, - "attachments.insert_pending": 25, - "attachments.direct.initiated": 25, - "attachments.find_for_complete": 25, - "attachments.direct.verify_bytes": 1638400, - "attachments.mark_ready": 25, - "attachments.direct.completed": 25 + "attachments.count_pending_direct": 24, + "attachments.insert_pending": 24, + "attachments.direct.initiated": 24, + "attachments.find_for_complete": 26, + "attachments.direct.verify_bytes": 27262976, + "attachments.decode.ms": 975.2134359999909, + "attachments.mark_ready": 26, + "attachments.direct.completed": 26 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 1800709, - "delta_tx_bytes": 185964, - "baseline_rss_bytes": 182013952, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 25357194, + "delta_tx_bytes": 186994, + "baseline_rss_bytes": 223174656, "peak_memory_bytes": { - "rss": 182800384, - "heap_used": 53017320, - "external": 7914245, - "array_buffers": 4123869 + "rss": 225120256, + "heap_used": 53461888, + "external": 29769942, + "array_buffers": 25979406 }, - "delta_rss_bytes": 786432, + "delta_rss_bytes": 1945600, "counters": { - "attachments.count_pending_direct": 25, - "attachments.insert_pending": 25, - "attachments.direct.initiated": 25, - "attachments.find_for_complete": 25, - "attachments.direct.verify_bytes": 1638400, - "attachments.mark_ready": 25, - "attachments.direct.completed": 25 + "attachments.count_pending_direct": 26, + "attachments.insert_pending": 26, + "attachments.direct.initiated": 26, + "attachments.find_for_complete": 24, + "attachments.direct.verify_bytes": 25165824, + "attachments.decode.ms": 805.6966420000099, + "attachments.mark_ready": 24, + "attachments.direct.completed": 24 } } ], - "total_delta_rx_bytes": 3601524, - "total_delta_tx_bytes": 372840, - "rx_bytes_per_upload": 72030, - "tx_bytes_per_upload": 7457, - "max_delta_rss_bytes": 786432 - }, - { - "uploads": 50, - "succeeded": 50, - "failed": 0, - "duration_s": 0.552, - "latency_ms": { - "p50": 75.4, - "p95": 147.0, - "p99": 157.9 - }, - "replicas": [ - { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 1801291, - "delta_tx_bytes": 185886, - "baseline_rss_bytes": 193396736, - "peak_memory_bytes": { - "rss": 194314240, - "heap_used": 52852056, - "external": 6737214, - "array_buffers": 2946870 - }, - "delta_rss_bytes": 917504, - "counters": { - "attachments.count_pending_direct": 25, - "attachments.insert_pending": 25, - "attachments.direct.initiated": 25, - "attachments.find_for_complete": 25, - "attachments.direct.verify_bytes": 1638400, - "attachments.mark_ready": 25, - "attachments.direct.completed": 25 - } - }, - { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 1800711, - "delta_tx_bytes": 185106, - "baseline_rss_bytes": 182374400, - "peak_memory_bytes": { - "rss": 182374400, - "heap_used": 53283160, - "external": 7898022, - "array_buffers": 3970019 - }, - "delta_rss_bytes": 0, - "counters": { - "attachments.count_pending_direct": 25, - "attachments.insert_pending": 25, - "attachments.direct.initiated": 25, - "attachments.find_for_complete": 25, - "attachments.direct.verify_bytes": 1638400, - "attachments.mark_ready": 25, - "attachments.direct.completed": 25 - } - } - ], - "total_delta_rx_bytes": 3602002, - "total_delta_tx_bytes": 370992, - "rx_bytes_per_upload": 72040, - "tx_bytes_per_upload": 7420, - "max_delta_rss_bytes": 917504 + "total_delta_rx_bytes": 52820353, + "total_delta_tx_bytes": 374680, + "rx_bytes_per_upload": 1056407, + "tx_bytes_per_upload": 7494, + "max_delta_rss_bytes": 5373952 } ] } diff --git a/evidence/lab4/bench/direct-131072-c10.json b/evidence/lab4/bench/direct-131072-c10.json index 7c42ee9..5563c6b 100644 --- a/evidence/lab4/bench/direct-131072-c10.json +++ b/evidence/lab4/bench/direct-131072-c10.json @@ -1,6 +1,6 @@ { - "date": "2026-10-22T20:02:09+00:00", - "git": "f048a37", + "date": "2026-10-23T13:32:40+00:00", + "git": "b32ce9a", "params": { "mode": "direct", "size_bytes": 131072, @@ -21,85 +21,87 @@ "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 0.242, + "duration_s": 0.421, "latency_ms": { - "p50": 43.2, - "p95": 56.1, - "p99": 59.7 + "p50": 68.3, + "p95": 104.0, + "p99": 117.0 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 1869074, - "delta_tx_bytes": 185920, - "baseline_rss_bytes": 182263808, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 3707052, + "delta_tx_bytes": 186917, + "baseline_rss_bytes": 193892352, "peak_memory_bytes": { - "rss": 182898688, - "heap_used": 53275328, - "external": 9220810, - "array_buffers": 5428348 + "rss": 195555328, + "heap_used": 52983040, + "external": 6914994, + "array_buffers": 3122532 }, - "delta_rss_bytes": 634880, + "delta_rss_bytes": 1662976, "counters": { - "attachments.count_pending_direct": 24, - "attachments.insert_pending": 24, - "attachments.direct.initiated": 24, - "attachments.find_for_complete": 26, - "attachments.direct.verify_bytes": 1703936, - "attachments.mark_ready": 26, - "attachments.direct.completed": 26 + "attachments.count_pending_direct": 23, + "attachments.insert_pending": 23, + "attachments.direct.initiated": 23, + "attachments.find_for_complete": 27, + "attachments.direct.verify_bytes": 3538944, + "attachments.decode.ms": 666.184485999991, + "attachments.mark_ready": 27, + "attachments.direct.completed": 27 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 1732185, - "delta_tx_bytes": 183862, - "baseline_rss_bytes": 173453312, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 3172669, + "delta_tx_bytes": 183467, + "baseline_rss_bytes": 194297856, "peak_memory_bytes": { - "rss": 173862912, - "heap_used": 51776512, - "external": 7372259, - "array_buffers": 3579797 + "rss": 196395008, + "heap_used": 53364080, + "external": 9480998, + "array_buffers": 5688536 }, - "delta_rss_bytes": 409600, + "delta_rss_bytes": 2097152, "counters": { - "attachments.count_pending_direct": 26, - "attachments.insert_pending": 26, - "attachments.direct.initiated": 26, - "attachments.find_for_complete": 24, - "attachments.direct.verify_bytes": 1572864, - "attachments.mark_ready": 24, - "attachments.direct.completed": 24 + "attachments.count_pending_direct": 27, + "attachments.insert_pending": 27, + "attachments.direct.initiated": 27, + "attachments.find_for_complete": 23, + "attachments.direct.verify_bytes": 3014656, + "attachments.decode.ms": 578.859613999979, + "attachments.mark_ready": 23, + "attachments.direct.completed": 23 } } ], - "total_delta_rx_bytes": 3601259, - "total_delta_tx_bytes": 369782, - "rx_bytes_per_upload": 72025, - "tx_bytes_per_upload": 7396, - "max_delta_rss_bytes": 634880 + "total_delta_rx_bytes": 6879721, + "total_delta_tx_bytes": 370384, + "rx_bytes_per_upload": 137594, + "tx_bytes_per_upload": 7408, + "max_delta_rss_bytes": 2097152 }, { "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 0.254, + "duration_s": 0.419, "latency_ms": { - "p50": 44.9, - "p95": 64.9, - "p99": 74.0 + "p50": 78.9, + "p95": 123.4, + "p99": 144.3 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 1663798, - "delta_tx_bytes": 181411, - "baseline_rss_bytes": 182898688, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 3172151, + "delta_tx_bytes": 182160, + "baseline_rss_bytes": 195555328, "peak_memory_bytes": { - "rss": 183029760, - "heap_used": 52623040, - "external": 9199397, - "array_buffers": 5406935 + "rss": 195686400, + "heap_used": 55040192, + "external": 7674854, + "array_buffers": 3882392 }, "delta_rss_bytes": 131072, "counters": { @@ -107,101 +109,105 @@ "attachments.insert_pending": 27, "attachments.direct.initiated": 27, "attachments.find_for_complete": 23, - "attachments.direct.verify_bytes": 1507328, + "attachments.direct.verify_bytes": 3014656, + "attachments.decode.ms": 521.6287550000125, "attachments.mark_ready": 23, "attachments.direct.completed": 23 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 1936597, - "delta_tx_bytes": 185873, - "baseline_rss_bytes": 173862912, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 3706567, + "delta_tx_bytes": 185794, + "baseline_rss_bytes": 196395008, "peak_memory_bytes": { - "rss": 174125056, - "heap_used": 53719328, - "external": 7649562, - "array_buffers": 3857100 + "rss": 196788224, + "heap_used": 53658784, + "external": 10141571, + "array_buffers": 6134972 }, - "delta_rss_bytes": 262144, + "delta_rss_bytes": 393216, "counters": { "attachments.count_pending_direct": 23, "attachments.insert_pending": 23, "attachments.direct.initiated": 23, "attachments.find_for_complete": 27, - "attachments.direct.verify_bytes": 1769472, + "attachments.direct.verify_bytes": 3538944, + "attachments.decode.ms": 674.9609369999744, "attachments.mark_ready": 27, "attachments.direct.completed": 27 } } ], - "total_delta_rx_bytes": 3600395, - "total_delta_tx_bytes": 367284, - "rx_bytes_per_upload": 72008, - "tx_bytes_per_upload": 7346, - "max_delta_rss_bytes": 262144 + "total_delta_rx_bytes": 6878718, + "total_delta_tx_bytes": 367954, + "rx_bytes_per_upload": 137574, + "tx_bytes_per_upload": 7359, + "max_delta_rss_bytes": 393216 }, { "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 0.441, + "duration_s": 0.395, "latency_ms": { - "p50": 80.3, - "p95": 124.0, - "p99": 127.6 + "p50": 67.0, + "p95": 95.3, + "p99": 116.5 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 2007125, - "delta_tx_bytes": 186925, - "baseline_rss_bytes": 183029760, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 3305839, + "delta_tx_bytes": 183731, + "baseline_rss_bytes": 191291392, "peak_memory_bytes": { - "rss": 183447552, - "heap_used": 56507192, - "external": 9369635, - "array_buffers": 5577173 + "rss": 192471040, + "heap_used": 56329664, + "external": 7513663, + "array_buffers": 3721201 }, - "delta_rss_bytes": 417792, + "delta_rss_bytes": 1179648, "counters": { - "attachments.count_pending_direct": 22, - "attachments.insert_pending": 22, - "attachments.direct.initiated": 22, - "attachments.find_for_complete": 28, - "attachments.direct.verify_bytes": 1835008, - "attachments.mark_ready": 28, - "attachments.direct.completed": 28 + "attachments.count_pending_direct": 26, + "attachments.insert_pending": 26, + "attachments.direct.initiated": 26, + "attachments.find_for_complete": 24, + "attachments.direct.verify_bytes": 3145728, + "attachments.decode.ms": 499.52755800001614, + "attachments.mark_ready": 24, + "attachments.direct.completed": 24 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 1596449, - "delta_tx_bytes": 182757, - "baseline_rss_bytes": 174125056, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 3572208, + "delta_tx_bytes": 183605, + "baseline_rss_bytes": 196788224, "peak_memory_bytes": { - "rss": 174387200, - "heap_used": 54337704, - "external": 7649635, - "array_buffers": 3857173 + "rss": 197181440, + "heap_used": 55084856, + "external": 7691196, + "array_buffers": 3898734 }, - "delta_rss_bytes": 262144, + "delta_rss_bytes": 393216, "counters": { - "attachments.count_pending_direct": 28, - "attachments.insert_pending": 28, - "attachments.direct.initiated": 28, - "attachments.find_for_complete": 22, - "attachments.direct.verify_bytes": 1441792, - "attachments.mark_ready": 22, - "attachments.direct.completed": 22 + "attachments.count_pending_direct": 24, + "attachments.insert_pending": 24, + "attachments.direct.initiated": 24, + "attachments.find_for_complete": 26, + "attachments.direct.verify_bytes": 3407872, + "attachments.decode.ms": 667.7248300000065, + "attachments.mark_ready": 26, + "attachments.direct.completed": 26 } } ], - "total_delta_rx_bytes": 3603574, - "total_delta_tx_bytes": 369682, - "rx_bytes_per_upload": 72071, - "tx_bytes_per_upload": 7394, - "max_delta_rss_bytes": 417792 + "total_delta_rx_bytes": 6878047, + "total_delta_tx_bytes": 367336, + "rx_bytes_per_upload": 137561, + "tx_bytes_per_upload": 7347, + "max_delta_rss_bytes": 1179648 } ] } diff --git a/evidence/lab4/bench/direct-9961472-c10.json b/evidence/lab4/bench/direct-9961472-c10.json index a06e0b5..fc84204 100644 --- a/evidence/lab4/bench/direct-9961472-c10.json +++ b/evidence/lab4/bench/direct-9961472-c10.json @@ -1,6 +1,6 @@ { - "date": "2026-10-22T20:02:47+00:00", - "git": "f048a37", + "date": "2026-10-23T13:33:31+00:00", + "git": "b32ce9a", "params": { "mode": "direct", "size_bytes": 9961472, @@ -21,23 +21,174 @@ "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 3.048, + "duration_s": 5.212, "latency_ms": { - "p50": 346.0, - "p95": 575.3, - "p99": 581.2 + "p50": 693.0, + "p95": 1084.0, + "p99": 1175.0 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 1669140, - "delta_tx_bytes": 194261, - "baseline_rss_bytes": 189468672, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 269480509, + "delta_tx_bytes": 305993, + "baseline_rss_bytes": 283983872, "peak_memory_bytes": { - "rss": 189468672, - "heap_used": 59441184, - "external": 6250789, - "array_buffers": 2449996 + "rss": 404570112, + "heap_used": 50680344, + "external": 123548186, + "array_buffers": 119757842 + }, + "delta_rss_bytes": 120586240, + "counters": { + "attachments.count_pending_direct": 23, + "attachments.insert_pending": 23, + "attachments.direct.initiated": 23, + "attachments.find_for_complete": 27, + "attachments.direct.verify_bytes": 268959744, + "attachments.decode.ms": 6438.860078999976, + "attachments.mark_ready": 27, + "attachments.direct.completed": 27 + } + }, + { + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 229561819, + "delta_tx_bytes": 313227, + "baseline_rss_bytes": 328466432, + "peak_memory_bytes": { + "rss": 385613824, + "heap_used": 52894936, + "external": 114148298, + "array_buffers": 110357821 + }, + "delta_rss_bytes": 57147392, + "counters": { + "attachments.count_pending_direct": 27, + "attachments.insert_pending": 27, + "attachments.direct.initiated": 27, + "attachments.find_for_complete": 23, + "attachments.direct.verify_bytes": 229113856, + "attachments.decode.ms": 5666.515076999989, + "attachments.mark_ready": 23, + "attachments.direct.completed": 23 + } + } + ], + "total_delta_rx_bytes": 499042328, + "total_delta_tx_bytes": 619220, + "rx_bytes_per_upload": 9980847, + "tx_bytes_per_upload": 12384, + "max_delta_rss_bytes": 120586240 + }, + { + "uploads": 50, + "succeeded": 50, + "failed": 0, + "duration_s": 4.689, + "latency_ms": { + "p50": 668.9, + "p95": 1081.6, + "p99": 1164.9 + }, + "replicas": [ + { + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 249519521, + "delta_tx_bytes": 283986, + "baseline_rss_bytes": 324087808, + "peak_memory_bytes": { + "rss": 408424448, + "heap_used": 51009296, + "external": 126698352, + "array_buffers": 122908008 + }, + "delta_rss_bytes": 84336640, + "counters": { + "attachments.count_pending_direct": 25, + "attachments.insert_pending": 25, + "attachments.direct.initiated": 25, + "attachments.find_for_complete": 25, + "attachments.direct.verify_bytes": 249036800, + "attachments.decode.ms": 6319.900557000001, + "attachments.mark_ready": 25, + "attachments.direct.completed": 25 + } + }, + { + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 249503096, + "delta_tx_bytes": 276564, + "baseline_rss_bytes": 320462848, + "peak_memory_bytes": { + "rss": 388620288, + "heap_used": 50687792, + "external": 135613815, + "array_buffers": 131823471 + }, + "delta_rss_bytes": 68157440, + "counters": { + "attachments.count_pending_direct": 25, + "attachments.insert_pending": 25, + "attachments.direct.initiated": 25, + "attachments.find_for_complete": 25, + "attachments.direct.verify_bytes": 249036800, + "attachments.decode.ms": 6777.923052999977, + "attachments.mark_ready": 25, + "attachments.direct.completed": 25 + } + } + ], + "total_delta_rx_bytes": 499022617, + "total_delta_tx_bytes": 560550, + "rx_bytes_per_upload": 9980452, + "tx_bytes_per_upload": 11211, + "max_delta_rss_bytes": 84336640 + }, + { + "uploads": 50, + "succeeded": 50, + "failed": 0, + "duration_s": 4.773, + "latency_ms": { + "p50": 695.7, + "p95": 1021.4, + "p99": 1371.6 + }, + "replicas": [ + { + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 269526599, + "delta_tx_bytes": 273432, + "baseline_rss_bytes": 303702016, + "peak_memory_bytes": { + "rss": 389439488, + "heap_used": 50333808, + "external": 124077219, + "array_buffers": 120286875 + }, + "delta_rss_bytes": 85737472, + "counters": { + "attachments.count_pending_direct": 23, + "attachments.insert_pending": 23, + "attachments.direct.initiated": 23, + "attachments.find_for_complete": 27, + "attachments.direct.verify_bytes": 268959744, + "attachments.decode.ms": 7513.258526999998, + "attachments.mark_ready": 27, + "attachments.direct.completed": 27 + } + }, + { + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 229549332, + "delta_tx_bytes": 263832, + "baseline_rss_bytes": 367620096, + "peak_memory_bytes": { + "rss": 367620096, + "heap_used": 50715496, + "external": 84222677, + "array_buffers": 80432333 }, "delta_rss_bytes": 0, "counters": { @@ -45,163 +196,18 @@ "attachments.insert_pending": 27, "attachments.direct.initiated": 27, "attachments.find_for_complete": 23, - "attachments.direct.verify_bytes": 1507328, + "attachments.direct.verify_bytes": 229113856, + "attachments.decode.ms": 6132.513337000011, "attachments.mark_ready": 23, "attachments.direct.completed": 23 } - }, - { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 1940713, - "delta_tx_bytes": 195885, - "baseline_rss_bytes": 179376128, - "peak_memory_bytes": { - "rss": 180293632, - "heap_used": 59568768, - "external": 6672150, - "array_buffers": 2881806 - }, - "delta_rss_bytes": 917504, - "counters": { - "attachments.count_pending_direct": 23, - "attachments.insert_pending": 23, - "attachments.direct.initiated": 23, - "attachments.find_for_complete": 27, - "attachments.direct.verify_bytes": 1769472, - "attachments.mark_ready": 27, - "attachments.direct.completed": 27 - } } ], - "total_delta_rx_bytes": 3609853, - "total_delta_tx_bytes": 390146, - "rx_bytes_per_upload": 72197, - "tx_bytes_per_upload": 7803, - "max_delta_rss_bytes": 917504 - }, - { - "uploads": 50, - "succeeded": 50, - "failed": 0, - "duration_s": 2.948, - "latency_ms": { - "p50": 350.2, - "p95": 570.8, - "p99": 608.6 - }, - "replicas": [ - { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 1803498, - "delta_tx_bytes": 194370, - "baseline_rss_bytes": 189468672, - "peak_memory_bytes": { - "rss": 189861888, - "heap_used": 59295328, - "external": 6363945, - "array_buffers": 2573569 - }, - "delta_rss_bytes": 393216, - "counters": { - "attachments.count_pending_direct": 25, - "attachments.insert_pending": 25, - "attachments.direct.initiated": 25, - "attachments.find_for_complete": 25, - "attachments.direct.verify_bytes": 1638400, - "attachments.mark_ready": 25, - "attachments.direct.completed": 25 - } - }, - { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 1804525, - "delta_tx_bytes": 194742, - "baseline_rss_bytes": 179740672, - "peak_memory_bytes": { - "rss": 179740672, - "heap_used": 59420128, - "external": 6260844, - "array_buffers": 2470500 - }, - "delta_rss_bytes": 0, - "counters": { - "attachments.count_pending_direct": 25, - "attachments.insert_pending": 25, - "attachments.direct.initiated": 25, - "attachments.find_for_complete": 25, - "attachments.direct.verify_bytes": 1638400, - "attachments.mark_ready": 25, - "attachments.direct.completed": 25 - } - } - ], - "total_delta_rx_bytes": 3608023, - "total_delta_tx_bytes": 389112, - "rx_bytes_per_upload": 72160, - "tx_bytes_per_upload": 7782, - "max_delta_rss_bytes": 393216 - }, - { - "uploads": 50, - "succeeded": 50, - "failed": 0, - "duration_s": 2.556, - "latency_ms": { - "p50": 314.1, - "p95": 425.2, - "p99": 453.1 - }, - "replicas": [ - { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 1531515, - "delta_tx_bytes": 190497, - "baseline_rss_bytes": 189861888, - "peak_memory_bytes": { - "rss": 190910464, - "heap_used": 60034376, - "external": 6373249, - "array_buffers": 2582873 - }, - "delta_rss_bytes": 1048576, - "counters": { - "attachments.count_pending_direct": 29, - "attachments.insert_pending": 29, - "attachments.direct.initiated": 29, - "attachments.find_for_complete": 21, - "attachments.direct.verify_bytes": 1376256, - "attachments.mark_ready": 21, - "attachments.direct.completed": 21 - } - }, - { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 2076238, - "delta_tx_bytes": 196531, - "baseline_rss_bytes": 179740672, - "peak_memory_bytes": { - "rss": 179740672, - "heap_used": 59642168, - "external": 6672708, - "array_buffers": 2755498 - }, - "delta_rss_bytes": 0, - "counters": { - "attachments.count_pending_direct": 21, - "attachments.insert_pending": 21, - "attachments.direct.initiated": 21, - "attachments.find_for_complete": 29, - "attachments.direct.verify_bytes": 1900544, - "attachments.mark_ready": 29, - "attachments.direct.completed": 29 - } - } - ], - "total_delta_rx_bytes": 3607753, - "total_delta_tx_bytes": 387028, - "rx_bytes_per_upload": 72155, - "tx_bytes_per_upload": 7741, - "max_delta_rss_bytes": 1048576 + "total_delta_rx_bytes": 499075931, + "total_delta_tx_bytes": 537264, + "rx_bytes_per_upload": 9981519, + "tx_bytes_per_upload": 10745, + "max_delta_rss_bytes": 85737472 } ] } diff --git a/evidence/lab4/bench/proxy-1048576-c10.json b/evidence/lab4/bench/proxy-1048576-c10.json index 603094f..ea636ea 100644 --- a/evidence/lab4/bench/proxy-1048576-c10.json +++ b/evidence/lab4/bench/proxy-1048576-c10.json @@ -1,6 +1,6 @@ { - "date": "2026-10-22T20:02:15+00:00", - "git": "f048a37", + "date": "2026-10-23T13:32:46+00:00", + "git": "b32ce9a", "params": { "mode": "proxy", "size_bytes": 1048576, @@ -21,175 +21,181 @@ "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 0.369, + "duration_s": 0.854, "latency_ms": { - "p50": 46.4, - "p95": 68.3, - "p99": 72.8 + "p50": 142.8, + "p95": 192.1, + "p99": 208.3 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 26390991, - "delta_tx_bytes": 26399463, - "baseline_rss_bytes": 183496704, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 26385133, + "delta_tx_bytes": 26401283, + "baseline_rss_bytes": 197070848, "peak_memory_bytes": { - "rss": 188407808, - "heap_used": 58350032, - "external": 15612927, - "array_buffers": 11820465 + "rss": 217759744, + "heap_used": 55062960, + "external": 22455454, + "array_buffers": 18665110 }, - "delta_rss_bytes": 4911104, + "delta_rss_bytes": 20688896, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 26214400, + "attachments.decode.ms": 1479.7760639999906, "attachments.proxy.bytes_to_s3": 26214400, "attachments.mark_ready": 25, "attachments.upload.created": 25 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 26389902, - "delta_tx_bytes": 26401063, - "baseline_rss_bytes": 172593152, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 26379459, + "delta_tx_bytes": 26398957, + "baseline_rss_bytes": 199708672, "peak_memory_bytes": { - "rss": 179159040, - "heap_used": 51726640, - "external": 10983870, - "array_buffers": 7191408 + "rss": 214302720, + "heap_used": 55570040, + "external": 24543846, + "array_buffers": 20174104 }, - "delta_rss_bytes": 6565888, + "delta_rss_bytes": 14594048, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 26214400, + "attachments.decode.ms": 1331.2164019999764, "attachments.proxy.bytes_to_s3": 26214400, "attachments.mark_ready": 25, "attachments.upload.created": 25 } } ], - "total_delta_rx_bytes": 52780893, - "total_delta_tx_bytes": 52800526, - "rx_bytes_per_upload": 1055618, - "tx_bytes_per_upload": 1056011, - "max_delta_rss_bytes": 6565888 + "total_delta_rx_bytes": 52764592, + "total_delta_tx_bytes": 52800240, + "rx_bytes_per_upload": 1055292, + "tx_bytes_per_upload": 1056005, + "max_delta_rss_bytes": 20688896 }, { "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 0.55, + "duration_s": 0.82, "latency_ms": { - "p50": 59.3, - "p95": 210.6, - "p99": 226.6 + "p50": 137.2, + "p95": 181.4, + "p99": 245.1 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 26377432, - "delta_tx_bytes": 26403430, - "baseline_rss_bytes": 188645376, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 26381801, + "delta_tx_bytes": 26401373, + "baseline_rss_bytes": 217759744, "peak_memory_bytes": { - "rss": 193232896, - "heap_used": 52490432, - "external": 19098493, - "array_buffers": 15306617 + "rss": 220250112, + "heap_used": 50014112, + "external": 24298087, + "array_buffers": 20507743 }, - "delta_rss_bytes": 4587520, + "delta_rss_bytes": 2490368, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 26214400, + "attachments.decode.ms": 1444.9002450000553, "attachments.proxy.bytes_to_s3": 26214400, "attachments.mark_ready": 25, "attachments.upload.created": 25 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 26383216, - "delta_tx_bytes": 26401660, - "baseline_rss_bytes": 179159040, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 26383381, + "delta_tx_bytes": 26401803, + "baseline_rss_bytes": 209428480, "peak_memory_bytes": { - "rss": 179486720, - "heap_used": 49462912, - "external": 15506324, - "array_buffers": 11714604 + "rss": 212426752, + "heap_used": 49637440, + "external": 21932135, + "array_buffers": 18141791 }, - "delta_rss_bytes": 327680, + "delta_rss_bytes": 2998272, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 26214400, + "attachments.decode.ms": 1494.1810810000025, "attachments.proxy.bytes_to_s3": 26214400, "attachments.mark_ready": 25, "attachments.upload.created": 25 } } ], - "total_delta_rx_bytes": 52760648, - "total_delta_tx_bytes": 52805090, - "rx_bytes_per_upload": 1055213, - "tx_bytes_per_upload": 1056102, - "max_delta_rss_bytes": 4587520 + "total_delta_rx_bytes": 52765182, + "total_delta_tx_bytes": 52803176, + "rx_bytes_per_upload": 1055304, + "tx_bytes_per_upload": 1056064, + "max_delta_rss_bytes": 2998272 }, { "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 0.461, + "duration_s": 0.818, "latency_ms": { - "p50": 67.3, - "p95": 109.8, - "p99": 118.7 + "p50": 146.1, + "p95": 209.1, + "p99": 245.9 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 26385813, - "delta_tx_bytes": 26399597, - "baseline_rss_bytes": 193232896, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 26379700, + "delta_tx_bytes": 26402387, + "baseline_rss_bytes": 216440832, "peak_memory_bytes": { - "rss": 194363392, - "heap_used": 51280880, - "external": 19455489, - "array_buffers": 15663613 + "rss": 229879808, + "heap_used": 52186344, + "external": 34161027, + "array_buffers": 30370683 }, - "delta_rss_bytes": 1130496, + "delta_rss_bytes": 13438976, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 26214400, + "attachments.decode.ms": 1491.96600400006, "attachments.proxy.bytes_to_s3": 26214400, "attachments.mark_ready": 25, "attachments.upload.created": 25 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 26391095, - "delta_tx_bytes": 26404143, - "baseline_rss_bytes": 178298880, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 26384562, + "delta_tx_bytes": 26402573, + "baseline_rss_bytes": 212082688, "peak_memory_bytes": { - "rss": 181444608, - "heap_used": 50462384, - "external": 17515725, - "array_buffers": 13659712 + "rss": 217251840, + "heap_used": 51036376, + "external": 26410042, + "array_buffers": 22619698 }, - "delta_rss_bytes": 3145728, + "delta_rss_bytes": 5169152, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 26214400, + "attachments.decode.ms": 1386.4965829999855, "attachments.proxy.bytes_to_s3": 26214400, "attachments.mark_ready": 25, "attachments.upload.created": 25 } } ], - "total_delta_rx_bytes": 52776908, - "total_delta_tx_bytes": 52803740, - "rx_bytes_per_upload": 1055538, - "tx_bytes_per_upload": 1056075, - "max_delta_rss_bytes": 3145728 + "total_delta_rx_bytes": 52764262, + "total_delta_tx_bytes": 52804960, + "rx_bytes_per_upload": 1055285, + "tx_bytes_per_upload": 1056099, + "max_delta_rss_bytes": 13438976 } ] } diff --git a/evidence/lab4/bench/proxy-131072-c10.json b/evidence/lab4/bench/proxy-131072-c10.json index 9b85fd7..84939c0 100644 --- a/evidence/lab4/bench/proxy-131072-c10.json +++ b/evidence/lab4/bench/proxy-131072-c10.json @@ -1,6 +1,6 @@ { - "date": "2026-10-22T20:02:04+00:00", - "git": "f048a37", + "date": "2026-10-23T13:32:35+00:00", + "git": "b32ce9a", "params": { "mode": "proxy", "size_bytes": 131072, @@ -21,175 +21,183 @@ "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 0.221, + "duration_s": 0.363, "latency_ms": { - "p50": 32.5, - "p95": 61.7, - "p99": 75.6 + "p50": 60.4, + "p95": 113.2, + "p99": 139.1 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 3382582, - "delta_tx_bytes": 3398177, - "baseline_rss_bytes": 172421120, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 3381618, + "delta_tx_bytes": 3399633, + "baseline_rss_bytes": 180125696, "peak_memory_bytes": { - "rss": 177926144, - "heap_used": 50033192, - "external": 7706616, - "array_buffers": 3914122 + "rss": 187985920, + "heap_used": 50414440, + "external": 8673461, + "array_buffers": 4505870 }, - "delta_rss_bytes": 5505024, + "delta_rss_bytes": 7860224, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 3276800, + "attachments.decode.ms": 528.2537349999984, "attachments.proxy.bytes_to_s3": 3276800, "attachments.mark_ready": 25, "attachments.upload.created": 25 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 3380734, - "delta_tx_bytes": 3397755, - "baseline_rss_bytes": 164986880, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 3384159, + "delta_tx_bytes": 3399409, + "baseline_rss_bytes": 181567488, "peak_memory_bytes": { - "rss": 170360832, - "heap_used": 49897896, - "external": 7704663, - "array_buffers": 3911977 + "rss": 189956096, + "heap_used": 51892912, + "external": 9517393, + "array_buffers": 5724803 }, - "delta_rss_bytes": 5373952, + "delta_rss_bytes": 8388608, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 3276800, + "attachments.decode.ms": 670.2341740000047, "attachments.proxy.bytes_to_s3": 3276800, "attachments.mark_ready": 25, "attachments.upload.created": 25 } } ], - "total_delta_rx_bytes": 6763316, - "total_delta_tx_bytes": 6795932, - "rx_bytes_per_upload": 135266, - "tx_bytes_per_upload": 135919, - "max_delta_rss_bytes": 5505024 + "total_delta_rx_bytes": 6765777, + "total_delta_tx_bytes": 6799042, + "rx_bytes_per_upload": 135316, + "tx_bytes_per_upload": 135981, + "max_delta_rss_bytes": 8388608 }, { "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 0.178, + "duration_s": 0.351, "latency_ms": { - "p50": 30.3, - "p95": 39.9, - "p99": 40.8 + "p50": 51.1, + "p95": 105.8, + "p99": 118.4 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 3378937, - "delta_tx_bytes": 3395467, - "baseline_rss_bytes": 177926144, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 3380483, + "delta_tx_bytes": 3398895, + "baseline_rss_bytes": 187985920, "peak_memory_bytes": { - "rss": 181886976, - "heap_used": 51028472, - "external": 10337544, - "array_buffers": 6545050 + "rss": 190345216, + "heap_used": 52699440, + "external": 10502334, + "array_buffers": 6709680 }, - "delta_rss_bytes": 3960832, + "delta_rss_bytes": 2359296, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 3276800, + "attachments.decode.ms": 633.1175999999905, "attachments.proxy.bytes_to_s3": 3276800, "attachments.mark_ready": 25, "attachments.upload.created": 25 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 3380009, - "delta_tx_bytes": 3397063, - "baseline_rss_bytes": 170360832, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 3376222, + "delta_tx_bytes": 3395913, + "baseline_rss_bytes": 189956096, "peak_memory_bytes": { - "rss": 171278336, - "heap_used": 50939136, - "external": 8430160, - "array_buffers": 4637666 + "rss": 193220608, + "heap_used": 52790776, + "external": 10858460, + "array_buffers": 7065998 }, - "delta_rss_bytes": 917504, + "delta_rss_bytes": 3264512, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 3276800, + "attachments.decode.ms": 359.4751439999891, "attachments.proxy.bytes_to_s3": 3276800, "attachments.mark_ready": 25, "attachments.upload.created": 25 } } ], - "total_delta_rx_bytes": 6758946, - "total_delta_tx_bytes": 6792530, - "rx_bytes_per_upload": 135179, - "tx_bytes_per_upload": 135851, - "max_delta_rss_bytes": 3960832 + "total_delta_rx_bytes": 6756705, + "total_delta_tx_bytes": 6794808, + "rx_bytes_per_upload": 135134, + "tx_bytes_per_upload": 135896, + "max_delta_rss_bytes": 3264512 }, { "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 0.291, + "duration_s": 0.354, "latency_ms": { - "p50": 41.2, - "p95": 87.2, - "p99": 93.6 + "p50": 60.3, + "p95": 96.3, + "p99": 120.9 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 3377137, - "delta_tx_bytes": 3395161, - "baseline_rss_bytes": 181886976, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 3377197, + "delta_tx_bytes": 3396754, + "baseline_rss_bytes": 190345216, "peak_memory_bytes": { - "rss": 182149120, - "heap_used": 51984832, - "external": 9554628, - "array_buffers": 5762166 + "rss": 193884160, + "heap_used": 53140928, + "external": 13245272, + "array_buffers": 9452618 }, - "delta_rss_bytes": 262144, + "delta_rss_bytes": 3538944, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 3276800, + "attachments.decode.ms": 518.702403999996, "attachments.proxy.bytes_to_s3": 3276800, "attachments.mark_ready": 25, - "attachments.upload.created": 25 + "attachments.upload.created": 25, + "attachments.claim_expired": 1 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 3377713, - "delta_tx_bytes": 3396473, - "baseline_rss_bytes": 171278336, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 3377745, + "delta_tx_bytes": 3397208, + "baseline_rss_bytes": 193220608, "peak_memory_bytes": { - "rss": 173244416, - "heap_used": 52256384, - "external": 10276505, - "array_buffers": 6484011 + "rss": 193744896, + "heap_used": 52880424, + "external": 11681352, + "array_buffers": 7888698 }, - "delta_rss_bytes": 1966080, + "delta_rss_bytes": 524288, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 3276800, + "attachments.decode.ms": 643.8722639999905, "attachments.proxy.bytes_to_s3": 3276800, "attachments.mark_ready": 25, - "attachments.upload.created": 25 + "attachments.upload.created": 25, + "attachments.claim_expired": 1 } } ], - "total_delta_rx_bytes": 6754850, - "total_delta_tx_bytes": 6791634, - "rx_bytes_per_upload": 135097, - "tx_bytes_per_upload": 135833, - "max_delta_rss_bytes": 1966080 + "total_delta_rx_bytes": 6754942, + "total_delta_tx_bytes": 6793962, + "rx_bytes_per_upload": 135099, + "tx_bytes_per_upload": 135879, + "max_delta_rss_bytes": 3538944 } ] } diff --git a/evidence/lab4/bench/proxy-9961472-c10.json b/evidence/lab4/bench/proxy-9961472-c10.json index 3965220..d41c413 100644 --- a/evidence/lab4/bench/proxy-9961472-c10.json +++ b/evidence/lab4/bench/proxy-9961472-c10.json @@ -1,6 +1,6 @@ { - "date": "2026-10-22T20:02:34+00:00", - "git": "f048a37", + "date": "2026-10-23T13:33:12+00:00", + "git": "b32ce9a", "params": { "mode": "proxy", "size_bytes": 9961472, @@ -21,177 +21,181 @@ "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 2.923, + "duration_s": 4.768, "latency_ms": { - "p50": 217.7, - "p95": 393.7, - "p99": 469.2 + "p50": 712.4, + "p95": 946.8, + "p99": 1012.6 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 249719999, - "delta_tx_bytes": 249864966, - "baseline_rss_bytes": 193277952, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 249658454, + "delta_tx_bytes": 249823407, + "baseline_rss_bytes": 252616704, "peak_memory_bytes": { - "rss": 208244736, - "heap_used": 49103680, - "external": 38092148, - "array_buffers": 31938886 + "rss": 364154880, + "heap_used": 49794104, + "external": 95705802, + "array_buffers": 78688662 }, - "delta_rss_bytes": 14966784, + "delta_rss_bytes": 111538176, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 249036800, + "attachments.decode.ms": 7843.138166000004, "attachments.proxy.bytes_to_s3": 249036800, "attachments.mark_ready": 25, "attachments.upload.created": 25 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 249670108, - "delta_tx_bytes": 249826185, - "baseline_rss_bytes": 178913280, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 249677855, + "delta_tx_bytes": 249819092, + "baseline_rss_bytes": 228974592, "peak_memory_bytes": { - "rss": 195375104, - "heap_used": 48823672, - "external": 30056217, - "array_buffers": 26265873 + "rss": 359043072, + "heap_used": 50979480, + "external": 105502404, + "array_buffers": 101712060 }, - "delta_rss_bytes": 16461824, + "delta_rss_bytes": 130068480, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 249036800, + "attachments.decode.ms": 7969.015626000037, "attachments.proxy.bytes_to_s3": 249036800, "attachments.mark_ready": 25, "attachments.upload.created": 25 } } ], - "total_delta_rx_bytes": 499390107, - "total_delta_tx_bytes": 499691151, - "rx_bytes_per_upload": 9987802, - "tx_bytes_per_upload": 9993823, - "max_delta_rss_bytes": 16461824 + "total_delta_rx_bytes": 499336309, + "total_delta_tx_bytes": 499642499, + "rx_bytes_per_upload": 9986726, + "tx_bytes_per_upload": 9992850, + "max_delta_rss_bytes": 130068480 }, { "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 3.32, + "duration_s": 4.843, "latency_ms": { - "p50": 277.4, - "p95": 513.9, - "p99": 548.1 + "p50": 687.8, + "p95": 997.1, + "p99": 1046.8 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 249653538, - "delta_tx_bytes": 249812864, - "baseline_rss_bytes": 193380352, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 249636288, + "delta_tx_bytes": 249801589, + "baseline_rss_bytes": 349237248, "peak_memory_bytes": { - "rss": 208535552, - "heap_used": 49665920, - "external": 36105007, - "array_buffers": 32313340 + "rss": 367636480, + "heap_used": 50033840, + "external": 85069927, + "array_buffers": 81278745 }, - "delta_rss_bytes": 15155200, + "delta_rss_bytes": 18399232, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 249036800, - "attachments.claim_expired": 1, + "attachments.decode.ms": 7391.692848000006, "attachments.proxy.bytes_to_s3": 249036800, "attachments.mark_ready": 25, "attachments.upload.created": 25 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 249644423, - "delta_tx_bytes": 249817785, - "baseline_rss_bytes": 194199552, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 249653773, + "delta_tx_bytes": 249814308, + "baseline_rss_bytes": 270807040, "peak_memory_bytes": { - "rss": 208871424, - "heap_used": 50742312, - "external": 43475182, - "array_buffers": 39684838 + "rss": 336084992, + "heap_used": 49357656, + "external": 85003828, + "array_buffers": 81213484 }, - "delta_rss_bytes": 14671872, + "delta_rss_bytes": 65277952, "counters": { "attachments.insert_pending": 25, - "attachments.claim_expired": 1, "attachments.proxy.bytes_in": 249036800, + "attachments.decode.ms": 7897.397337000031, "attachments.proxy.bytes_to_s3": 249036800, "attachments.mark_ready": 25, "attachments.upload.created": 25 } } ], - "total_delta_rx_bytes": 499297961, - "total_delta_tx_bytes": 499630649, - "rx_bytes_per_upload": 9985959, - "tx_bytes_per_upload": 9992613, - "max_delta_rss_bytes": 15155200 + "total_delta_rx_bytes": 499290061, + "total_delta_tx_bytes": 499615897, + "rx_bytes_per_upload": 9985801, + "tx_bytes_per_upload": 9992318, + "max_delta_rss_bytes": 65277952 }, { "uploads": 50, "succeeded": 50, "failed": 0, - "duration_s": 3.07, + "duration_s": 4.694, "latency_ms": { - "p50": 238.9, - "p95": 391.0, - "p99": 423.1 + "p50": 637.3, + "p95": 848.8, + "p99": 979.4 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 249690323, - "delta_tx_bytes": 249843279, - "baseline_rss_bytes": 193445888, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 249629894, + "delta_tx_bytes": 249780802, + "baseline_rss_bytes": 322142208, "peak_memory_bytes": { - "rss": 212447232, - "heap_used": 48981896, - "external": 28322088, - "array_buffers": 24531744 + "rss": 366731264, + "heap_used": 50163968, + "external": 85133242, + "array_buffers": 81342898 }, - "delta_rss_bytes": 19001344, + "delta_rss_bytes": 44589056, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 249036800, + "attachments.decode.ms": 7874.299524000016, "attachments.proxy.bytes_to_s3": 249036800, "attachments.mark_ready": 25, "attachments.upload.created": 25 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 249684428, - "delta_tx_bytes": 249830235, - "baseline_rss_bytes": 200146944, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 249682445, + "delta_tx_bytes": 249837698, + "baseline_rss_bytes": 325865472, "peak_memory_bytes": { - "rss": 200146944, - "heap_used": 48496592, - "external": 26712221, - "array_buffers": 22921877 + "rss": 365383680, + "heap_used": 50007528, + "external": 84862098, + "array_buffers": 81070915 }, - "delta_rss_bytes": 0, + "delta_rss_bytes": 39518208, "counters": { "attachments.insert_pending": 25, "attachments.proxy.bytes_in": 249036800, + "attachments.decode.ms": 7699.224510000015, "attachments.proxy.bytes_to_s3": 249036800, "attachments.mark_ready": 25, "attachments.upload.created": 25 } } ], - "total_delta_rx_bytes": 499374751, - "total_delta_tx_bytes": 499673514, - "rx_bytes_per_upload": 9987495, - "tx_bytes_per_upload": 9993470, - "max_delta_rss_bytes": 19001344 + "total_delta_rx_bytes": 499312339, + "total_delta_tx_bytes": 499618500, + "rx_bytes_per_upload": 9986247, + "tx_bytes_per_upload": 9992370, + "max_delta_rss_bytes": 44589056 } ] } diff --git a/evidence/lab4/bench/proxy-9961472-c20.json b/evidence/lab4/bench/proxy-9961472-c20.json index c5299ab..34dbd64 100644 --- a/evidence/lab4/bench/proxy-9961472-c20.json +++ b/evidence/lab4/bench/proxy-9961472-c20.json @@ -1,6 +1,6 @@ { - "date": "2026-10-22T20:03:09+00:00", - "git": "f048a37", + "date": "2026-10-23T13:34:02+00:00", + "git": "b32ce9a", "params": { "mode": "proxy", "size_bytes": 9961472, @@ -21,175 +21,185 @@ "uploads": 100, "succeeded": 100, "failed": 0, - "duration_s": 5.789, + "duration_s": 8.965, "latency_ms": { - "p50": 409.2, - "p95": 812.5, - "p99": 959.0 + "p50": 1396.5, + "p95": 1795.3, + "p99": 1927.7 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 499859990, - "delta_tx_bytes": 500110302, - "baseline_rss_bytes": 189095936, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 500201125, + "delta_tx_bytes": 500377070, + "baseline_rss_bytes": 305356800, "peak_memory_bytes": { - "rss": 209506304, - "heap_used": 49551104, - "external": 37459480, - "array_buffers": 28998398 + "rss": 434417664, + "heap_used": 51274840, + "external": 145565797, + "array_buffers": 141709917 }, - "delta_rss_bytes": 20410368, + "delta_rss_bytes": 129060864, "counters": { "attachments.insert_pending": 50, "attachments.proxy.bytes_in": 498073600, + "attachments.decode.ms": 15301.763066, "attachments.proxy.bytes_to_s3": 498073600, "attachments.mark_ready": 50, - "attachments.upload.created": 50 + "attachments.upload.created": 50, + "attachments.claim_expired": 1, + "attachments.delete_claimed": 2, + "attachments.sweep.deleted": 2 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 499688844, - "delta_tx_bytes": 499961376, - "baseline_rss_bytes": 179896320, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 499840721, + "delta_tx_bytes": 500065968, + "baseline_rss_bytes": 315572224, "peak_memory_bytes": { - "rss": 201883648, - "heap_used": 48903104, - "external": 30171785, - "array_buffers": 23259151 + "rss": 417861632, + "heap_used": 51333520, + "external": 141534029, + "array_buffers": 137743685 }, - "delta_rss_bytes": 21987328, + "delta_rss_bytes": 102289408, "counters": { "attachments.insert_pending": 50, "attachments.proxy.bytes_in": 498073600, + "attachments.decode.ms": 15764.19308799997, "attachments.proxy.bytes_to_s3": 498073600, "attachments.mark_ready": 50, - "attachments.upload.created": 50 + "attachments.upload.created": 50, + "attachments.claim_expired": 1 } } ], - "total_delta_rx_bytes": 999548834, - "total_delta_tx_bytes": 1000071678, - "rx_bytes_per_upload": 9995488, - "tx_bytes_per_upload": 10000717, - "max_delta_rss_bytes": 21987328 + "total_delta_rx_bytes": 1000041846, + "total_delta_tx_bytes": 1000443038, + "rx_bytes_per_upload": 10000418, + "tx_bytes_per_upload": 10004430, + "max_delta_rss_bytes": 129060864 }, { "uploads": 100, "succeeded": 100, "failed": 0, - "duration_s": 5.789, + "duration_s": 8.87, "latency_ms": { - "p50": 406.7, - "p95": 756.8, - "p99": 1110.8 + "p50": 1327.7, + "p95": 1753.9, + "p99": 2016.9 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 499409660, - "delta_tx_bytes": 499704231, - "baseline_rss_bytes": 204034048, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 500384354, + "delta_tx_bytes": 500549484, + "baseline_rss_bytes": 405041152, "peak_memory_bytes": { - "rss": 216682496, - "heap_used": 50958080, - "external": 42044393, - "array_buffers": 38254049 + "rss": 442638336, + "heap_used": 51584448, + "external": 136101545, + "array_buffers": 132311201 }, - "delta_rss_bytes": 12648448, + "delta_rss_bytes": 37597184, "counters": { "attachments.insert_pending": 50, "attachments.proxy.bytes_in": 498073600, + "attachments.decode.ms": 15850.254651000054, "attachments.proxy.bytes_to_s3": 498073600, "attachments.mark_ready": 50, "attachments.upload.created": 50 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 499385236, - "delta_tx_bytes": 499657364, - "baseline_rss_bytes": 196177920, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 500629918, + "delta_tx_bytes": 500817708, + "baseline_rss_bytes": 379080704, "peak_memory_bytes": { - "rss": 208781312, - "heap_used": 49416712, - "external": 29886702, - "array_buffers": 26096358 + "rss": 435548160, + "heap_used": 51076952, + "external": 146391435, + "array_buffers": 142601091 }, - "delta_rss_bytes": 12603392, + "delta_rss_bytes": 56467456, "counters": { "attachments.insert_pending": 50, "attachments.proxy.bytes_in": 498073600, + "attachments.decode.ms": 15065.693191000057, "attachments.proxy.bytes_to_s3": 498073600, "attachments.mark_ready": 50, "attachments.upload.created": 50 } } ], - "total_delta_rx_bytes": 998794896, - "total_delta_tx_bytes": 999361595, - "rx_bytes_per_upload": 9987949, - "tx_bytes_per_upload": 9993616, - "max_delta_rss_bytes": 12648448 + "total_delta_rx_bytes": 1001014272, + "total_delta_tx_bytes": 1001367192, + "rx_bytes_per_upload": 10010143, + "tx_bytes_per_upload": 10013672, + "max_delta_rss_bytes": 56467456 }, { "uploads": 100, "succeeded": 100, "failed": 0, - "duration_s": 6.222, + "duration_s": 9.117, "latency_ms": { - "p50": 452.3, - "p95": 913.7, - "p99": 1284.1 + "p50": 1442.2, + "p95": 1862.3, + "p99": 1962.7 }, "replicas": [ { - "instance_id": "01e84e9e9e38", - "delta_rx_bytes": 499462554, - "delta_tx_bytes": 499707805, - "baseline_rss_bytes": 208515072, + "instance_id": "7c7cf67931e5", + "delta_rx_bytes": 499434564, + "delta_tx_bytes": 499705234, + "baseline_rss_bytes": 421199872, "peak_memory_bytes": { - "rss": 213237760, - "heap_used": 50201400, - "external": 39684000, - "array_buffers": 35893464 + "rss": 441876480, + "heap_used": 50736392, + "external": 135949482, + "array_buffers": 132036017 }, - "delta_rss_bytes": 4722688, + "delta_rss_bytes": 20676608, "counters": { "attachments.insert_pending": 50, "attachments.proxy.bytes_in": 498073600, + "attachments.decode.ms": 16234.571914999979, "attachments.proxy.bytes_to_s3": 498073600, "attachments.mark_ready": 50, "attachments.upload.created": 50 } }, { - "instance_id": "d49b799653d6", - "delta_rx_bytes": 499435292, - "delta_tx_bytes": 499704897, - "baseline_rss_bytes": 192315392, + "instance_id": "ff9a363e52b1", + "delta_rx_bytes": 499505499, + "delta_tx_bytes": 499795523, + "baseline_rss_bytes": 348524544, "peak_memory_bytes": { - "rss": 209580032, - "heap_used": 50343440, - "external": 38677040, - "array_buffers": 34886696 + "rss": 441692160, + "heap_used": 50551064, + "external": 136342743, + "array_buffers": 132552399 }, - "delta_rss_bytes": 17264640, + "delta_rss_bytes": 93167616, "counters": { "attachments.insert_pending": 50, "attachments.proxy.bytes_in": 498073600, + "attachments.decode.ms": 16105.769058999955, "attachments.proxy.bytes_to_s3": 498073600, "attachments.mark_ready": 50, "attachments.upload.created": 50 } } ], - "total_delta_rx_bytes": 998897846, - "total_delta_tx_bytes": 999412702, - "rx_bytes_per_upload": 9988978, - "tx_bytes_per_upload": 9994127, - "max_delta_rss_bytes": 17264640 + "total_delta_rx_bytes": 998940063, + "total_delta_tx_bytes": 999500757, + "rx_bytes_per_upload": 9989401, + "tx_bytes_per_upload": 9995008, + "max_delta_rss_bytes": 93167616 } ] } diff --git a/evidence/lab4/consistency.txt b/evidence/lab4/consistency.txt index b2f9c3e..7e9b047 100644 --- a/evidence/lab4/consistency.txt +++ b/evidence/lab4/consistency.txt @@ -1,9 +1,9 @@ scripts/lab4/consistency_check.sh bucket: messenger-attachments -objects: 2580 +objects: 3823 rows by status: - 33 pending - 2577 ready - 6 rejected + 11 pending + 3822 ready + 4 rejected orphans: 0 missing: 0 diff --git a/evidence/lab4/decode-memory.txt b/evidence/lab4/decode-memory.txt new file mode 100644 index 0000000..09ebb0d --- /dev/null +++ b/evidence/lab4/decode-memory.txt @@ -0,0 +1,4 @@ +# inputs: magick -size 6320x6320 gradient:red-blue (PNG); same as JPEG q85 baseline and -interlace JPEG +png 6320x6320 bytes=53350 decode_ms=1159 peak_delta_rss_mib=116.8 +jpeg 6320x6320 bytes=4899767 decode_ms=1234 peak_delta_rss_mib=126.5 +jpeg 6320x6320 progressive bytes=4791710 decode_ms=1379 peak_delta_rss_mib=130.5 diff --git a/evidence/lab4/direct-ttl-short.txt b/evidence/lab4/direct-ttl-short.txt index f9afeee..2f06310 100644 --- a/evidence/lab4/direct-ttl-short.txt +++ b/evidence/lab4/direct-ttl-short.txt @@ -3,6 +3,6 @@ The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead. RUN v4.1.11 /home/tomato/Projects/VP/mtusi2026lab4/app Test Files 1 passed (1) - Tests 7 passed (7) - Start at 23:00:12 - Duration 8.41s (transform 64ms, setup 0ms, import 94ms, tests 8.16s, environment 0ms) + Tests 9 passed (9) + Start at 16:31:20 + Duration 8.28s (transform 48ms, setup 0ms, import 72ms, tests 8.12s, environment 0ms) diff --git a/evidence/lab4/make-test-dependencies.txt b/evidence/lab4/make-test-dependencies.txt index 36cd7ce..3900886 100644 --- a/evidence/lab4/make-test-dependencies.txt +++ b/evidence/lab4/make-test-dependencies.txt @@ -5,5 +5,5 @@ The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths r RUN v4.1.11 /home/tomato/Projects/VP/mtusi2026lab4/app Test Files 1 passed (1) Tests 6 passed (6) - Start at 23:00:31 - Duration 88.83s (transform 48ms, setup 0ms, import 73ms, tests 88.65s, environment 0ms) + Start at 16:34:39 + Duration 124.94s (transform 75ms, setup 0ms, import 94ms, tests 124.75s, environment 0ms) diff --git a/evidence/lab4/make-test-e2e.txt b/evidence/lab4/make-test-e2e.txt index 433cb5a..9dd7805 100644 --- a/evidence/lab4/make-test-e2e.txt +++ b/evidence/lab4/make-test-e2e.txt @@ -3,6 +3,6 @@ The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead. RUN v4.1.11 /home/tomato/Projects/VP/mtusi2026lab4/app Test Files 3 passed | 1 skipped (4) - Tests 34 passed | 8 skipped (42) - Start at 22:59:53 - Duration 4.87s (transform 409ms, setup 0ms, import 764ms, tests 9.39s, environment 0ms) + Tests 38 passed | 8 skipped (46) + Start at 16:30:56 + Duration 4.59s (transform 196ms, setup 0ms, import 593ms, tests 10.10s, environment 0ms) diff --git a/evidence/lab4/summary.md b/evidence/lab4/summary.md index f740885..322a225 100644 --- a/evidence/lab4/summary.md +++ b/evidence/lab4/summary.md @@ -1,9 +1,9 @@ | mode | size, MiB | C | ok | API rx/upload, MiB | API tx/upload, MiB | max Δrss, MiB | p50, ms | p95, ms | |---|---|---|---|---|---|---|---|---| -| direct | 0.12 | 10 | 150/150 | 0.07 | 0.01 | 0.40 | 45 | 65 | -| proxy | 0.12 | 10 | 150/150 | 0.13 | 0.13 | 3.78 | 32 | 62 | -| direct | 1.00 | 10 | 150/150 | 0.07 | 0.01 | 0.75 | 75 | 137 | -| proxy | 1.00 | 10 | 150/150 | 1.01 | 1.01 | 4.38 | 59 | 110 | -| direct | 9.50 | 10 | 150/150 | 0.07 | 0.01 | 0.88 | 346 | 571 | -| proxy | 9.50 | 10 | 150/150 | 9.52 | 9.53 | 15.70 | 239 | 394 | -| proxy | 9.50 | 20 | 300/300 | 9.53 | 9.53 | 16.46 | 409 | 812 | +| direct | 0.12 | 10 | 150/150 | 0.13 | 0.01 | 1.12 | 68 | 104 | +| proxy | 0.12 | 10 | 150/150 | 0.13 | 0.13 | 3.38 | 60 | 106 | +| direct | 1.00 | 10 | 150/150 | 1.01 | 0.01 | 9.81 | 164 | 249 | +| proxy | 1.00 | 10 | 150/150 | 1.01 | 1.01 | 12.82 | 143 | 192 | +| direct | 9.50 | 10 | 150/150 | 9.52 | 0.01 | 81.77 | 693 | 1082 | +| proxy | 9.50 | 10 | 150/150 | 9.52 | 9.53 | 62.25 | 688 | 947 | +| proxy | 9.50 | 20 | 300/300 | 9.54 | 9.54 | 88.85 | 1396 | 1795 | diff --git a/evidence/lab4/unit-tests.txt b/evidence/lab4/unit-tests.txt index 5a32fee..273e164 100644 --- a/evidence/lab4/unit-tests.txt +++ b/evidence/lab4/unit-tests.txt @@ -1,8 +1,6 @@ -The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead. - RUN v4.1.11 /home/tomato/Projects/VP/mtusi2026lab4/app -[Nest] 3057161 - 10/22/2026, 10:44:47 PM WARN [MessagesCacheService] Cache read failed, serving PostgreSQL: redis down -[Nest] 3057161 - 10/22/2026, 10:44:47 PM WARN [MessagesCacheService] Cache fill failed: redis down - Test Files 10 passed (10) - Tests 36 passed (36) - Start at 22:44:46 - Duration 1.93s (transform 718ms, setup 0ms, import 5.44s, tests 373ms, environment 1ms) +[Nest] 3821708 - 10/23/2026, 4:31:09 PM WARN [MessagesCacheService] Cache fill failed: redis down +[Nest] 3821732 - 10/23/2026, 4:31:10 PM WARN [AttachmentsService] Compensation of attachment 26212360-edf3-428c-9246-43cb29900490 deferred: Connection terminated unexpectedly + Test Files 12 passed (12) + Tests 43 passed (43) + Start at 16:31:08 + Duration 2.59s (transform 791ms, setup 0ms, import 8.70s, tests 543ms, environment 2ms) diff --git a/scripts/lab4/decode_memory.mjs b/scripts/lab4/decode_memory.mjs new file mode 100644 index 0000000..475316d --- /dev/null +++ b/scripts/lab4/decode_memory.mjs @@ -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 +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)}`, + ); +}