fix: limit concurrent thumbnail generation (#1138)
This commit is contained in:
parent
e3c793a44d
commit
a4e3bf3eea
3 changed files with 8 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1537,6 +1537,7 @@ dependencies = [
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
"notify-debouncer-full",
|
"notify-debouncer-full",
|
||||||
"notify-rust",
|
"notify-rust",
|
||||||
|
"num_cpus",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"open",
|
"open",
|
||||||
"ordermap",
|
"ordermap",
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ uzers = "0.12.1"
|
||||||
md-5 = "0.10.6"
|
md-5 = "0.10.6"
|
||||||
png = "0.17.16"
|
png = "0.17.16"
|
||||||
jxl-oxide = { version = "0.12.2", features = ["image"] }
|
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.
|
# Completion-based IO runtime to enable io_uring / IOCP file IO support.
|
||||||
[dependencies.compio]
|
[dependencies.compio]
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,11 @@ const MAX_SEARCH_RESULTS: usize = 200;
|
||||||
//TODO: configurable thumbnail size?
|
//TODO: configurable thumbnail size?
|
||||||
const THUMBNAIL_SIZE: u32 = (ICON_SIZE_GRID as u32) * (ICON_SCALE_MAX as u32);
|
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)>> =
|
pub(crate) static SORT_OPTION_FALLBACK: LazyLock<HashMap<String, (HeadingOptions, bool)>> =
|
||||||
LazyLock::new(|| {
|
LazyLock::new(|| {
|
||||||
HashMap::from_iter(dirs::download_dir().into_iter().map(|dir| {
|
HashMap::from_iter(dirs::download_dir().into_iter().map(|dir| {
|
||||||
|
|
@ -5634,6 +5639,7 @@ impl Tab {
|
||||||
let message = {
|
let message = {
|
||||||
let path = path.clone();
|
let path = path.clone();
|
||||||
|
|
||||||
|
_ = THUMB_SEMAPHORE.acquire().await;
|
||||||
tokio::task::spawn_blocking(move || {
|
tokio::task::spawn_blocking(move || {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let thumbnail = ItemThumbnail::new(
|
let thumbnail = ItemThumbnail::new(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue