mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-26 23:59:19 +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 anyhow::{anyhow, Context, Result};
|
||||||
use gitbutler_core::ops::OPLOG_FILE_NAME;
|
use gitbutler_core::ops::OPLOG_FILE_NAME;
|
||||||
use gitbutler_core::projects::ProjectId;
|
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::RecommendedWatcher;
|
||||||
use notify::Watcher;
|
use notify::Watcher;
|
||||||
use tokio::task;
|
use tokio::task;
|
||||||
@ -55,7 +55,7 @@ pub fn spawn(
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
worktree_path: &std::path::Path,
|
worktree_path: &std::path::Path,
|
||||||
out: tokio::sync::mpsc::UnboundedSender<InternalEvent>,
|
out: tokio::sync::mpsc::UnboundedSender<InternalEvent>,
|
||||||
) -> Result<Debouncer<RecommendedWatcher, FileIdMap>> {
|
) -> Result<Debouncer<RecommendedWatcher, NoCache>> {
|
||||||
let (notify_tx, notify_rx) = std::sync::mpsc::channel();
|
let (notify_tx, notify_rx) = std::sync::mpsc::channel();
|
||||||
let mut debouncer = new_debouncer(
|
let mut debouncer = new_debouncer(
|
||||||
DEBOUNCE_TIMEOUT,
|
DEBOUNCE_TIMEOUT,
|
||||||
@ -91,21 +91,11 @@ pub fn spawn(
|
|||||||
debouncer
|
debouncer
|
||||||
.watcher()
|
.watcher()
|
||||||
.watch(worktree_path, notify::RecursiveMode::Recursive)
|
.watch(worktree_path, notify::RecursiveMode::Recursive)
|
||||||
.map(|_| {
|
|
||||||
debouncer
|
|
||||||
.cache()
|
|
||||||
.add_root(worktree_path, notify::RecursiveMode::Recursive)
|
|
||||||
})
|
|
||||||
.and_then(|()| {
|
.and_then(|()| {
|
||||||
if let Some(git_dir) = extra_git_dir_to_watch {
|
if let Some(git_dir) = extra_git_dir_to_watch {
|
||||||
debouncer
|
debouncer
|
||||||
.watcher()
|
.watcher()
|
||||||
.watch(git_dir, notify::RecursiveMode::Recursive)
|
.watch(git_dir, notify::RecursiveMode::Recursive)
|
||||||
.map(|_| {
|
|
||||||
debouncer
|
|
||||||
.cache()
|
|
||||||
.add_root(git_dir, notify::RecursiveMode::Recursive)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,11 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
pub use cache::{FileIdCache, FileIdMap, NoCache};
|
pub use cache::{FileIdCache, FileIdMap, NoCache};
|
||||||
pub use event::DebouncedEvent;
|
pub use event::DebouncedEvent;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
pub use file_id;
|
pub use file_id;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
pub use notify;
|
pub use notify;
|
||||||
|
|
||||||
use file_id::FileId;
|
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.
|
/// 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>,
|
tick_rate: Option<Duration>,
|
||||||
flush_after: Option<u32>,
|
flush_after: Option<u32>,
|
||||||
event_handler: F,
|
event_handler: F,
|
||||||
) -> Result<Debouncer<RecommendedWatcher, FileIdMap>, Error> {
|
) -> Result<Debouncer<RecommendedWatcher, NoCache>, Error> {
|
||||||
new_debouncer_opt::<F, RecommendedWatcher, FileIdMap>(
|
new_debouncer_opt::<F, RecommendedWatcher, NoCache>(
|
||||||
timeout,
|
timeout,
|
||||||
tick_rate,
|
tick_rate,
|
||||||
flush_after,
|
flush_after,
|
||||||
event_handler,
|
event_handler,
|
||||||
FileIdMap::new(),
|
NoCache,
|
||||||
notify::Config::default(),
|
notify::Config::default(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user