From bf1274315dbcef858b46a55f212cfa34b916c3d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20misaki=20masa?= Date: Fri, 26 Jun 2026 15:19:15 +0800 Subject: [PATCH 1/2] perf: switch memory allocator back to jemalloc (#4084) --- .cargo/config.toml | 13 ++++++++++++- Cargo.lock | 40 +++++++++++++++++++++------------------- nix/yazi-unwrapped.nix | 5 +++++ yazi-fm/Cargo.toml | 2 +- yazi-fm/src/main.rs | 2 +- 5 files changed, 40 insertions(+), 22 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 9d806a3c..df06aa5e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,16 @@ [env] -MACOSX_DEPLOYMENT_TARGET = "10.12" +MACOSX_DEPLOYMENT_TARGET = "10.12" +JEMALLOC_SYS_WITH_LG_PAGE = "16" + +# environment variable for tikv-jemalloc-sys +# +# https://jemalloc.net/jemalloc.3.html#opt.narenas +# narenas is the maximum number of arenas to use for automatic multiplexing +# of threads and arenas. The default is four times the number of CPUs, +# or one if there is a single CPU. +# +# Improve memory efficiency by reducing fragmentation and ensuring all threads allocate from the same pool +JEMALLOC_SYS_WITH_MALLOC_CONF = "narenas:1" [target.aarch64-apple-darwin] rustflags = [ "-Ctarget-cpu=apple-m1" ] diff --git a/Cargo.lock b/Cargo.lock index 2d740e82..254299f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1896,15 +1896,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" -[[package]] -name = "libmimalloc-sys" -version = "0.1.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a45a52f43e1c16f667ccfe4dd8c85b7f7c204fd5e3bf46c5b0db9a5c3c0b8e9" -dependencies = [ - "cc", -] - [[package]] name = "libredox" version = "0.1.17" @@ -2020,15 +2011,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "mimalloc" -version = "0.1.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d4139bb28d14ad1facf21d5eb8825051b326e172d216b39f6d31df53cc97862" -dependencies = [ - "libmimalloc-sys", -] - [[package]] name = "miniz_oxide" version = "0.8.9" @@ -3827,6 +3809,26 @@ dependencies = [ "zune-jpeg", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.6.1+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd8aa5b2ab86a2cefa406d889139c162cbb230092f7d1d7cbc1716405d852a3b" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0359b4327f954e0567e69fb191cf1436617748813819c94b8cd4a431422d053a" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.51" @@ -4978,12 +4980,12 @@ dependencies = [ "better-panic", "fdlimit", "libc", - "mimalloc", "mlua", "paste", "ratatui-core", "ratatui-widgets", "signal-hook-tokio", + "tikv-jemallocator", "tokio", "tokio-stream", "tracing", diff --git a/nix/yazi-unwrapped.nix b/nix/yazi-unwrapped.nix index 2c223485..2cae987c 100644 --- a/nix/yazi-unwrapped.nix +++ b/nix/yazi-unwrapped.nix @@ -7,6 +7,7 @@ installShellFiles, fetchFromGitHub, + rust-jemalloc-sys, imagemagick, }: @@ -40,6 +41,10 @@ rustPlatform.buildRustPackage (finalAttrs: { imagemagick ]; + buildInputs = [ + rust-jemalloc-sys + ]; + postInstall = '' installShellCompletion --cmd yazi \ --bash ./yazi-boot/completions/yazi.bash \ diff --git a/yazi-fm/Cargo.toml b/yazi-fm/Cargo.toml index 57bf8bb1..f8f04d3d 100644 --- a/yazi-fm/Cargo.toml +++ b/yazi-fm/Cargo.toml @@ -59,7 +59,7 @@ libc = { workspace = true } signal-hook-tokio = { version = "0.4.0", features = [ "futures-v0_3" ] } [target.'cfg(all(not(target_os = "macos"), not(target_os = "windows")))'.dependencies] -mimalloc = "0.1.52" +tikv-jemallocator = "0.6.1" [[bin]] name = "yazi" diff --git a/yazi-fm/src/main.rs b/yazi-fm/src/main.rs index 85e993d5..f6710142 100644 --- a/yazi-fm/src/main.rs +++ b/yazi-fm/src/main.rs @@ -1,6 +1,6 @@ #[cfg(all(not(target_os = "macos"), not(target_os = "windows")))] #[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; yazi_macro::mod_pub!(app cmp confirm help input mgr notify pick spot tasks which); From 3aaf64ebb71e08519ac8a23ec859ad326c0d9b19 Mon Sep 17 00:00:00 2001 From: Yahddyyp Date: Fri, 3 Jul 2026 21:02:57 +0530 Subject: [PATCH 2/2] feat: add filter_keyword style to header indicator defaults to red, bold; can be changed by setting filter_keyword = { fg = "red", bold = true } in the [mgr] section --- yazi-config/preset/theme-dark.toml | 1 + yazi-config/preset/theme-light.toml | 1 + yazi-config/src/theme/theme.rs | 3 +++ yazi-plugin/preset/components/header.lua | 12 +++++++++--- yazi-plugin/src/theme/theme.rs | 2 ++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/yazi-config/preset/theme-dark.toml b/yazi-config/preset/theme-dark.toml index 90d6eca6..9891a12c 100644 --- a/yazi-config/preset/theme-dark.toml +++ b/yazi-config/preset/theme-dark.toml @@ -28,6 +28,7 @@ overall = {} [mgr] cwd = { fg = "cyan" } +filter_keyword = { fg = "red", bold = true } # Find find_keyword = { fg = "yellow", bold = true, italic = true, underline = true } diff --git a/yazi-config/preset/theme-light.toml b/yazi-config/preset/theme-light.toml index 43cf9552..44bbe12a 100644 --- a/yazi-config/preset/theme-light.toml +++ b/yazi-config/preset/theme-light.toml @@ -28,6 +28,7 @@ overall = {} [mgr] cwd = { fg = "cyan" } +filter_keyword = { fg = "red", bold = true } # Find find_keyword = { fg = "yellow", bold = true, italic = true, underline = true } diff --git a/yazi-config/src/theme/theme.rs b/yazi-config/src/theme/theme.rs index 4998eae1..2adb34fd 100644 --- a/yazi-config/src/theme/theme.rs +++ b/yazi-config/src/theme/theme.rs @@ -71,6 +71,9 @@ pub struct Mgr { pub find_keyword: SyncCell, pub find_position: SyncCell, + // Filter + pub filter_keyword: SyncCell, + // Symlink pub symlink_target: SyncCell, diff --git a/yazi-plugin/preset/components/header.lua b/yazi-plugin/preset/components/header.lua index 494d06a4..394bd224 100644 --- a/yazi-plugin/preset/components/header.lua +++ b/yazi-plugin/preset/components/header.lua @@ -27,8 +27,14 @@ function Header:cwd() return "" end - local s = ya.readable_path(tostring(self._current.cwd)) .. self:flags() - return ui.Span(ui.truncate(s, { max = max, rtl = true })):style(th.mgr.cwd) + local path = ya.readable_path(tostring(self._current.cwd)) + local flags = self:flags() + local flag_str = #flags == 0 and "" or " (" .. table.concat(flags, ", ") .. ")" + + return ui.Line { + ui.Span(ui.truncate(path, { max = max - #flag_str, rtl = true })):style(th.mgr.cwd), + ui.Span(flag_str):style(th.mgr.filter_keyword), + } end function Header:flags() @@ -46,7 +52,7 @@ function Header:flags() if finder then t[#t + 1] = string.format("find: %s", finder) end - return #t == 0 and "" or " (" .. table.concat(t, ", ") .. ")" + return t end function Header:count() diff --git a/yazi-plugin/src/theme/theme.rs b/yazi-plugin/src/theme/theme.rs index 8460b169..aeffe051 100644 --- a/yazi-plugin/src/theme/theme.rs +++ b/yazi-plugin/src/theme/theme.rs @@ -59,6 +59,8 @@ fn mgr() -> Composer { b"find_keyword" => Style::from(&m.find_keyword).into_lua(lua), b"find_position" => Style::from(&m.find_position).into_lua(lua), + b"filter_keyword" => Style::from(&m.filter_keyword).into_lua(lua), + b"symlink_target" => Style::from(&m.symlink_target).into_lua(lua), b"marker_copied" => Style::from(&m.marker_copied).into_lua(lua),