feat(lab5): add exactly_right scenario and refresh evidence

This commit is contained in:
Mikhail Verkovykh
2026-11-20 19:05:29 +03:00
parent d0f533b371
commit b6953ae6ee
7 changed files with 2529 additions and 675 deletions
+178 -95
View File
@@ -49,18 +49,18 @@ code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
<body>
<main>
<h1>Lab5, трек 1: очередь под перегрузкой</h1>
<p class="lead">Сгенерировано 2026-11-14T21:42:03.122104+00:00. Стенд: http://172.18.0.1:8080,
<p class="lead">Сгенерировано 2026-11-20T16:02:07.856909+00:00. Стенд: http://172.18.0.1:8080,
4 CPU, Docker 5.6.1.</p>
<section class="card hypothesis">
<strong>Гипотеза.</strong> Маленькие изображения, которые почти не требуют
масштабирования, должны давать высокий throughput и низкий RSS на задание.
Большие изображения требуют декодирования и downscale, поэтому каждое задание
дороже: при том же числе worker-ов очередь растёт, p95 time-to-ready
увеличивается, а пиковый RSS зависит от concurrency сильнее, чем у маленьких
файлов. Одновременно проверяем компромисс: <em>eager</em> уменьшает ожидание,
но повышает потребление памяти; <em>serial</em> экономит память, но ограничивает
throughput.
<strong>Гипотеза.</strong> Стоимость задания складывается из decode, масштабирования
и сжатия. <em>exactly_right</em> (1280×1280) не масштабирует optimized-вариант,
поэтому показывает нижнюю границу стоимости сжатия; <em>huge_few</em> добавляет
downscale, а <em>small_many</em> почти не масштабируется, но и пикселей в нём
мало. Большие изображения при том же числе worker-ов увеличивают очередь,
p95 time-to-ready и RSS. Одновременно проверяем компромисс: <em>eager</em>
уменьшает ожидание, но повышает память; <em>serial</em> экономит память, но
ограничивает throughput.
</section>
<section class="card">
@@ -72,16 +72,15 @@ throughput.
</tbody>
</table>
<p class="note">Сценарии:
small_many — 192×128, 30 jobs, many small images; variants fit or crop without large scaling; huge_few — 2400×1800, 12 jobs, few 4.32 MP images; optimized variant must scale down to 1280.</p>
small_many — 192×128, 30 jobs, many small images; almost no scaling; exactly_right — 1280×1280, 18 jobs, largest variant encodes at native 1280, so no scaling on the WebP path; huge_few — 2400×1800, 12 jobs, few 4.32 MP images; optimized variant must scale down to 1280.</p>
</section>
<section class="card">
<h2>Ключевые числа</h2>
<div class="metrics">
<div class="metric"><div class="value">6</div><div class="label">прогонов матрицы</div></div>
<div class="metric"><div class="value">1122 MiB</div><div class="label">максимальный RSS worker</div></div>
<div class="metric"><div class="value">3</div><div class="label">принято до первого 503</div></div>
<div class="metric"><div class="value">7.6 s</div><div class="label">восстановление после backpressure</div></div>
<div class="metric"><div class="value">9</div><div class="label">прогонов матрицы</div></div>
<div class="metric"><div class="value">950 MiB</div><div class="label">максимальный RSS worker</div></div>
<div class="metric"><div class="value">7.7 s</div><div class="label">восстановление после backpressure</div></div>
</div>
</section>
@@ -91,27 +90,34 @@ small_many — 192×128, 30 jobs, many small images; variants fit or crop withou
<line x1="64" y1="258.0" x2="740" y2="258.0" class="grid"/>
<text x="54" y="262.0" class="axis" text-anchor="end">0 jobs/s</text>
<line x1="64" y1="206.5" x2="740" y2="206.5" class="grid"/>
<text x="54" y="210.5" class="axis" text-anchor="end">4 jobs/s</text>
<text x="54" y="210.5" class="axis" text-anchor="end">5 jobs/s</text>
<line x1="64" y1="155.0" x2="740" y2="155.0" class="grid"/>
<text x="54" y="159.0" class="axis" text-anchor="end">8 jobs/s</text>
<text x="54" y="159.0" class="axis" text-anchor="end">9 jobs/s</text>
<line x1="64" y1="103.5" x2="740" y2="103.5" class="grid"/>
<text x="54" y="107.5" class="axis" text-anchor="end">12 jobs/s</text>
<text x="54" y="107.5" class="axis" text-anchor="end">14 jobs/s</text>
<line x1="64" y1="52.0" x2="740" y2="52.0" class="grid"/>
<text x="54" y="56.0" class="axis" text-anchor="end">16 jobs/s</text>
<rect x="92.9" y="171.4" width="67.6" height="86.6" fill="#64748b" rx="3"/>
<text x="126.7" y="166.4" class="bar-label" text-anchor="middle">6.88 jobs/s</text>
<rect x="175.3" y="112.0" width="67.6" height="146.0" fill="#0284c7" rx="3"/>
<text x="209.1" y="107.0" class="bar-label" text-anchor="middle">11.59 jobs/s</text>
<rect x="257.7" y="83.4" width="67.6" height="174.6" fill="#f59e0b" rx="3"/>
<text x="291.5" y="78.4" class="bar-label" text-anchor="middle">13.86 jobs/s</text>
<text x="233.0" y="282" class="axis" text-anchor="middle">small_many</text>
<rect x="430.9" y="252.4" width="67.6" height="5.6" fill="#64748b" rx="3"/>
<text x="464.7" y="247.4" class="bar-label" text-anchor="middle">0.44 jobs/s</text>
<rect x="513.3" y="252.3" width="67.6" height="5.7" fill="#0284c7" rx="3"/>
<text x="547.1" y="247.3" class="bar-label" text-anchor="middle">0.45 jobs/s</text>
<rect x="595.7" y="252.2" width="67.6" height="5.8" fill="#f59e0b" rx="3"/>
<text x="629.5" y="247.2" class="bar-label" text-anchor="middle">0.46 jobs/s</text>
<text x="571.0" y="282" class="axis" text-anchor="middle">huge_few</text>
<text x="54" y="56.0" class="axis" text-anchor="end">18 jobs/s</text>
<rect x="83.2" y="181.4" width="45.1" height="76.6" fill="#64748b" rx="3"/>
<text x="105.8" y="176.4" class="bar-label" text-anchor="middle">6.84 jobs/s</text>
<rect x="138.2" y="104.5" width="45.1" height="153.5" fill="#0284c7" rx="3"/>
<text x="160.7" y="99.5" class="bar-label" text-anchor="middle">13.69 jobs/s</text>
<rect x="193.2" y="83.4" width="45.1" height="174.6" fill="#f59e0b" rx="3"/>
<text x="215.7" y="78.4" class="bar-label" text-anchor="middle">15.58 jobs/s</text>
<text x="176.7" y="282" class="axis" text-anchor="middle">small_many</text>
<rect x="308.6" y="252.7" width="45.1" height="5.3" fill="#64748b" rx="3"/>
<text x="331.1" y="247.7" class="bar-label" text-anchor="middle">0.47 jobs/s</text>
<rect x="363.5" y="252.5" width="45.1" height="5.5" fill="#0284c7" rx="3"/>
<text x="386.1" y="247.5" class="bar-label" text-anchor="middle">0.49 jobs/s</text>
<rect x="418.5" y="252.5" width="45.1" height="5.5" fill="#f59e0b" rx="3"/>
<text x="441.0" y="247.5" class="bar-label" text-anchor="middle">0.49 jobs/s</text>
<text x="402.0" y="282" class="axis" text-anchor="middle">exactly_right</text>
<rect x="533.9" y="253.1" width="45.1" height="4.9" fill="#64748b" rx="3"/>
<text x="556.4" y="248.1" class="bar-label" text-anchor="middle">0.44 jobs/s</text>
<rect x="588.9" y="253.1" width="45.1" height="4.9" fill="#0284c7" rx="3"/>
<text x="611.4" y="248.1" class="bar-label" text-anchor="middle">0.44 jobs/s</text>
<rect x="643.8" y="253.0" width="45.1" height="5.0" fill="#f59e0b" rx="3"/>
<text x="666.4" y="248.0" class="bar-label" text-anchor="middle">0.44 jobs/s</text>
<text x="627.3" y="282" class="axis" text-anchor="middle">huge_few</text>
<rect x="64" y="298" width="11" height="11" fill="#64748b" rx="2"/>
<text x="80" y="308" class="axis">serial</text>
<rect x="154" y="298" width="11" height="11" fill="#0284c7" rx="2"/>
@@ -126,27 +132,34 @@ small_many — 192×128, 30 jobs, many small images; variants fit or crop withou
<line x1="64" y1="258.0" x2="740" y2="258.0" class="grid"/>
<text x="54" y="262.0" class="axis" text-anchor="end">0 ms</text>
<line x1="64" y1="206.5" x2="740" y2="206.5" class="grid"/>
<text x="54" y="210.5" class="axis" text-anchor="end">7606 ms</text>
<text x="54" y="210.5" class="axis" text-anchor="end">10560 ms</text>
<line x1="64" y1="155.0" x2="740" y2="155.0" class="grid"/>
<text x="54" y="159.0" class="axis" text-anchor="end">15213 ms</text>
<text x="54" y="159.0" class="axis" text-anchor="end">21120 ms</text>
<line x1="64" y1="103.5" x2="740" y2="103.5" class="grid"/>
<text x="54" y="107.5" class="axis" text-anchor="end">22819 ms</text>
<text x="54" y="107.5" class="axis" text-anchor="end">31680 ms</text>
<line x1="64" y1="52.0" x2="740" y2="52.0" class="grid"/>
<text x="54" y="56.0" class="axis" text-anchor="end">30426 ms</text>
<rect x="92.9" y="235.8" width="67.6" height="22.2" fill="#64748b" rx="3"/>
<text x="126.7" y="230.8" class="bar-label" text-anchor="middle">3284 ms</text>
<rect x="175.3" y="246.2" width="67.6" height="11.8" fill="#0284c7" rx="3"/>
<text x="209.1" y="241.2" class="bar-label" text-anchor="middle">1736 ms</text>
<rect x="257.7" y="250.2" width="67.6" height="7.8" fill="#f59e0b" rx="3"/>
<text x="291.5" y="245.2" class="bar-label" text-anchor="middle">1158 ms</text>
<text x="233.0" y="282" class="axis" text-anchor="middle">small_many</text>
<rect x="430.9" y="85.2" width="67.6" height="172.8" fill="#64748b" rx="3"/>
<text x="464.7" y="80.2" class="bar-label" text-anchor="middle">25521 ms</text>
<rect x="513.3" y="83.4" width="67.6" height="174.6" fill="#0284c7" rx="3"/>
<text x="547.1" y="78.4" class="bar-label" text-anchor="middle">25785 ms</text>
<rect x="595.7" y="84.0" width="67.6" height="174.0" fill="#f59e0b" rx="3"/>
<text x="629.5" y="79.0" class="bar-label" text-anchor="middle">25699 ms</text>
<text x="571.0" y="282" class="axis" text-anchor="middle">huge_few</text>
<text x="54" y="56.0" class="axis" text-anchor="end">42240 ms</text>
<rect x="83.2" y="241.7" width="45.1" height="16.3" fill="#64748b" rx="3"/>
<text x="105.8" y="236.7" class="bar-label" text-anchor="middle">3338 ms</text>
<rect x="138.2" y="251.8" width="45.1" height="6.2" fill="#0284c7" rx="3"/>
<text x="160.7" y="246.8" class="bar-label" text-anchor="middle">1274 ms</text>
<rect x="193.2" y="252.3" width="45.1" height="5.7" fill="#f59e0b" rx="3"/>
<text x="215.7" y="247.3" class="bar-label" text-anchor="middle">1166 ms</text>
<text x="176.7" y="282" class="axis" text-anchor="middle">small_many</text>
<rect x="308.6" y="83.8" width="45.1" height="174.2" fill="#64748b" rx="3"/>
<text x="331.1" y="78.8" class="bar-label" text-anchor="middle">35714 ms</text>
<rect x="363.5" y="83.6" width="45.1" height="174.4" fill="#0284c7" rx="3"/>
<text x="386.1" y="78.6" class="bar-label" text-anchor="middle">35764 ms</text>
<rect x="418.5" y="83.4" width="45.1" height="174.6" fill="#f59e0b" rx="3"/>
<text x="441.0" y="78.4" class="bar-label" text-anchor="middle">35797 ms</text>
<text x="402.0" y="282" class="axis" text-anchor="middle">exactly_right</text>
<rect x="533.9" y="131.7" width="45.1" height="126.3" fill="#64748b" rx="3"/>
<text x="556.4" y="126.7" class="bar-label" text-anchor="middle">25896 ms</text>
<rect x="588.9" y="128.4" width="45.1" height="129.6" fill="#0284c7" rx="3"/>
<text x="611.4" y="123.4" class="bar-label" text-anchor="middle">26576 ms</text>
<rect x="643.8" y="128.1" width="45.1" height="129.9" fill="#f59e0b" rx="3"/>
<text x="666.4" y="123.1" class="bar-label" text-anchor="middle">26641 ms</text>
<text x="627.3" y="282" class="axis" text-anchor="middle">huge_few</text>
<rect x="64" y="298" width="11" height="11" fill="#64748b" rx="2"/>
<text x="80" y="308" class="axis">serial</text>
<rect x="154" y="298" width="11" height="11" fill="#0284c7" rx="2"/>
@@ -161,27 +174,34 @@ small_many — 192×128, 30 jobs, many small images; variants fit or crop withou
<line x1="64" y1="258.0" x2="740" y2="258.0" class="grid"/>
<text x="54" y="262.0" class="axis" text-anchor="end">0 ms</text>
<line x1="64" y1="206.5" x2="740" y2="206.5" class="grid"/>
<text x="54" y="210.5" class="axis" text-anchor="end">6883 ms</text>
<text x="54" y="210.5" class="axis" text-anchor="end">9909 ms</text>
<line x1="64" y1="155.0" x2="740" y2="155.0" class="grid"/>
<text x="54" y="159.0" class="axis" text-anchor="end">13766 ms</text>
<text x="54" y="159.0" class="axis" text-anchor="end">19819 ms</text>
<line x1="64" y1="103.5" x2="740" y2="103.5" class="grid"/>
<text x="54" y="107.5" class="axis" text-anchor="end">20650 ms</text>
<text x="54" y="107.5" class="axis" text-anchor="end">29728 ms</text>
<line x1="64" y1="52.0" x2="740" y2="52.0" class="grid"/>
<text x="54" y="56.0" class="axis" text-anchor="end">27533 ms</text>
<rect x="92.9" y="234.1" width="67.6" height="23.9" fill="#64748b" rx="3"/>
<text x="126.7" y="229.1" class="bar-label" text-anchor="middle">3194 ms</text>
<rect x="175.3" y="245.9" width="67.6" height="12.1" fill="#0284c7" rx="3"/>
<text x="209.1" y="240.9" class="bar-label" text-anchor="middle">1624 ms</text>
<rect x="257.7" y="251.3" width="67.6" height="6.7" fill="#f59e0b" rx="3"/>
<text x="291.5" y="246.3" class="bar-label" text-anchor="middle">898 ms</text>
<text x="233.0" y="282" class="axis" text-anchor="middle">small_many</text>
<rect x="430.9" y="83.4" width="67.6" height="174.6" fill="#64748b" rx="3"/>
<text x="464.7" y="78.4" class="bar-label" text-anchor="middle">23333 ms</text>
<rect x="513.3" y="125.4" width="67.6" height="132.6" fill="#0284c7" rx="3"/>
<text x="547.1" y="120.4" class="bar-label" text-anchor="middle">17716 ms</text>
<rect x="595.7" y="126.8" width="67.6" height="131.2" fill="#f59e0b" rx="3"/>
<text x="629.5" y="121.8" class="bar-label" text-anchor="middle">17538 ms</text>
<text x="571.0" y="282" class="axis" text-anchor="middle">huge_few</text>
<text x="54" y="56.0" class="axis" text-anchor="end">39637 ms</text>
<rect x="83.2" y="241.1" width="45.1" height="16.9" fill="#64748b" rx="3"/>
<text x="105.8" y="236.1" class="bar-label" text-anchor="middle">3256 ms</text>
<rect x="138.2" y="252.0" width="45.1" height="6.0" fill="#0284c7" rx="3"/>
<text x="160.7" y="247.0" class="bar-label" text-anchor="middle">1147 ms</text>
<rect x="193.2" y="253.2" width="45.1" height="4.8" fill="#f59e0b" rx="3"/>
<text x="215.7" y="248.2" class="bar-label" text-anchor="middle">924 ms</text>
<text x="176.7" y="282" class="axis" text-anchor="middle">small_many</text>
<rect x="308.6" y="83.4" width="45.1" height="174.6" fill="#64748b" rx="3"/>
<text x="331.1" y="78.4" class="bar-label" text-anchor="middle">33591 ms</text>
<rect x="363.5" y="94.2" width="45.1" height="163.8" fill="#0284c7" rx="3"/>
<text x="386.1" y="89.2" class="bar-label" text-anchor="middle">31510 ms</text>
<rect x="418.5" y="93.1" width="45.1" height="164.9" fill="#f59e0b" rx="3"/>
<text x="441.0" y="88.1" class="bar-label" text-anchor="middle">31735 ms</text>
<text x="402.0" y="282" class="axis" text-anchor="middle">exactly_right</text>
<rect x="533.9" y="135.0" width="45.1" height="123.0" fill="#64748b" rx="3"/>
<text x="556.4" y="130.0" class="bar-label" text-anchor="middle">23668 ms</text>
<rect x="588.9" y="163.6" width="45.1" height="94.4" fill="#0284c7" rx="3"/>
<text x="611.4" y="158.6" class="bar-label" text-anchor="middle">18161 ms</text>
<rect x="643.8" y="166.3" width="45.1" height="91.7" fill="#f59e0b" rx="3"/>
<text x="666.4" y="161.3" class="bar-label" text-anchor="middle">17648 ms</text>
<text x="627.3" y="282" class="axis" text-anchor="middle">huge_few</text>
<rect x="64" y="298" width="11" height="11" fill="#64748b" rx="2"/>
<text x="80" y="308" class="axis">serial</text>
<rect x="154" y="298" width="11" height="11" fill="#0284c7" rx="2"/>
@@ -196,27 +216,76 @@ small_many — 192×128, 30 jobs, many small images; variants fit or crop withou
<line x1="64" y1="258.0" x2="740" y2="258.0" class="grid"/>
<text x="54" y="262.0" class="axis" text-anchor="end">0 MiB</text>
<line x1="64" y1="206.5" x2="740" y2="206.5" class="grid"/>
<text x="54" y="210.5" class="axis" text-anchor="end">331 MiB</text>
<text x="54" y="210.5" class="axis" text-anchor="end">280 MiB</text>
<line x1="64" y1="155.0" x2="740" y2="155.0" class="grid"/>
<text x="54" y="159.0" class="axis" text-anchor="end">662 MiB</text>
<text x="54" y="159.0" class="axis" text-anchor="end">560 MiB</text>
<line x1="64" y1="103.5" x2="740" y2="103.5" class="grid"/>
<text x="54" y="107.5" class="axis" text-anchor="end">993 MiB</text>
<text x="54" y="107.5" class="axis" text-anchor="end">840 MiB</text>
<line x1="64" y1="52.0" x2="740" y2="52.0" class="grid"/>
<text x="54" y="56.0" class="axis" text-anchor="end">1324 MiB</text>
<rect x="92.9" y="253.6" width="67.6" height="4.4" fill="#64748b" rx="3"/>
<text x="126.7" y="248.6" class="bar-label" text-anchor="middle">28 MiB</text>
<rect x="175.3" y="253.2" width="67.6" height="4.8" fill="#0284c7" rx="3"/>
<text x="209.1" y="248.2" class="bar-label" text-anchor="middle">31 MiB</text>
<rect x="257.7" y="252.9" width="67.6" height="5.1" fill="#f59e0b" rx="3"/>
<text x="291.5" y="247.9" class="bar-label" text-anchor="middle">33 MiB</text>
<text x="233.0" y="282" class="axis" text-anchor="middle">small_many</text>
<rect x="430.9" y="226.2" width="67.6" height="31.8" fill="#64748b" rx="3"/>
<text x="464.7" y="221.2" class="bar-label" text-anchor="middle">205 MiB</text>
<rect x="513.3" y="144.6" width="67.6" height="113.4" fill="#0284c7" rx="3"/>
<text x="547.1" y="139.6" class="bar-label" text-anchor="middle">729 MiB</text>
<rect x="595.7" y="83.4" width="67.6" height="174.6" fill="#f59e0b" rx="3"/>
<text x="629.5" y="78.4" class="bar-label" text-anchor="middle">1122 MiB</text>
<text x="571.0" y="282" class="axis" text-anchor="middle">huge_few</text>
<text x="54" y="56.0" class="axis" text-anchor="end">1121 MiB</text>
<rect x="83.2" y="252.8" width="45.1" height="5.2" fill="#64748b" rx="3"/>
<text x="105.8" y="247.8" class="bar-label" text-anchor="middle">28 MiB</text>
<rect x="138.2" y="252.7" width="45.1" height="5.3" fill="#0284c7" rx="3"/>
<text x="160.7" y="247.7" class="bar-label" text-anchor="middle">29 MiB</text>
<rect x="193.2" y="252.1" width="45.1" height="5.9" fill="#f59e0b" rx="3"/>
<text x="215.7" y="247.1" class="bar-label" text-anchor="middle">32 MiB</text>
<text x="176.7" y="282" class="axis" text-anchor="middle">small_many</text>
<rect x="308.6" y="226.0" width="45.1" height="32.0" fill="#64748b" rx="3"/>
<text x="331.1" y="221.0" class="bar-label" text-anchor="middle">174 MiB</text>
<rect x="363.5" y="178.2" width="45.1" height="79.8" fill="#0284c7" rx="3"/>
<text x="386.1" y="173.2" class="bar-label" text-anchor="middle">434 MiB</text>
<rect x="418.5" y="107.5" width="45.1" height="150.5" fill="#f59e0b" rx="3"/>
<text x="441.0" y="102.5" class="bar-label" text-anchor="middle">818 MiB</text>
<text x="402.0" y="282" class="axis" text-anchor="middle">exactly_right</text>
<rect x="533.9" y="218.9" width="45.1" height="39.1" fill="#64748b" rx="3"/>
<text x="556.4" y="213.9" class="bar-label" text-anchor="middle">213 MiB</text>
<rect x="588.9" y="118.9" width="45.1" height="139.1" fill="#0284c7" rx="3"/>
<text x="611.4" y="113.9" class="bar-label" text-anchor="middle">756 MiB</text>
<rect x="643.8" y="83.4" width="45.1" height="174.6" fill="#f59e0b" rx="3"/>
<text x="666.4" y="78.4" class="bar-label" text-anchor="middle">950 MiB</text>
<text x="627.3" y="282" class="axis" text-anchor="middle">huge_few</text>
<rect x="64" y="298" width="11" height="11" fill="#64748b" rx="2"/>
<text x="80" y="308" class="axis">serial</text>
<rect x="154" y="298" width="11" height="11" fill="#0284c7" rx="2"/>
<text x="170" y="308" class="axis">balanced</text>
<rect x="244" y="298" width="11" height="11" fill="#f59e0b" rx="2"/>
<text x="260" y="308" class="axis">eager</text>
<text x="740" y="308" class="axis" text-anchor="end">lower is better</text>
</svg></section>
<section class="card chart"><svg viewBox="0 0 760 320" role="img" aria-label="Compression overhead: доля encode в pipeline CPU">
<text x="64" y="24" class="chart-title">Compression overhead: доля encode в pipeline CPU</text>
<text x="64" y="42" class="chart-sub">encode / (decode + scale + encode), % (меньше — дешевле сжатие).</text>
<line x1="64" y1="258.0" x2="740" y2="258.0" class="grid"/>
<text x="54" y="262.0" class="axis" text-anchor="end">0 %</text>
<line x1="64" y1="206.5" x2="740" y2="206.5" class="grid"/>
<text x="54" y="210.5" class="axis" text-anchor="end">25 %</text>
<line x1="64" y1="155.0" x2="740" y2="155.0" class="grid"/>
<text x="54" y="159.0" class="axis" text-anchor="end">49 %</text>
<line x1="64" y1="103.5" x2="740" y2="103.5" class="grid"/>
<text x="54" y="107.5" class="axis" text-anchor="end">74 %</text>
<line x1="64" y1="52.0" x2="740" y2="52.0" class="grid"/>
<text x="54" y="56.0" class="axis" text-anchor="end">99 %</text>
<rect x="83.2" y="83.4" width="45.1" height="174.6" fill="#64748b" rx="3"/>
<text x="105.8" y="78.4" class="bar-label" text-anchor="middle">83.8 %</text>
<rect x="138.2" y="83.4" width="45.1" height="174.6" fill="#0284c7" rx="3"/>
<text x="160.7" y="78.4" class="bar-label" text-anchor="middle">83.8 %</text>
<rect x="193.2" y="91.5" width="45.1" height="166.5" fill="#f59e0b" rx="3"/>
<text x="215.7" y="86.5" class="bar-label" text-anchor="middle">79.9 %</text>
<text x="176.7" y="282" class="axis" text-anchor="middle">small_many</text>
<rect x="308.6" y="87.2" width="45.1" height="170.8" fill="#64748b" rx="3"/>
<text x="331.1" y="82.2" class="bar-label" text-anchor="middle">82.0 %</text>
<rect x="363.5" y="84.9" width="45.1" height="173.1" fill="#0284c7" rx="3"/>
<text x="386.1" y="79.9" class="bar-label" text-anchor="middle">83.1 %</text>
<rect x="418.5" y="84.9" width="45.1" height="173.1" fill="#f59e0b" rx="3"/>
<text x="441.0" y="79.9" class="bar-label" text-anchor="middle">83.1 %</text>
<text x="402.0" y="282" class="axis" text-anchor="middle">exactly_right</text>
<rect x="533.9" y="125.1" width="45.1" height="132.9" fill="#64748b" rx="3"/>
<text x="556.4" y="120.1" class="bar-label" text-anchor="middle">63.8 %</text>
<rect x="588.9" y="130.1" width="45.1" height="127.9" fill="#0284c7" rx="3"/>
<text x="611.4" y="125.1" class="bar-label" text-anchor="middle">61.4 %</text>
<rect x="643.8" y="130.1" width="45.1" height="127.9" fill="#f59e0b" rx="3"/>
<text x="666.4" y="125.1" class="bar-label" text-anchor="middle">61.4 %</text>
<text x="627.3" y="282" class="axis" text-anchor="middle">huge_few</text>
<rect x="64" y="298" width="11" height="11" fill="#64748b" rx="2"/>
<text x="80" y="308" class="axis">serial</text>
<rect x="154" y="298" width="11" height="11" fill="#0284c7" rx="2"/>
@@ -229,11 +298,16 @@ small_many — 192×128, 30 jobs, many small images; variants fit or crop withou
<section class="card">
<h2>Полная матрица</h2>
<table>
<thead><tr><th>Профиль</th><th>Сценарий</th><th>Jobs</th><th>Jobs/s</th><th>Queue lag p95, ms</th><th>Ready p95, ms</th><th>Processing p95, ms</th><th>RSS peak, MiB</th><th>Max parallel</th><th>Max backlog</th></tr></thead>
<tbody><tr><td>serial</td><td>small_many</td><td>30</td><td>6.88</td><td>3194</td><td>3284</td><td>152</td><td>28</td><td>1</td><td>27</td></tr><tr><td>serial</td><td>huge_few</td><td>12</td><td>0.44</td><td>23333</td><td>25521</td><td>2311</td><td>205</td><td>1</td><td>12</td></tr><tr><td>balanced</td><td>small_many</td><td>30</td><td>11.59</td><td>1624</td><td>1736</td><td>336</td><td>31</td><td>4</td><td>26</td></tr><tr><td>balanced</td><td>huge_few</td><td>12</td><td>0.45</td><td>17716</td><td>25785</td><td>8710</td><td>729</td><td>4</td><td>12</td></tr><tr><td>eager</td><td>small_many</td><td>30</td><td>13.86</td><td>898</td><td>1158</td><td>566</td><td>33</td><td>8</td><td>26</td></tr><tr><td>eager</td><td>huge_few</td><td>12</td><td>0.46</td><td>17538</td><td>25699</td><td>17320</td><td>1122</td><td>8</td><td>12</td></tr></tbody>
<thead><tr><th>Профиль</th><th>Сценарий</th><th>Jobs</th><th>Jobs/s</th><th>Queue lag p95, ms</th><th>Ready p95, ms</th><th>Processing p95, ms</th><th>Encode p95, ms</th><th>Encode share, %</th><th>RSS peak, MiB</th><th>Max parallel</th><th>Max backlog</th></tr></thead>
<tbody><tr><td>serial</td><td>small_many</td><td>30</td><td>6.84</td><td>3256</td><td>3338</td><td>170</td><td>80</td><td>83.8</td><td>28</td><td>1</td><td>27</td></tr><tr><td>serial</td><td>exactly_right</td><td>18</td><td>0.47</td><td>33591</td><td>35714</td><td>2180</td><td>1722</td><td>82.0</td><td>174</td><td>1</td><td>18</td></tr><tr><td>serial</td><td>huge_few</td><td>12</td><td>0.44</td><td>23668</td><td>25896</td><td>2359</td><td>1508</td><td>63.8</td><td>213</td><td>1</td><td>12</td></tr><tr><td>balanced</td><td>small_many</td><td>30</td><td>13.69</td><td>1147</td><td>1274</td><td>396</td><td>90</td><td>83.8</td><td>29</td><td>4</td><td>24</td></tr><tr><td>balanced</td><td>exactly_right</td><td>18</td><td>0.49</td><td>31510</td><td>35764</td><td>8174</td><td>6562</td><td>83.1</td><td>434</td><td>4</td><td>18</td></tr><tr><td>balanced</td><td>huge_few</td><td>12</td><td>0.44</td><td>18161</td><td>26576</td><td>9046</td><td>5606</td><td>61.4</td><td>756</td><td>4</td><td>12</td></tr><tr><td>eager</td><td>small_many</td><td>30</td><td>15.58</td><td>924</td><td>1166</td><td>410</td><td>95</td><td>79.9</td><td>32</td><td>8</td><td>22</td></tr><tr><td>eager</td><td>exactly_right</td><td>18</td><td>0.49</td><td>31735</td><td>35797</td><td>16363</td><td>13330</td><td>83.1</td><td>818</td><td>8</td><td>18</td></tr><tr><td>eager</td><td>huge_few</td><td>12</td><td>0.44</td><td>17648</td><td>26641</td><td>17678</td><td>11124</td><td>61.4</td><td>950</td><td>8</td><td>12</td></tr></tbody>
</table>
<p class="note">Queue lag = <code>processing_started_at - created_at</code>.
Time-to-ready = <code>finished_at - created_at</code>. Processing = <code>finished_at - processing_started_at</code>.
Encode = JPEG thumbnail + JPEG crop + WebP optimized; encode share =
<code>encode / (decode + scale + encode)</code> из worker-лога.
Суммы байт вариантов и оригинала остаются в JSON, но не выносятся в заголовок:
синтетический PNG сжимается слишком хорошо, чтобы отношение байт было честной
метрикой эффективности кодека.
RSS — VmRSS процесса worker, сэмплирование примерно каждые 100 мс.
Max parallel — максимум одновременно обрабатываемых заданий; max backlog —
максимум принятых, но ещё не готовых заданий.</p>
@@ -242,20 +316,22 @@ Max parallel — максимум одновременно обрабатыва
<section class="card">
<h2>Backpressure и восстановление</h2>
<p>Перед этим прогоном API пересоздан с <code>MAX_PENDING_JOBS=3</code>, worker
остановлен. Последовательные upload-ы показывают, где заканчивается принятая
работа. Затем worker запускается, принятые задания должны дойти до ready.</p>
остановлен. Cap выбран намеренно: важно не число принятых заданий, а то, что
API возвращает <code>503</code> с <code>Retry-After</code> и не теряет уже
подтверждённую работу. Затем worker запускается, принятые задания должны дойти
до ready.</p>
<table>
<thead><tr><th>#</th><th>HTTP</th><th>Latency, ms</th><th>Retry-After</th><th>Error code</th></tr></thead>
<tbody><tr><td>1</td><td class="ok">202</td><td>18.2</td><td>—</td><td>—</td></tr><tr><td>2</td><td class="ok">202</td><td>17.4</td><td>—</td><td>—</td></tr><tr><td>3</td><td class="ok">202</td><td>10.8</td><td>—</td><td>—</td></tr><tr><td>4</td><td class="blocked">503</td><td>3.9</td><td>5</td><td>unavailable</td></tr></tbody>
<tbody><tr><td>1</td><td class="ok">202</td><td>26.7</td><td>—</td><td>—</td></tr><tr><td>2</td><td class="ok">202</td><td>20.3</td><td>—</td><td>—</td></tr><tr><td>3</td><td class="ok">202</td><td>13.8</td><td>—</td><td>—</td></tr><tr><td>4</td><td class="blocked">503</td><td>2.4</td><td>5</td><td>unavailable</td></tr></tbody>
</table>
<p class="note">Recovery: 3 принятых заданий
стали ready за 7.60 с после старта worker.
стали ready за 7.65 с после старта worker.
Финальный probe upload: HTTP 202 → ready.</p>
</section>
<section class="card">
<h2>Что это значит</h2>
<ul><li>small_many: eager быстрее serial в 2.0× по throughput.</li><li>small_many: пиковый RSS eager относится к serial как 1.2×.</li><li>huge_few: throughput eager и serial практически одинаков.</li><li>huge_few: пиковый RSS eager относится к serial как 5.5×.</li><li>При balanced p95 time-to-ready для huge_few в 14.9× больше, чем для small_many: размер изображения меняет стоимость задания, а не только число заданий.</li><li>На huge_few eager почти не поднял throughput (1.04×): worker ограничен 1.0 CPU, а декодирование и масштабирование упираются в CPU. Concurrency снижает queue lag, но при этом растёт RSS; это и есть компромисс latency/ресурсы, а не бесплатное ускорение.</li><li>serial ограничивает одновременно обрабатываемые задания одним, поэтому queue lag растёт, но RSS остаётся минимальным. eager держит больше заданий в работе и в prefetch-окне брокера.</li><li>Backpressure: при MAX_PENDING_JOBS=3 API принял 3 задания, затем вернул 503 с Retry-After=5; после старта worker очередь восстановилась за 7.6 с.</li></ul>
<ul><li>small_many: eager быстрее serial в 2.3× по throughput.</li><li>small_many: пиковый RSS eager относится к serial как 1.1×.</li><li>exactly_right: throughput eager и serial практически одинаков.</li><li>exactly_right: пиковый RSS eager относится к serial как 4.7×.</li><li>huge_few: throughput eager и serial практически одинаков.</li><li>huge_few: пиковый RSS eager относится к serial как 4.5×.</li><li>При balanced p95 time-to-ready для huge_few в 20.9× больше, чем для small_many: размер изображения меняет стоимость задания, а не только число заданий.</li><li>Compression vs scaling (balanced): exactly_right — encode share 83.1%, scale p95 1527 ms; huge_few — encode share 61.4%, scale p95 3448 ms. На exactly_right optimized WebP кодируется в native 1280, поэтому это нижняя граница стоимости сжатия; на huge_few к ней добавляется downscale.</li><li>На huge_few eager почти не поднял throughput (1.02×): worker ограничен 1.0 CPU, а декодирование и масштабирование упираются в CPU. Concurrency снижает queue lag, но при этом растёт RSS; это и есть компромисс latency/ресурсы, а не бесплатное ускорение.</li><li>serial ограничивает одновременно обрабатываемые задания одним, поэтому queue lag растёт, но RSS остаётся минимальным. eager держит больше заданий в работе и в prefetch-окне брокера.</li><li>Backpressure: cap=3 выставлен намеренно, поэтому число принятых заданий — следствие настройки, а не открытие. Значимо то, что API вернул 503 с Retry-After=5, а после старта worker очередь восстановилась за 7.7 с.</li></ul>
</section>
<section class="card">
@@ -263,8 +339,15 @@ Max parallel — максимум одновременно обрабатыва
<ul>
<li>Один worker, один RabbitMQ и один PostgreSQL: это сравнение настроек, а не
HA-кластер. Числа зависят от CPU/диска конкретной машины.</li>
<li>PNG-фикстуры синтетические и хорошо сжимаются; доминирует стоимость декодирования
и масштабирования, а не передача по сети. Размер в байтах указан в JSON.</li>
<li>PNG-фикстуры синтетические и хорошо сжимаются; absolute encode time зависит
от паттерна, но сравнение сценариев при одном паттерне остаётся корректным.
Размер в байтах указан в JSON.</li>
<li>Timing-поля читаются из worker-лога. Это wall-clock внутри процесса, поэтому
при concurrency &gt; 1 в них входит и планировщик, что как раз и нужно для
сравнения профилей.</li>
<li>exactly_right кодирует 1.64 MP WebP, а huge_few после downscale — около
1.23 MP. Сценарий убирает scaling, но не уравнивает объём encode; это указано,
чтобы не сравнивать throughput как «одинаковую работу».</li>
<li>RSS сэмплируется из <code>/proc/1/status</code>; короткий прогон не заменяет
длительный memory profile и p99.</li>
<li>Backpressure cap приблизительный: каждая API-реплика считает pending-задания
+2061 -444
View File
File diff suppressed because it is too large Load Diff
+13 -10
View File
@@ -1,16 +1,19 @@
# Lab5 track 1 — queue under load
Generated: `2026-11-14T21:42:03.122104+00:00`
Generated: `2026-11-20T16:02:07.856909+00:00`
Synthetic images; no tokens or credentials are stored.
| Profile | Scenario | Jobs | Jobs/s | Queue lag p95, ms | Ready p95, ms | RSS peak, MiB |
| --- | --- | ---: | ---: | ---: | ---: | ---: |
| serial | small_many | 30 | 6.88 | 3194 | 3284 | 28 |
| serial | huge_few | 12 | 0.44 | 23333 | 25521 | 205 |
| balanced | small_many | 30 | 11.59 | 1624 | 1736 | 31 |
| balanced | huge_few | 12 | 0.45 | 17716 | 25785 | 729 |
| eager | small_many | 30 | 13.86 | 898 | 1158 | 33 |
| eager | huge_few | 12 | 0.46 | 17538 | 25699 | 1122 |
| Profile | Scenario | Jobs | Jobs/s | Queue lag p95, ms | Ready p95, ms | Encode p95, ms | Encode share, % | RSS peak, MiB |
| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| serial | small_many | 30 | 6.84 | 3256 | 3338 | 80 | 83.8 | 28 |
| serial | exactly_right | 18 | 0.47 | 33591 | 35714 | 1722 | 82.0 | 174 |
| serial | huge_few | 12 | 0.44 | 23668 | 25896 | 1508 | 63.8 | 213 |
| balanced | small_many | 30 | 13.69 | 1147 | 1274 | 90 | 83.8 | 29 |
| balanced | exactly_right | 18 | 0.49 | 31510 | 35764 | 6562 | 83.1 | 434 |
| balanced | huge_few | 12 | 0.44 | 18161 | 26576 | 5606 | 61.4 | 756 |
| eager | small_many | 30 | 15.58 | 924 | 1166 | 95 | 79.9 | 32 |
| eager | exactly_right | 18 | 0.49 | 31735 | 35797 | 13330 | 83.1 | 818 |
| eager | huge_few | 12 | 0.44 | 17648 | 26641 | 11124 | 61.4 | 950 |
Backpressure: cap=3, accepted=3, first 503 Retry-After=5, recovery=7.60s, probe HTTP 202.
Backpressure: cap=3 (deliberate), first 503 Retry-After=5, recovery=7.65s, probe HTTP 202.