diff options
Diffstat (limited to '')
| -rw-r--r-- | pkgs/by-name/fi/fish-patched/package.nix | 8 | ||||
| -rw-r--r-- | pkgs/by-name/fi/fish-patched/patches/0003-feat-history-Add-turtle-as-history-backend.patch (renamed from pkgs/by-name/fi/fish-patched/0001-feat-history-Add-turtle-as-history-backend.patch) | 2 | ||||
| -rw-r--r-- | pkgs/by-name/fi/fish-patched/patches/0004-history-turtle-Fix-id-misuse-and-history-return-orde.patch | 50 | ||||
| -rw-r--r-- | pkgs/by-name/fi/fish-patched/patches/0005-history-history-Always-save-history-even-in-private-.patch | 32 | ||||
| -rw-r--r-- | pkgs/by-name/fi/fish-patched/patches/0006-history-turtle-Don-t-block-at-startup-and-wait-until.patch | 101 | ||||
| -rw-r--r-- | pkgs/by-name/fi/fish-patched/patches/0007-history-turtle-Don-t-reverse-newly-loaded-history.patch | 27 | ||||
| -rw-r--r-- | pkgs/by-name/fi/fish-patched/patches/0008-history-turtle-Reverse-history-upon-load.patch | 28 | ||||
| -rw-r--r-- | pkgs/by-name/fi/fish-patched/patches/0009-history-turtle-Do-more-work-in-the-command-handler-w.patch | 188 |
8 files changed, 432 insertions, 4 deletions
diff --git a/pkgs/by-name/fi/fish-patched/package.nix b/pkgs/by-name/fi/fish-patched/package.nix index f0546952..9d4bac75 100644 --- a/pkgs/by-name/fi/fish-patched/package.nix +++ b/pkgs/by-name/fi/fish-patched/package.nix @@ -29,7 +29,9 @@ in patches = (prev.patches or []) - ++ [ - ./0001-feat-history-Add-turtle-as-history-backend.patch - ]; + ++ ( + builtins.map (name: ./patches + "/${name}") + (builtins.attrNames + (builtins.readDir ./patches)) + ); }) diff --git a/pkgs/by-name/fi/fish-patched/0001-feat-history-Add-turtle-as-history-backend.patch b/pkgs/by-name/fi/fish-patched/patches/0003-feat-history-Add-turtle-as-history-backend.patch index 3e98b298..8eeb03b4 100644 --- a/pkgs/by-name/fi/fish-patched/0001-feat-history-Add-turtle-as-history-backend.patch +++ b/pkgs/by-name/fi/fish-patched/patches/0003-feat-history-Add-turtle-as-history-backend.patch @@ -1,7 +1,7 @@ From 26e8fbb5a24dd8b9cac67adcb59e714b32f95aa6 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz <benedikt.peetz@b-peetz.de> Date: Sat, 22 Aug 2026 22:42:44 +0200 -Subject: [PATCH 3/3] feat(history): Add turtle as history backend +Subject: [PATCH 03/10] feat(history): Add turtle as history backend --- Cargo.toml | 4 + diff --git a/pkgs/by-name/fi/fish-patched/patches/0004-history-turtle-Fix-id-misuse-and-history-return-orde.patch b/pkgs/by-name/fi/fish-patched/patches/0004-history-turtle-Fix-id-misuse-and-history-return-orde.patch new file mode 100644 index 00000000..4eb3220b --- /dev/null +++ b/pkgs/by-name/fi/fish-patched/patches/0004-history-turtle-Fix-id-misuse-and-history-return-orde.patch @@ -0,0 +1,50 @@ +From c4f1ff5812024e50f8c6cf825a81b654afada2a4 Mon Sep 17 00:00:00 2001 +From: Benedikt Peetz <benedikt.peetz@b-peetz.de> +Date: Sun, 23 Aug 2026 23:34:58 +0200 +Subject: [PATCH 04/10] history/turtle: Fix id misuse and history return order + +--- + src/history/turtle.rs | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/src/history/turtle.rs b/src/history/turtle.rs +index ffcdea108..862b7346b 100644 +--- a/src/history/turtle.rs ++++ b/src/history/turtle.rs +@@ -42,6 +42,10 @@ fn loaded_history(&mut self) -> &[History] { + if NEW_LOADED_HISTORY_AVAILABLE.load(Ordering::Relaxed) || should_wait { + if let Some(pre_loaded_history) = self.handler.load_history_resp(should_wait) { + self.loaded_history = pre_loaded_history; ++ ++ // HACK(@bpeetz): For some reason, the returned history is reversed. ++ // So we un-reverse it here. <2026-08-23> ++ self.loaded_history.reverse(); + } + + flogf!( +@@ -273,13 +277,19 @@ fn start(daemon_socket: String) -> Self { + + flogf!(history, " > Starting cmd '%s'", command); + +- let history_id = history.id; + let start_time = history.timestamp; + +- rt.block_on(client.start_history(history)) ++ let reply = rt ++ .block_on(client.start_history(history)) + .expect("client to still work"); + +- running_history.insert(command, (history_id, start_time)); ++ // NOTE(@bpeetz): We already _have_ an HistoryId on our history, ++ // but the turtle daemon will assign a new one. ++ // Therefore, we need to make sure, that we only use the id it has assigned. ++ // <2026-08-23> ++ let real_id = HistoryId::from(reply.id); ++ ++ running_history.insert(command, (real_id, start_time)); + } + HandleHistoryCmd::End { + command, +-- +2.55.0 + diff --git a/pkgs/by-name/fi/fish-patched/patches/0005-history-history-Always-save-history-even-in-private-.patch b/pkgs/by-name/fi/fish-patched/patches/0005-history-history-Always-save-history-even-in-private-.patch new file mode 100644 index 00000000..f55a6096 --- /dev/null +++ b/pkgs/by-name/fi/fish-patched/patches/0005-history-history-Always-save-history-even-in-private-.patch @@ -0,0 +1,32 @@ +From b113638a4a3283b95029fe67fe575ae37e1b768a Mon Sep 17 00:00:00 2001 +From: Benedikt Peetz <benedikt.peetz@b-peetz.de> +Date: Mon, 24 Aug 2026 21:12:01 +0200 +Subject: [PATCH 05/10] history/history: Always save history, even in private + mode + +--- + src/history/history.rs | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/history/history.rs b/src/history/history.rs +index 90cbfe6a9..b721e04df 100644 +--- a/src/history/history.rs ++++ b/src/history/history.rs +@@ -355,12 +355,12 @@ impl HistoryImpl { + /// Because the `path_get_data` function does not return error information, + /// we cannot provide more detail about the reason for the failure here. + fn history_file_path(&self) -> std::io::Result<Option<WString>> { ++ return Ok(Some(L!("/run/user/1000/turtle.sock").to_owned())); ++ + if self.name.is_empty() { + return Ok(None); + } + +- return Ok(Some(L!("/run/user/1000/turtle.sock").to_owned())); +- + let mut path = if let Some(custom_dir) = &self.custom_directory { + custom_dir.clone() + } else { +-- +2.55.0 + diff --git a/pkgs/by-name/fi/fish-patched/patches/0006-history-turtle-Don-t-block-at-startup-and-wait-until.patch b/pkgs/by-name/fi/fish-patched/patches/0006-history-turtle-Don-t-block-at-startup-and-wait-until.patch new file mode 100644 index 00000000..00fbc192 --- /dev/null +++ b/pkgs/by-name/fi/fish-patched/patches/0006-history-turtle-Don-t-block-at-startup-and-wait-until.patch @@ -0,0 +1,101 @@ +From c159bc0d6be03ce566a5a0e144a503d174aee91f Mon Sep 17 00:00:00 2001 +From: Benedikt Peetz <benedikt.peetz@b-peetz.de> +Date: Mon, 24 Aug 2026 21:18:39 +0200 +Subject: [PATCH 06/10] history/turtle: Don't block at startup, and wait until + history is loaded + +--- + src/history/turtle.rs | 49 +++---------------------------------------- + 1 file changed, 3 insertions(+), 46 deletions(-) + +diff --git a/src/history/turtle.rs b/src/history/turtle.rs +index 862b7346b..a1009a162 100644 +--- a/src/history/turtle.rs ++++ b/src/history/turtle.rs +@@ -31,16 +31,8 @@ struct HistoryDbInner { + + impl HistoryDbInner { + fn loaded_history(&mut self) -> &[History] { +- let should_wait = if self.loaded_history.is_empty() { +- // We are probably running this the first time. +- // Make sure, that we actually load something. +- true +- } else { +- false +- }; +- +- if NEW_LOADED_HISTORY_AVAILABLE.load(Ordering::Relaxed) || should_wait { +- if let Some(pre_loaded_history) = self.handler.load_history_resp(should_wait) { ++ if NEW_LOADED_HISTORY_AVAILABLE.load(Ordering::Relaxed) { ++ if let Some(pre_loaded_history) = self.handler.load_history_resp() { + self.loaded_history = pre_loaded_history; + + // HACK(@bpeetz): For some reason, the returned history is reversed. +@@ -237,8 +229,6 @@ enum HandleHistoryCmd { + } + + static HANDLER_IS_SHUTTING_DOWN: AtomicBool = AtomicBool::new(false); +-static LOAD_HISTORY_THREAD: RwLock<Option<Thread>> = RwLock::new(None); +-static LOAD_HISTORY_WAITING: AtomicBool = AtomicBool::new(false); + static NEW_LOADED_HISTORY_AVAILABLE: AtomicBool = AtomicBool::new(false); + + impl Handler { +@@ -325,16 +315,6 @@ fn start(daemon_socket: String) -> Self { + let mut output = loaded_history_return.write().expect("not poisioned"); + (*output) = Some(loaded_history); + NEW_LOADED_HISTORY_AVAILABLE.store(true, Ordering::Relaxed); +- +- if LOAD_HISTORY_WAITING.load(Ordering::Relaxed) { +- let read = LOAD_HISTORY_THREAD.read().expect("not poisioned"); +- let t = read +- .as_ref() +- .expect("is some, as a thread is marked as waiting"); +- +- LOAD_HISTORY_WAITING.store(false, Ordering::Relaxed); +- t.unpark(); +- } + } + } + } +@@ -364,7 +344,7 @@ fn stop(&mut self) { + flog!(history, "History db shutdown completed."); + } + +- fn load_history_resp(&self, should_wait: bool) -> Option<Vec<History>> { ++ fn load_history_resp(&self) -> Option<Vec<History>> { + let mut output = None; + let rx = &self.returned_loaded_history; + +@@ -372,29 +352,6 @@ fn load_history_resp(&self, should_wait: bool) -> Option<Vec<History>> { + read.clone_into(&mut output); + } + +- if should_wait && output.is_none() { +- { +- { +- let me = thread::current(); +- let mut write = LOAD_HISTORY_THREAD.write().expect("not poisioned"); +- (*write) = Some(me); +- } +- +- LOAD_HISTORY_WAITING.store(true, Ordering::Relaxed); +- while LOAD_HISTORY_WAITING.load(Ordering::Relaxed) { +- thread::park(); +- } +- +- { +- let mut write = LOAD_HISTORY_THREAD.write().expect("not poisioned"); +- (*write) = None; +- } +- } +- +- let read = rx.read().expect("not poisioned"); +- read.clone_into(&mut output); +- } +- + output + } + +-- +2.55.0 + diff --git a/pkgs/by-name/fi/fish-patched/patches/0007-history-turtle-Don-t-reverse-newly-loaded-history.patch b/pkgs/by-name/fi/fish-patched/patches/0007-history-turtle-Don-t-reverse-newly-loaded-history.patch new file mode 100644 index 00000000..1e75acaf --- /dev/null +++ b/pkgs/by-name/fi/fish-patched/patches/0007-history-turtle-Don-t-reverse-newly-loaded-history.patch @@ -0,0 +1,27 @@ +From dd41eb10eb76289504ff4c5457434c81112cb008 Mon Sep 17 00:00:00 2001 +From: Benedikt Peetz <benedikt.peetz@b-peetz.de> +Date: Mon, 24 Aug 2026 21:28:04 +0200 +Subject: [PATCH 07/10] history/turtle: Don't reverse newly loaded history + +--- + src/history/turtle.rs | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/src/history/turtle.rs b/src/history/turtle.rs +index a1009a162..2143f38a9 100644 +--- a/src/history/turtle.rs ++++ b/src/history/turtle.rs +@@ -34,10 +34,6 @@ fn loaded_history(&mut self) -> &[History] { + if NEW_LOADED_HISTORY_AVAILABLE.load(Ordering::Relaxed) { + if let Some(pre_loaded_history) = self.handler.load_history_resp() { + self.loaded_history = pre_loaded_history; +- +- // HACK(@bpeetz): For some reason, the returned history is reversed. +- // So we un-reverse it here. <2026-08-23> +- self.loaded_history.reverse(); + } + + flogf!( +-- +2.55.0 + diff --git a/pkgs/by-name/fi/fish-patched/patches/0008-history-turtle-Reverse-history-upon-load.patch b/pkgs/by-name/fi/fish-patched/patches/0008-history-turtle-Reverse-history-upon-load.patch new file mode 100644 index 00000000..b7331637 --- /dev/null +++ b/pkgs/by-name/fi/fish-patched/patches/0008-history-turtle-Reverse-history-upon-load.patch @@ -0,0 +1,28 @@ +From 5afaf63f339cfc183a8728363fbb34a710f0e2dc Mon Sep 17 00:00:00 2001 +From: Benedikt Peetz <benedikt.peetz@b-peetz.de> +Date: Mon, 24 Aug 2026 21:32:51 +0200 +Subject: [PATCH 08/10] history/turtle: Reverse history upon load + +For _some_ reason, that seems to improve performance by 5x?! +(I presume I'm just measuring wrong.) +--- + src/history/turtle.rs | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/history/turtle.rs b/src/history/turtle.rs +index 2143f38a9..4ac931a19 100644 +--- a/src/history/turtle.rs ++++ b/src/history/turtle.rs +@@ -34,6 +34,9 @@ fn loaded_history(&mut self) -> &[History] { + if NEW_LOADED_HISTORY_AVAILABLE.load(Ordering::Relaxed) { + if let Some(pre_loaded_history) = self.handler.load_history_resp() { + self.loaded_history = pre_loaded_history; ++ ++ // PERFORMANCE: That seems to improve performance? <2026-08-24> ++ self.loaded_history.reverse(); + } + + flogf!( +-- +2.55.0 + diff --git a/pkgs/by-name/fi/fish-patched/patches/0009-history-turtle-Do-more-work-in-the-command-handler-w.patch b/pkgs/by-name/fi/fish-patched/patches/0009-history-turtle-Do-more-work-in-the-command-handler-w.patch new file mode 100644 index 00000000..9e5fbecc --- /dev/null +++ b/pkgs/by-name/fi/fish-patched/patches/0009-history-turtle-Do-more-work-in-the-command-handler-w.patch @@ -0,0 +1,188 @@ +From b316b4952d46ad964aa8397f9a3e57de8ba98b3b Mon Sep 17 00:00:00 2001 +From: Benedikt Peetz <benedikt.peetz@b-peetz.de> +Date: Mon, 24 Aug 2026 21:43:45 +0200 +Subject: [PATCH 09/10] history/turtle: Do more work in the command handler, + when loading history + +--- + src/history/turtle.rs | 94 +++++++++++++++++++++++++++++-------------- + 1 file changed, 63 insertions(+), 31 deletions(-) + +diff --git a/src/history/turtle.rs b/src/history/turtle.rs +index 4ac931a19..15515fe15 100644 +--- a/src/history/turtle.rs ++++ b/src/history/turtle.rs +@@ -5,7 +5,7 @@ + atomic::{AtomicBool, Ordering}, + mpsc, + }, +- thread::{self, JoinHandle, Thread}, ++ thread::JoinHandle, + time::{Duration, SystemTime, UNIX_EPOCH}, + }; + +@@ -19,30 +19,40 @@ + + pub(crate) struct HistoryDb; + ++#[derive(Debug, Clone)] ++struct LoadedHistory { ++ map: HashMap<HistoryId, HistoryItem>, ++ ++ /// This field is effectively the same as `map.keys().collect()`. ++ /// ++ /// It just a cache. ++ keys: Vec<HistoryId>, ++} ++ + #[derive(Debug)] + struct HistoryDbInner { + range: Option<Range>, + session: uuid::Uuid, + +- loaded_history: Vec<History>, ++ loaded_history: LoadedHistory, + + handler: Handler, + } + + impl HistoryDbInner { +- fn loaded_history(&mut self) -> &[History] { ++ fn loaded_history(&mut self) -> &LoadedHistory { + if NEW_LOADED_HISTORY_AVAILABLE.load(Ordering::Relaxed) { + if let Some(pre_loaded_history) = self.handler.load_history_resp() { + self.loaded_history = pre_loaded_history; + + // PERFORMANCE: That seems to improve performance? <2026-08-24> +- self.loaded_history.reverse(); ++ self.loaded_history.keys.reverse(); + } + + flogf!( + history, + "Loaded history was requested, returning %d entries.", +- self.loaded_history.len() ++ self.loaded_history.map.len() + ); + + NEW_LOADED_HISTORY_AVAILABLE.store(false, Ordering::Relaxed); +@@ -73,14 +83,7 @@ pub(super) fn create_empty() -> Self { + + /// Return the offsets of items in this file. + pub(super) fn offsets(&self) -> Vec<HistoryId> { +- let out: Vec<_> = Self::with_inner_mut(|inner| { +- inner +- .loaded_history() +- .iter() +- .map(|h| h.id.clone()) +- .collect() +- }); +- out ++ Self::with_inner_mut(|inner| inner.loaded_history().keys.clone()) + } + + /// Return whether this file is empty. +@@ -111,7 +114,10 @@ pub(super) fn load(history_path: &WString, _boundary_timestamp: SystemTime) -> S + let inner = HistoryDbInner { + session: uuid::Uuid::now_v7(), + range, +- loaded_history: vec![], ++ loaded_history: LoadedHistory { ++ map: HashMap::new(), ++ keys: vec![], ++ }, + handler, + }; + +@@ -128,20 +134,7 @@ pub(super) fn load(history_path: &WString, _boundary_timestamp: SystemTime) -> S + + /// Decode an item at a given offset. + pub(super) fn decode_item(&self, id: HistoryId) -> Option<HistoryItem> { +- Self::with_inner_mut(|inner| { +- inner.loaded_history().iter().find(|h| h.id == id).map(|h| { +- HistoryItem::new( +- WString::from_str(&h.command), +- super::Timestamps { +- last_added: UNIX_EPOCH +- + Duration::from_nanos_u128(h.timestamp.unix_timestamp_nanos() as u128), +- first_added: UNIX_EPOCH +- + Duration::from_nanos_u128(h.timestamp.unix_timestamp_nanos() as u128), +- }, +- super::PersistenceMode::Disk, +- ) +- }) +- }) ++ Self::with_inner_mut(|inner| inner.loaded_history().map.get(&id).map(ToOwned::to_owned)) + } + } + +@@ -209,7 +202,7 @@ struct Handler { + + cmd_tx: Option<mpsc::Sender<HandleHistoryCmd>>, + +- returned_loaded_history: Arc<RwLock<Option<Vec<History>>>>, ++ returned_loaded_history: Arc<RwLock<Option<LoadedHistory>>>, + } + + #[derive(Debug)] +@@ -311,8 +304,47 @@ fn start(daemon_socket: String) -> Self { + base.expect("the client to still work") + }; + ++ let mut loaded_history_map = HashMap::new(); ++ ++ for item in loaded_history { ++ loaded_history_map.insert(item.id, { ++ HistoryItem::new( ++ WString::from_str(&item.command), ++ super::Timestamps { ++ last_added: UNIX_EPOCH ++ + Duration::from_nanos_u128( ++ item.timestamp.unix_timestamp_nanos() as u128, ++ ), ++ first_added: UNIX_EPOCH ++ + Duration::from_nanos_u128( ++ item.timestamp.unix_timestamp_nanos() as u128, ++ ), ++ }, ++ super::PersistenceMode::Disk, ++ ) ++ }); ++ } ++ ++ let keys = { ++ let mut base: Vec<_> = loaded_history_map ++ .iter() ++ .map(|(key, h)| (key, h.first_added_timestamp())) ++ .collect(); ++ ++ base.sort_by_key(|(_, time)| *time); ++ ++ // reverse this first here, so we can re-reverse it in the ++ // `loaded_history` function. ++ base.reverse(); ++ ++ base.into_iter().map(|(key, _)| key).copied().collect() ++ }; ++ + let mut output = loaded_history_return.write().expect("not poisioned"); +- (*output) = Some(loaded_history); ++ (*output) = Some(LoadedHistory { ++ keys, ++ map: loaded_history_map, ++ }); + NEW_LOADED_HISTORY_AVAILABLE.store(true, Ordering::Relaxed); + } + } +@@ -343,7 +375,7 @@ fn stop(&mut self) { + flog!(history, "History db shutdown completed."); + } + +- fn load_history_resp(&self) -> Option<Vec<History>> { ++ fn load_history_resp(&self) -> Option<LoadedHistory> { + let mut output = None; + let rx = &self.returned_loaded_history; + +-- +2.55.0 + |
