From b1789a37beb113c09ab8f008db7cc4892bd90bcd Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 12 Feb 2026 01:44:39 -0600 Subject: [PATCH] Refactor VFS event handling in ChangeProcessor - Removed redundant logic for draining and discarding stale VFS events after reconciliation, streamlining the event processing flow. - Simplified the handling of queued VFS events to improve performance and reduce potential backlog issues. These changes enhance the efficiency of the ChangeProcessor by optimizing VFS event management. --- src/change_processor.rs | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/src/change_processor.rs b/src/change_processor.rs index e849a5ef..d28a6411 100644 --- a/src/change_processor.rs +++ b/src/change_processor.rs @@ -121,22 +121,6 @@ impl ChangeProcessor { select! { recv(vfs_receiver) -> event => { task.handle_vfs_event(event?); - - // Drain any additional queued VFS events without - // blocking. This prevents a backlog of hundreds - // of events from holding the tree lock for minutes. - let mut drained = 0u64; - while let Ok(extra) = vfs_receiver.try_recv() { - task.handle_vfs_event(extra); - drained += 1; - } - if drained > 0 { - log::debug!( - "Drained {} additional VFS events from backlog", - drained - ); - } - task.process_pending_recoveries(); // Schedule a reconciliation 200ms from now if one isn't pending. @@ -151,22 +135,6 @@ impl ChangeProcessor { if reconcile_at.is_some_and(|d| Instant::now() >= d) { task.reconcile_tree(); reconcile_at = None; - - // After reconciliation, drain and discard any pending - // VFS events. The reconciliation already computed the - // correct state from disk — stale events would only - // re-introduce drift (they reference paths from before - // the reconciliation). - let mut discarded = 0u64; - while vfs_receiver.try_recv().is_ok() { - discarded += 1; - } - if discarded > 0 { - log::info!( - "Discarded {} stale VFS events after reconciliation", - discarded - ); - } } }, recv(tree_mutation_receiver) -> patch_set => { @@ -180,8 +148,6 @@ impl ChangeProcessor { ); task.reconcile_tree(); reconcile_at = None; - // Drain stale events after reconciliation - while vfs_receiver.try_recv().is_ok() {} } }, recv(shutdown_receiver) -> _ => { @@ -195,8 +161,6 @@ impl ChangeProcessor { if reconcile_at.is_some_and(|d| Instant::now() >= d) { task.reconcile_tree(); reconcile_at = None; - // Drain stale events after reconciliation - while vfs_receiver.try_recv().is_ok() {} } }, }