fix: limit concurrent thumbnail generation (#1138)

This commit is contained in:
Ashley Wulber 2025-08-13 13:00:07 -04:00 committed by GitHub
parent e3c793a44d
commit a4e3bf3eea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 0 deletions

1
Cargo.lock generated
View file

@ -1537,6 +1537,7 @@ dependencies = [
"mime_guess",
"notify-debouncer-full",
"notify-rust",
"num_cpus",
"once_cell",
"open",
"ordermap",

View file

@ -71,6 +71,7 @@ uzers = "0.12.1"
md-5 = "0.10.6"
png = "0.17.16"
jxl-oxide = { version = "0.12.2", features = ["image"] }
num_cpus = "1.17.0"
# Completion-based IO runtime to enable io_uring / IOCP file IO support.
[dependencies.compio]

View file

@ -95,6 +95,11 @@ const MAX_SEARCH_RESULTS: usize = 200;
//TODO: configurable thumbnail size?
const THUMBNAIL_SIZE: u32 = (ICON_SIZE_GRID as u32) * (ICON_SCALE_MAX as u32);
pub static THUMB_SEMAPHORE: LazyLock<tokio::sync::Semaphore> = LazyLock::new(|| {
tokio::sync::Semaphore::const_new(num_cpus::get())
});
pub(crate) static SORT_OPTION_FALLBACK: LazyLock<HashMap<String, (HeadingOptions, bool)>> =
LazyLock::new(|| {
HashMap::from_iter(dirs::download_dir().into_iter().map(|dir| {
@ -5634,6 +5639,7 @@ impl Tab {
let message = {
let path = path.clone();
_ = THUMB_SEMAPHORE.acquire().await;
tokio::task::spawn_blocking(move || {
let start = Instant::now();
let thumbnail = ItemThumbnail::new(