From 009530416f4ed9c283b4f8fbd9cd138dc0b8c6a1 Mon Sep 17 00:00:00 2001 From: Zac Gaetano Date: Thu, 9 Apr 2026 22:07:09 -0400 Subject: [PATCH] perf: reduce chunk size from 32MB to 8MB for better parallelism A 46MB file now splits into 6 chunks (all 6 streams active) instead of 2 chunks (4 streams idle). Better saturation of available bandwidth on high-latency or constrained links. --- public/index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/index.html b/public/index.html index 5e04414..3ec0aaa 100644 --- a/public/index.html +++ b/public/index.html @@ -1128,14 +1128,14 @@ async function startUpload() { // ============================================================ // HTTP MULTI-PART UPLOAD -// Small files (<= 32 MB): single presigned PUT direct to S3. -// Large files (> 32 MB): S3 multipart with presigned part URLs — -// browser PUTs each 32 MB chunk directly to S3, 6 in parallel. +// Small files (<= 8 MB): single presigned PUT direct to S3. +// Large files (> 8 MB): S3 multipart with presigned part URLs — +// browser PUTs each 8 MB chunk directly to S3, 6 in parallel. // Node only signs URLs; file data never touches the server. // Falls back to server-proxied chunked upload if presigned fails. // ============================================================ const UPLOAD_CONCURRENCY = 6; // concurrent file uploads -const CHUNK_SIZE = 32 * 1024 * 1024; // 32 MB per chunk +const CHUNK_SIZE = 8 * 1024 * 1024; // 8 MB per chunk const CHUNKS_PARALLEL = 6; // concurrent chunks per file // Helper: PUT a blob to a presigned URL, return ETag from response @@ -1161,7 +1161,7 @@ async function uploadFilePresigned(item, idx) { const mime = item.file.type || 'application/octet-stream'; const totalParts = Math.max(1, Math.ceil(item.file.size / CHUNK_SIZE)); - // Small files (<= 32 MB): single presigned PUT + // Small files (<= 8 MB): single presigned PUT if (totalParts === 1) { setFileStatus(idx, 'uploading', 'Getting URL\u2026'); const pre = await api('POST', '/api/presigned', { @@ -1193,7 +1193,7 @@ async function uploadFilePresigned(item, idx) { }); } - // Large files (> 32 MB): presigned multipart \u2014 browser \u2192 S3 direct + // Large files (> 8 MB): presigned multipart \u2014 browser \u2192 S3 direct setFileStatus(idx, 'uploading', 'Initiating\u2026'); const init = await api('POST', '/api/desktop/multipart/init', { filename: item.name, prefix: selectedPrefix, size: item.file.size, totalParts,