Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

perf(upload): reduce max chunk size and increase concurrent uploads

Richie McIlroyc2b93500c2b0
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rs
index 281a0529c..4723d0e2b 100644
--- a/apps/desktop/src-tauri/src/recording.rs
+++ b/apps/desktop/src-tauri/src/recording.rs
@@ -950,6 +950,7 @@ pub async fn start_recording(
e
})?;
+
let progressive_upload = InstantMultipartUpload::spawn(
app_handle.clone(),
recording_dir.join("content/output.mp4"),
diff --git a/apps/desktop/src-tauri/src/upload.rs b/apps/desktop/src-tauri/src/upload.rs
index 5ba1b0bd7..04dd2c030 100644
--- a/apps/desktop/src-tauri/src/upload.rs
+++ b/apps/desktop/src-tauri/src/upload.rs
@@ -54,9 +54,8 @@ pub struct UploadProgressEvent {
total: String,
}
-// The size of each S3 multipart upload chunk
-const MIN_CHUNK_SIZE: u64 = 5 * 1024 * 1024; // 5 MB
-const MAX_CHUNK_SIZE: u64 = 20 * 1024 * 1024; // 20 MB
+const MIN_CHUNK_SIZE: u64 = 5 * 1024 * 1024; // 5 MB - S3 multipart minimum
+const MAX_CHUNK_SIZE: u64 = 15 * 1024 * 1024; // 15 MB
#[instrument(skip(app, channel, file_path, screenshot_path))]
pub async fn upload_video(
@@ -552,11 +551,11 @@ pub fn from_pending_file_to_chunks(
}
if total_read > 0 {
- // Remember first chunk size for later re-emission with updated header
if last_read_position == 0 {
first_chunk_size = Some(total_read as u64);
}
+
yield Chunk {
total_size: file_size,
part_number,
@@ -608,7 +607,7 @@ fn multipart_uploader(
upload_id: String,
stream: impl Stream<Item = io::Result<Chunk>> + Send + 'static,
) -> impl Stream<Item = Result<UploadedPart, AuthedApiError>> + 'static {
- const MAX_CONCURRENT_UPLOADS: usize = 3;
+ const MAX_CONCURRENT_UPLOADS: usize = 5;
debug!("Initializing multipart uploader for video {video_id:?}");
let start = Instant::now();