perf: switch to a higher-performance hash algorithm (#3083)

This commit is contained in:
三咲雅 misaki masa 2025-08-19 15:58:39 +08:00 committed by GitHub
parent ae75fc0f7b
commit 7a9bfff95d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 78 additions and 56 deletions

8
Cargo.lock generated
View file

@ -3464,7 +3464,6 @@ version = "25.6.11"
dependencies = [
"anyhow",
"crossterm 0.29.0",
"foldhash",
"futures",
"hashbrown",
"libc",
@ -3516,7 +3515,7 @@ name = "yazi-binding"
version = "25.6.11"
dependencies = [
"ansi-to-tui",
"foldhash",
"hashbrown",
"mlua",
"paste",
"ratatui",
@ -3540,6 +3539,7 @@ dependencies = [
"clap_complete_fig",
"clap_complete_nushell",
"futures",
"hashbrown",
"regex",
"serde",
"vergen-gitcl",
@ -3597,6 +3597,7 @@ dependencies = [
"crossterm 0.29.0",
"dirs",
"globset",
"hashbrown",
"indexmap",
"ratatui",
"regex",
@ -3728,6 +3729,7 @@ dependencies = [
"dirs",
"foldhash",
"futures",
"hashbrown",
"libc",
"objc",
"parking_lot",
@ -3777,6 +3779,7 @@ dependencies = [
"anyhow",
"crossterm 0.29.0",
"futures",
"hashbrown",
"libc",
"mlua",
"parking_lot",
@ -3831,6 +3834,7 @@ dependencies = [
"anyhow",
"async-priority-channel",
"futures",
"hashbrown",
"libc",
"lru 0.16.0",
"parking_lot",

View file

@ -30,7 +30,6 @@ yazi-widgets = { path = "../yazi-widgets", version = "25.6.11" }
# External dependencies
anyhow = { workspace = true }
crossterm = { workspace = true }
foldhash = { workspace = true }
futures = { workspace = true }
hashbrown = { workspace = true }
mlua = { workspace = true }

View file

@ -36,7 +36,7 @@ impl File {
folder: &yazi_core::tab::Folder,
tab: &yazi_core::tab::Tab,
) -> mlua::Result<AnyUserData> {
use std::collections::hash_map::Entry;
use hashbrown::hash_map::Entry;
Ok(match super::FILE_CACHE.borrow_mut().entry(PtrCell(&folder.files[idx])) {
Entry::Occupied(oe) => oe.into_mut().clone(),

View file

@ -1,6 +1,6 @@
use std::cell::RefCell;
use foldhash::HashMap;
use hashbrown::HashMap;
use mlua::{AnyUserData, UserData};
use scopeguard::defer;
use tracing::error;

View file

@ -1,7 +1,8 @@
use std::{borrow::Cow, collections::HashMap, ffi::{OsStr, OsString}, hash::Hash, io::{Read, Write}, ops::Deref, path::Path};
use std::{borrow::Cow, ffi::{OsStr, OsString}, hash::Hash, io::{Read, Write}, ops::Deref, path::Path};
use anyhow::{Result, anyhow};
use crossterm::{execute, style::Print};
use hashbrown::HashMap;
use scopeguard::defer;
use tokio::io::AsyncWriteExt;
use yazi_config::{YAZI, opener::OpenerRule};

View file

@ -21,7 +21,7 @@ yazi-shared = { path = "../yazi-shared", version = "25.6.11" }
# External dependencies
ansi-to-tui = { workspace = true }
foldhash = { workspace = true }
hashbrown = { workspace = true }
mlua = { workspace = true }
paste = { workspace = true }
ratatui = { workspace = true }

View file

@ -1,4 +1,4 @@
use foldhash::HashMap;
use hashbrown::HashMap;
use mlua::{Lua, MetaMethod, UserData, UserDataMethods, Value};
pub type ComposerGet = fn(&Lua, &[u8]) -> mlua::Result<Value>;

View file

@ -1,5 +1,6 @@
use std::collections::{HashMap, VecDeque};
use std::collections::VecDeque;
use hashbrown::HashMap;
use mlua::Function;
#[derive(Debug, Default)]

View file

@ -16,10 +16,11 @@ yazi-macro = { path = "../yazi-macro", version = "25.6.11" }
yazi-shared = { path = "../yazi-shared", version = "25.6.11" }
# External dependencies
clap = { workspace = true }
futures = { workspace = true }
regex = { workspace = true }
serde = { workspace = true }
clap = { workspace = true }
futures = { workspace = true }
hashbrown = { workspace = true }
regex = { workspace = true }
serde = { workspace = true }
[build-dependencies]
yazi-shared = { path = "../yazi-shared", version = "25.6.11" }

View file

@ -1,6 +1,7 @@
use std::{collections::HashSet, path::PathBuf};
use std::path::PathBuf;
use futures::executor::block_on;
use hashbrown::HashSet;
use serde::Serialize;
use yazi_fs::{CWD, Xdg, path::expand_url, provider};
use yazi_shared::url::{UrlBuf, UrnBuf};

View file

@ -21,6 +21,7 @@ bitflags = { workspace = true }
crossterm = { workspace = true }
dirs = { workspace = true }
globset = { workspace = true }
hashbrown = { workspace = true }
indexmap = { workspace = true }
ratatui = { workspace = true }
regex = { workspace = true }

View file

@ -1,6 +1,7 @@
use std::{collections::HashSet, ops::Deref};
use std::ops::Deref;
use anyhow::Result;
use hashbrown::HashSet;
use serde::Deserialize;
use yazi_codegen::DeserializeOver2;
use yazi_shared::Layer;

View file

@ -1,6 +1,7 @@
use std::{collections::HashMap, mem, ops::Deref};
use std::{mem, ops::Deref};
use anyhow::Result;
use hashbrown::HashMap;
use indexmap::IndexSet;
use serde::Deserialize;

View file

@ -1,6 +1,5 @@
use std::collections::HashSet;
use anyhow::Result;
use hashbrown::HashSet;
use serde::Deserialize;
use tracing::warn;
use yazi_codegen::DeserializeOver2;

View file

@ -1,6 +1,7 @@
use std::{collections::HashMap, ops::Deref};
use std::ops::Deref;
use anyhow::Result;
use hashbrown::HashMap;
use serde::{Deserialize, Deserializer};
use yazi_codegen::DeserializeOver2;
use yazi_fs::File;

View file

@ -1,5 +1,4 @@
use std::collections::HashMap;
use hashbrown::HashMap;
use yazi_parser::cmp::CmpItem;
use yazi_shared::{Id, url::UrlBuf};
use yazi_widgets::Scrollable;

View file

@ -1,5 +1,6 @@
use std::{collections::HashMap, iter, ops::{Deref, DerefMut}};
use std::{iter, ops::{Deref, DerefMut}};
use hashbrown::HashMap;
use yazi_shared::url::{Url, UrlBuf};
#[derive(Default)]

View file

@ -1,6 +1,7 @@
use std::{collections::{HashMap, HashSet}, time::Duration};
use std::time::Duration;
use anyhow::Result;
use hashbrown::{HashMap, HashSet};
use notify::{PollWatcher, RecommendedWatcher, RecursiveMode, Watcher as _Watcher};
use parking_lot::RwLock;
use tokio::{pin, sync::{mpsc::{self, UnboundedReceiver}, watch}};

View file

@ -1,6 +1,5 @@
use std::collections::HashMap;
use anyhow::Result;
use hashbrown::HashMap;
use yazi_fs::{Files, Filter, FilterCase};
use yazi_shared::url::{UrlBuf, Urn, UrnBuf};

View file

@ -1,5 +1,6 @@
use std::{borrow::Cow, collections::HashMap, ffi::OsString, mem};
use std::{borrow::Cow, ffi::OsString, mem};
use hashbrown::HashMap;
use yazi_config::{YAZI, opener::OpenerRule};
use yazi_parser::tasks::ProcessExecOpt;
use yazi_shared::url::UrlBuf;

View file

@ -1,6 +1,7 @@
use std::{collections::{HashMap, HashSet}, iter, mem, str::FromStr};
use std::{iter, mem, str::FromStr};
use anyhow::{Context, Result, bail};
use hashbrown::{HashMap, HashSet};
use parking_lot::RwLock;
use serde::{Deserialize, Serialize};
use tokio::{io::AsyncWriteExt, select, sync::mpsc, task::JoinHandle, time};

View file

@ -1,5 +1,6 @@
use std::{borrow::Cow, collections::HashMap};
use std::borrow::Cow;
use hashbrown::HashMap;
use mlua::{IntoLua, Lua, Value};
use serde::{Deserialize, Serialize};
use yazi_shared::url::UrlBuf;

View file

@ -1,5 +1,4 @@
use std::collections::HashMap;
use hashbrown::HashMap;
use mlua::{ExternalResult, IntoLua, Lua, Value};
use serde::{Deserialize, Serialize};
use yazi_shared::{Id, SStr};

View file

@ -1,5 +1,6 @@
use std::{borrow::Cow, collections::HashSet};
use std::borrow::Cow;
use hashbrown::HashSet;
use mlua::{ExternalResult, IntoLua, Lua, Value};
use serde::{Deserialize, Serialize};
use yazi_shared::SStr;

View file

@ -1,7 +1,5 @@
use std::collections::HashMap;
use anyhow::Result;
use hashbrown::HashSet;
use hashbrown::{HashMap, HashSet};
use mlua::Function;
use parking_lot::RwLock;
use yazi_boot::BOOT;

View file

@ -1,5 +1,6 @@
use std::{any::TypeId, borrow::Cow, collections::HashMap};
use std::{any::TypeId, borrow::Cow};
use hashbrown::HashMap;
use mlua::{ExternalError, IntoLua, Lua, MultiValue, Table, Value};
use ordered_float::OrderedFloat;
use yazi_shared::{event::{Data, DataKey}, replace_cow};

View file

@ -1,6 +1,7 @@
use std::{collections::HashMap, str::FromStr, time::Duration};
use std::{str::FromStr, time::Duration};
use anyhow::Result;
use hashbrown::HashMap;
use parking_lot::RwLock;
use tokio::{io::{AsyncBufReadExt, AsyncWriteExt, BufReader}, select, sync::mpsc::{self, UnboundedReceiver}, task::JoinHandle, time};
use yazi_macro::try_format;
@ -51,7 +52,7 @@ impl Server {
let mut parts = line.splitn(4, ',');
let Some(kind) = parts.next() else { continue };
let Some(receiver) = parts.next().and_then(|s| s.parse().ok()) else { continue };
let Some(receiver) = parts.next().and_then(|s| s.parse::<Id>().ok()) else { continue };
let Some(sender) = parts.next().and_then(|s| s.parse::<u64>().ok()) else { continue };
let clients = CLIENTS.read();

View file

@ -1,6 +1,7 @@
use std::{collections::HashMap, mem, ops::Deref, sync::atomic::{AtomicU64, Ordering}, time::UNIX_EPOCH};
use std::{mem, ops::Deref, sync::atomic::{AtomicU64, Ordering}, time::UNIX_EPOCH};
use anyhow::Result;
use hashbrown::HashMap;
use parking_lot::RwLock;
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufWriter};
use yazi_boot::BOOT;

View file

@ -20,6 +20,7 @@ bitflags = { workspace = true }
dirs = { workspace = true }
foldhash = { workspace = true }
futures = { workspace = true }
hashbrown = { workspace = true }
parking_lot = { workspace = true }
regex = { workspace = true }
scopeguard = { workspace = true }

View file

@ -1,5 +1,6 @@
use std::{collections::{HashMap, HashSet}, mem, ops::{Deref, DerefMut, Not}};
use std::{mem, ops::{Deref, DerefMut, Not}};
use hashbrown::{HashMap, HashSet};
use tokio::{select, sync::mpsc::{self, UnboundedReceiver}};
use yazi_shared::{Id, url::{UrlBuf, Urn, UrnBuf}};

View file

@ -1,8 +1,9 @@
// FIXME: VFS
use std::{borrow::Cow, collections::{HashMap, HashSet}, ffi::{OsStr, OsString}, path::{Path, PathBuf}};
use std::{borrow::Cow, ffi::{OsStr, OsString}, path::{Path, PathBuf}};
use anyhow::{Result, bail};
use hashbrown::{HashMap, HashSet};
use tokio::{fs, io, select, sync::{mpsc, oneshot}, time};
use yazi_shared::url::{Component, Url, UrlBuf};

View file

@ -1,6 +1,7 @@
use std::{borrow::Cow, collections::{HashMap, HashSet}, ffi::{OsStr, OsString}, os::{fd::AsFd, unix::{ffi::{OsStrExt, OsStringExt}, fs::MetadataExt}}, time::Duration};
use std::{borrow::Cow, ffi::{OsStr, OsString}, os::{fd::AsFd, unix::{ffi::{OsStrExt, OsStringExt}, fs::MetadataExt}}, time::Duration};
use anyhow::{Context, Result};
use hashbrown::{HashMap, HashSet};
use tokio::{io::{Interest, unix::AsyncFd}, time::sleep};
use tracing::error;
use yazi_shared::{natsort, replace_cow, replace_vec_cow};

View file

@ -14,7 +14,7 @@ pub static PARTITIONS: RoCell<Locked> = RoCell::new();
pub struct Partitions {
pub(super) inner: Vec<Partition>,
#[cfg(target_os = "linux")]
pub(super) linux_cache: std::collections::HashSet<String>,
pub(super) linux_cache: hashbrown::HashSet<String>,
#[cfg(target_os = "macos")]
pub(super) need_update: bool,
}

View file

@ -1,5 +1,4 @@
use std::collections::{HashMap, HashSet};
use hashbrown::{HashMap, HashSet};
use yazi_macro::relay;
use yazi_shared::{Id, Ids, url::{UrlBuf, UrnBuf}};

View file

@ -1,5 +1,6 @@
use std::{cmp::Ordering, collections::HashMap};
use std::cmp::Ordering;
use hashbrown::HashMap;
use yazi_shared::{LcgRng, natsort, translit::Transliterator, url::UrnBuf};
use crate::{File, SortBy};

View file

@ -1,6 +1,7 @@
use std::{collections::HashMap, fmt::Debug};
use std::fmt::Debug;
use anyhow::bail;
use hashbrown::HashMap;
use mlua::{Lua, Table};
use yazi_shared::{SStr, event::{Cmd, CmdCow, Data, DataKey}};

View file

@ -1,6 +1,5 @@
use std::collections::HashMap;
use anyhow::bail;
use hashbrown::HashMap;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::{CmdCow, Data, DataKey};

View file

@ -29,6 +29,7 @@ yazi-widgets = { path = "../yazi-widgets", version = "25.6.11" }
anyhow = { workspace = true }
crossterm = { workspace = true }
futures = { workspace = true }
hashbrown = { workspace = true }
mlua = { workspace = true }
parking_lot = { workspace = true }
paste = { workspace = true }

View file

@ -1,6 +1,7 @@
use std::{borrow::Cow, collections::HashMap, ops::Deref};
use std::{borrow::Cow, ops::Deref};
use anyhow::{Context, Result, bail};
use hashbrown::HashMap;
use mlua::{ChunkMode, ExternalError, Lua, Table};
use parking_lot::RwLock;
use yazi_boot::BOOT;

View file

@ -22,6 +22,7 @@ yazi-shared = { path = "../yazi-shared", version = "25.6.11" }
anyhow = { workspace = true }
async-priority-channel = "0.2.0"
futures = { workspace = true }
hashbrown = { workspace = true }
lru = { workspace = true }
parking_lot = { workspace = true }
scopeguard = { workspace = true }

View file

@ -1,6 +1,5 @@
use std::collections::HashMap;
use futures::future::BoxFuture;
use hashbrown::HashMap;
use yazi_shared::Id;
#[derive(Default)]

View file

@ -1,5 +1,4 @@
use std::collections::HashMap;
use hashbrown::HashMap;
use yazi_config::YAZI;
use yazi_parser::app::TasksProgress;
use yazi_shared::{Id, Ids};

View file

@ -1,6 +1,7 @@
use std::{collections::{HashMap, HashSet}, num::NonZeroUsize};
use std::num::NonZeroUsize;
use anyhow::{Result, anyhow};
use hashbrown::{HashMap, HashSet};
use lru::LruCache;
use parking_lot::{Mutex, RwLock};
use tokio::sync::mpsc;

View file

@ -1,6 +1,7 @@
use std::{any::Any, borrow::Cow, collections::HashMap, fmt::{self, Display}, mem, str::FromStr};
use std::{any::Any, borrow::Cow, fmt::{self, Display}, mem, str::FromStr};
use anyhow::{Result, anyhow, bail};
use hashbrown::HashMap;
use serde::{Deserialize, de};
use super::{Data, DataKey};

View file

@ -1,6 +1,7 @@
use std::{any::Any, borrow::Cow, collections::HashMap};
use std::{any::Any, borrow::Cow};
use anyhow::{Result, bail};
use hashbrown::HashMap;
use ordered_float::OrderedFloat;
use serde::{Deserialize, Serialize, de};