Refactor VFS event logging and streamline ServeSession watch setup

- Changed VFS event logging from INFO to DEBUG level for better performance and reduced verbosity during normal operations.
- Removed unnecessary project folder variable and redundant watch calls in ServeSession, enhancing clarity and efficiency in the watch setup process.
This commit is contained in:
Joe 2026-03-07 14:41:17 -06:00
parent 9ed8cf3f37
commit 345d36cda5
2 changed files with 11 additions and 17 deletions

View file

@ -657,14 +657,11 @@ impl JobThreadContext {
} }
fn handle_vfs_event(&self, event: VfsEvent) -> Vec<AppliedPatchSet> { fn handle_vfs_event(&self, event: VfsEvent) -> Vec<AppliedPatchSet> {
// Log EVERY VFS event at INFO level for diagnostics.
// This is intentionally verbose — it is critical for debugging
// file watcher desync issues (e.g., rapid delete+recreate).
match &event { match &event {
VfsEvent::Create(path) => log::info!("VFS event: CREATE {}", self.display_path(path)), VfsEvent::Create(path) => log::debug!("VFS event: CREATE {}", self.display_path(path)),
VfsEvent::Write(path) => log::info!("VFS event: WRITE {}", self.display_path(path)), VfsEvent::Write(path) => log::debug!("VFS event: WRITE {}", self.display_path(path)),
VfsEvent::Remove(path) => log::info!("VFS event: REMOVE {}", self.display_path(path)), VfsEvent::Remove(path) => log::debug!("VFS event: REMOVE {}", self.display_path(path)),
_ => log::info!("VFS event: OTHER {:?}", event), _ => log::debug!("VFS event: OTHER {:?}", event),
} }
// Check if this event should be suppressed (one-shot, from API syncback). // Check if this event should be suppressed (one-shot, from API syncback).
@ -699,7 +696,7 @@ impl JobThreadContext {
self.vfs self.vfs
.commit_event(&event) .commit_event(&event)
.expect("Error applying VFS change"); .expect("Error applying VFS change");
log::info!( log::debug!(
"VFS event SUPPRESSED (API syncback echo): {}", "VFS event SUPPRESSED (API syncback echo): {}",
self.display_path(path) self.display_path(path)
); );
@ -726,7 +723,7 @@ impl JobThreadContext {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
if let VfsEvent::Write(ref path) = event { if let VfsEvent::Write(ref path) = event {
if path.is_dir() { if path.is_dir() {
log::info!( log::debug!(
"VFS event SKIPPED (directory WRITE, deferring to file events): {}", "VFS event SKIPPED (directory WRITE, deferring to file events): {}",
self.display_path(path) self.display_path(path)
); );

View file

@ -370,7 +370,6 @@ impl ServeSession {
vfs.clear_prefetch_cache(); vfs.clear_prefetch_cache();
let patch_start = Instant::now(); let patch_start = Instant::now();
let project_folder = root_project.folder_location().to_path_buf();
let watch_ignore_rules = root_project.path_ignore_rules(); let watch_ignore_rules = root_project.path_ignore_rules();
std::thread::scope(|s| { std::thread::scope(|s| {
s.spawn(|| { s.spawn(|| {
@ -386,6 +385,11 @@ impl ServeSession {
// watches are required because kqueue directory watches // watches are required because kqueue directory watches
// only fire for structural changes, not child content edits. // only fire for structural changes, not child content edits.
let passes_ignore = |entry: &walkdir::DirEntry| -> bool { let passes_ignore = |entry: &walkdir::DirEntry| -> bool {
if let Some(name) = entry.file_name().to_str() {
if matches!(name, ".git" | ".hg" | ".svn") {
return false;
}
}
watch_ignore_rules watch_ignore_rules
.iter() .iter()
.all(|rule: &PathIgnoreRule| rule.passes(entry.path())) .all(|rule: &PathIgnoreRule| rule.passes(entry.path()))
@ -393,7 +397,6 @@ impl ServeSession {
vfs.set_watch_recursive(false); vfs.set_watch_recursive(false);
for root in &path_roots { for root in &path_roots {
for entry in WalkDir::new(root) for entry in WalkDir::new(root)
.follow_links(true)
.into_iter() .into_iter()
.filter_entry(&passes_ignore) .filter_entry(&passes_ignore)
.flatten() .flatten()
@ -402,8 +405,6 @@ impl ServeSession {
watch_count += 1; watch_count += 1;
} }
} }
let _ = vfs.watch(&project_folder);
watch_count += 1;
vfs.set_watch_recursive(true); vfs.set_watch_recursive(true);
} else { } else {
// Linux/Windows: inotify uses a single FD for all watches, // Linux/Windows: inotify uses a single FD for all watches,
@ -415,10 +416,6 @@ impl ServeSession {
let _ = vfs.watch(root); let _ = vfs.watch(root);
watch_count += 1; watch_count += 1;
} }
vfs.set_watch_recursive(false);
let _ = vfs.watch(&project_folder);
vfs.set_watch_recursive(true);
watch_count += 1;
} }
log::debug!( log::debug!(
"Set up {} watches in {:.1?}", "Set up {} watches in {:.1?}",