Skip to content

index --watch should cap pending path batches and fall back to full rescan #2903

Description

@Widthdom

Problem

FileChangeBatcher keeps pending filesystem events in an unbounded HashSet<string>. Add records every changed path until the debounce window drains, and TryDrain snapshots the whole set into a new List<string>. A sustained event storm with many unique paths can grow memory before watch mode has a chance to process the batch.

Suggested fix

Add a maximum pending path count or byte budget. When the budget is exceeded, collapse the batch into a full rescan request and clear individual path storage.

Evidence

  • src/CodeIndex/Cli/IndexWatchRunner.cs: FileChangeBatcher
  • _pending
  • Add
  • TryDrain

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions