perf: non-blocking hash + parallel thumbnail generation
- Replace blocking blake3::hash() with DedupService::hash_file() in file_upload_service (create_file, update_file). Uses spawn_blocking + mmap_rayon instead of blocking the Tokio async worker. - Parallelize thumbnail resize+encode with rayon par_iter() for the 3 sizes (Icon, Preview, Large) inside spawn_blocking.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use bytes::Bytes;
|
||||
use image::codecs::jpeg::JpegEncoder;
|
||||
use image::imageops::FilterType;
|
||||
use rayon::prelude::*;
|
||||
/**
|
||||
* Thumbnail Generation Service
|
||||
*
|
||||
@@ -534,7 +535,7 @@ impl ThumbnailService {
|
||||
let (orig_w, orig_h) = (img.width(), img.height());
|
||||
|
||||
ThumbnailSize::all()
|
||||
.iter()
|
||||
.par_iter()
|
||||
.map(|&size| {
|
||||
let max_dim = size.max_dimension();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user