mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-22 19:14:31 +03:00
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.
This commit is contained in:
parent
843841981c
commit
b27fff77ad
@ -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<InternalEvent>,
|
||||
) -> Result<Debouncer<RecommendedWatcher, FileIdMap>> {
|
||||
) -> Result<Debouncer<RecommendedWatcher, NoCache>> {
|
||||
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(())
|
||||
}
|
||||
|
@ -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<F: DebounceEventHandler, T: Watcher, C: FileIdCache + S
|
||||
})
|
||||
}
|
||||
|
||||
/// Short function to create a new debounced watcher with the recommended debouncer and the built-in file ID cache.
|
||||
/// Short function to create a new debounced watcher with the recommended debouncer, without FileID cache for performance.
|
||||
///
|
||||
/// Timeout is the amount of time after which a debounced event is emitted.
|
||||
///
|
||||
@ -657,13 +654,13 @@ pub fn new_debouncer<F: DebounceEventHandler>(
|
||||
tick_rate: Option<Duration>,
|
||||
flush_after: Option<u32>,
|
||||
event_handler: F,
|
||||
) -> Result<Debouncer<RecommendedWatcher, FileIdMap>, Error> {
|
||||
new_debouncer_opt::<F, RecommendedWatcher, FileIdMap>(
|
||||
) -> Result<Debouncer<RecommendedWatcher, NoCache>, Error> {
|
||||
new_debouncer_opt::<F, RecommendedWatcher, NoCache>(
|
||||
timeout,
|
||||
tick_rate,
|
||||
flush_after,
|
||||
event_handler,
|
||||
FileIdMap::new(),
|
||||
NoCache,
|
||||
notify::Config::default(),
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user