From b27fff77ad061931bf6b8a1ce06c7fbe735c5151 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 16 Jun 2024 09:39:40 +0200 Subject: [PATCH] fix performance issue that seems to be introduced by the `FileIdMap` This disables the cache entirely which would have been the case before the refactor as well. This time, it's explicit though. --- crates/gitbutler-watcher/src/file_monitor.rs | 14 ++------------ .../gitbutler-watcher/vendor/debouncer/src/lib.rs | 11 ++++------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/crates/gitbutler-watcher/src/file_monitor.rs b/crates/gitbutler-watcher/src/file_monitor.rs index b7bb17498..a8ea3ccf0 100644 --- a/crates/gitbutler-watcher/src/file_monitor.rs +++ b/crates/gitbutler-watcher/src/file_monitor.rs @@ -6,7 +6,7 @@ use crate::events::InternalEvent; use anyhow::{anyhow, Context, Result}; use gitbutler_core::ops::OPLOG_FILE_NAME; use gitbutler_core::projects::ProjectId; -use gitbutler_notify_debouncer::{new_debouncer, Debouncer, FileIdMap}; +use gitbutler_notify_debouncer::{new_debouncer, Debouncer, NoCache}; use notify::RecommendedWatcher; use notify::Watcher; use tokio::task; @@ -55,7 +55,7 @@ pub fn spawn( project_id: ProjectId, worktree_path: &std::path::Path, out: tokio::sync::mpsc::UnboundedSender, -) -> Result> { +) -> Result> { let (notify_tx, notify_rx) = std::sync::mpsc::channel(); let mut debouncer = new_debouncer( DEBOUNCE_TIMEOUT, @@ -91,21 +91,11 @@ pub fn spawn( debouncer .watcher() .watch(worktree_path, notify::RecursiveMode::Recursive) - .map(|_| { - debouncer - .cache() - .add_root(worktree_path, notify::RecursiveMode::Recursive) - }) .and_then(|()| { if let Some(git_dir) = extra_git_dir_to_watch { debouncer .watcher() .watch(git_dir, notify::RecursiveMode::Recursive) - .map(|_| { - debouncer - .cache() - .add_root(git_dir, notify::RecursiveMode::Recursive) - }) } else { Ok(()) } diff --git a/crates/gitbutler-watcher/vendor/debouncer/src/lib.rs b/crates/gitbutler-watcher/vendor/debouncer/src/lib.rs index 7f67d6603..23db5b03c 100644 --- a/crates/gitbutler-watcher/vendor/debouncer/src/lib.rs +++ b/crates/gitbutler-watcher/vendor/debouncer/src/lib.rs @@ -44,14 +44,11 @@ use std::{ time::Duration, }; -#[allow(unused_imports)] pub use cache::{FileIdCache, FileIdMap, NoCache}; pub use event::DebouncedEvent; -#[allow(unused_imports)] pub use file_id; -#[allow(unused_imports)] pub use notify; use file_id::FileId; @@ -647,7 +644,7 @@ pub fn new_debouncer_opt( tick_rate: Option, flush_after: Option, event_handler: F, -) -> Result, Error> { - new_debouncer_opt::( +) -> Result, Error> { + new_debouncer_opt::( timeout, tick_rate, flush_after, event_handler, - FileIdMap::new(), + NoCache, notify::Config::default(), ) }