From 00db72063992d43e731828a08ad93c17b60a65d3 Mon Sep 17 00:00:00 2001 From: Nico Hinderling Date: Thu, 26 Mar 2026 14:17:11 -0700 Subject: [PATCH 1/2] perf(snapshots): Parallelize image hashing with rayon --- src/commands/build/snapshots.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/commands/build/snapshots.rs b/src/commands/build/snapshots.rs index cc48284323..04bea69fa4 100644 --- a/src/commands/build/snapshots.rs +++ b/src/commands/build/snapshots.rs @@ -11,6 +11,7 @@ use console::style; use itertools::Itertools as _; use log::{debug, info, warn}; use objectstore_client::{ClientBuilder, ExpirationPolicy, Usecase}; +use rayon::prelude::*; use secrecy::ExposeSecret as _; use serde_json::Value; use sha2::{Digest as _, Sha256}; @@ -230,7 +231,7 @@ fn compute_sha256_hash(path: &Path) -> Result { let mut file = std::fs::File::open(path) .with_context(|| format!("Failed to open image for hashing: {}", path.display()))?; let mut hasher = Sha256::new(); - let mut buffer = [0u8; 8192]; + let mut buffer = [0u8; 65536]; loop { let bytes_read = file .read(&mut buffer) @@ -332,10 +333,17 @@ fn upload_images( let mut many_builder = session.many(); let mut manifest_entries = HashMap::new(); let mut collisions: HashMap> = HashMap::new(); - let mut kept_paths: HashMap = HashMap::new(); - for image in images { - debug!("Processing image: {}", image.path.display()); + let mut kept_paths = HashMap::new(); + let hashed_images: Vec<_> = images + .into_par_iter() + .map(|image| { + let hash = compute_sha256_hash(&image.path)?; + Ok((image, hash)) + }) + .collect::>>()?; + + for (image, hash) in hashed_images { let image_file_name = image .relative_path .file_name() @@ -353,7 +361,6 @@ fn upload_images( continue; } - let hash = compute_sha256_hash(&image.path)?; let file = runtime .block_on(tokio::fs::File::open(&image.path)) .with_context(|| { From 3c123e08fdc2c316ab36365aedc956ebf2a04a0a Mon Sep 17 00:00:00 2001 From: Nico Hinderling Date: Thu, 26 Mar 2026 14:24:11 -0700 Subject: [PATCH 2/2] docs(changelog): Add entry for parallel hashing optimization Co-Authored-By: Claude Opus 4.6 (1M context) --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 754f12a5e1..8d3ba26551 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Performance + +- (snapshots) Parallelize image hashing with rayon ([#3250](https://github.com/getsentry/sentry-cli/pull/3250)) + ### Fixes - (sourcemaps) Skip non-base64 embedded sourcemaps during injection ([#3243](https://github.com/getsentry/sentry-cli/pull/3243))