Skip to content

watcher: continuous auto-sync re-indexing churn on Windows (real driver of #832) #841

Open

Description

@DeusData

During the #833 review we found the reported 20GB RSS / 100% CPU / 600MB-per-minute growth on 65 markdown files (1.3MB) cannot be produced by a single index run — the reporter's own workaround (CBM_WORKERS=1 plus auto_index false) points at the auto-sync loop re-indexing continuously on Windows and leaking per cycle.

To investigate:

  • Why does the watcher consider an unchanged directory dirty every poll on Windows (mtime granularity? path-normalization mismatch in the git-status hash? CRLF)?
  • Per-cycle retention: what survives repeated index cycles (candidate: mimalloc page_reclaim_on_free=0 stranding pages of exited worker heaps — see fix: memory not released after indexing (20GB+ RSS for 5MB data) #833's one plausible line).
    Reproduction should loop N watcher cycles on an unchanged fixture on windows-latest and assert RSS returns to baseline after cbm_mem_collect.

Refs #832, #833.

Activity

  1. added
    bugSomething isn't working
    stability/performanceServer crashes, OOM, hangs, high CPU/memory
    windowsWindows-specific issues
    priority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.
    on Jul 4, 2026
  2. DeusData commented on Jul 8, 2026

    @DeusData
    OwnerAuthor

    v0.9.0 includes Windows watcher/runtime and memory-retention fixes that may change this continuous auto-sync churn path, and #832 is now awaiting a reporter retest on the same class of symptom. Could you retest the unchanged-directory watcher loop on v0.9.0 and confirm whether it still re-indexes continuously? Marking awaiting-reporter.

  3. added
    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then close
    on Jul 8, 2026
  4. github-actions commented on Jul 8, 2026

    @github-actions

    Thanks for the report! To move this forward we need a bit more so we can reproduce it ourselves:

    • the codebase-memory-mcp --version you're on
    • the exact steps or command you ran
    • a public repo (or a small dummy snippet) that shows the problem — please don't paste proprietary code

    Once that's here we'll pick it straight back up. Heads-up: issues left awaiting-reporter are automatically closed after a few weeks of silence, but a comment reopens the door anytime.

  5. added this to the 0.9.1-rc milestone on Jul 8, 2026
  6. DeusData commented on Jul 10, 2026

    @DeusData
    OwnerAuthor

    The linked reporter path has activity again, so I am removing awaiting-reporter here and keeping this in the 0.9.1-rc maintainer queue. The next step is still to verify the unchanged-directory watcher loop on Windows and separate watcher churn from any retained-memory behavior.

  7. removed
    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then close
    on Jul 10, 2026
  8. kevinkavi2001 commented on Aug 11, 2026

    @kevinkavi2001

    I can reproduce a deterministic Windows freshness false-positive that may help isolate the unchanged-directory churn tracked here.

    Environment

    • codebase-memory-mcp 0.10.0
    • Windows 10, amd64
    • Binary: C:\Users\Uzer\AppData\Local\Programs\codebase-memory-mcp\codebase-memory-mcp.exe
    • Project: D:\SuperDevPro
    • Filesystem: NTFS
    • Project is not a Git repository

    Reproduction

    1. Delete the existing project index.
    2. Run a clean full index_repository.
    3. Do not modify the repository files.
    4. Immediately call check_index_coverage for several exact paths.
    5. Compare the reported freshness with each file's fractional modification timestamp:
      os.stat(path).st_mtime_ns % 1_000_000_000.
    6. Reindex again and repeat the coverage check.

    Unchanged files with whole-second mtimes are reported correctly, while unchanged files with fractional-second mtimes are reported as changed:

    Path Fractional mtime Freshness result
    export-element/codepen.js 0 ns metadata_match
    content-scripts/content.css 0 ns metadata_match
    content-scripts/content.js 212663000 ns metadata_changed
    background.js 154049700 ns metadata_changed
    manifest.json 148551100 ns metadata_changed

    For the false positives, check_index_coverage also returns:

    recommended_action: read_source_and_reindex
    

    Reindexing does not clear the result.

    This reproduced after the original clean index and again after deleting the index and performing a second clean full rebuild. The second rebuild produced 309 nodes and 763 edges with .cbmignore exclusions applied and its UTF-8 BOM removed. Immediately afterward, the unchanged background.js and manifest.json files were still reported as metadata_changed.

    Expected behavior

    Unchanged files should report metadata_match immediately after a clean full index, regardless of whether their NTFS mtime includes a fractional second.

    Suspected cause

    The exact correlation suggests a Windows timestamp-normalization mismatch: index creation and freshness comparison may be storing or comparing NTFS subsecond mtimes at different precision.

    Because this project is non-git and I did not reproduce the watcher loop itself, this may be either a shared timestamp-normalization defect or a separate bug in the check_index_coverage freshness path.

  9. DeusData commented on Sep 19, 2026

    @DeusData
    OwnerAuthor

    Thank you for the controlled unchanged-file comparison and for explicitly separating it from watcher churn. Current Windows coverage checking in src/mcp/mcp.c uses whole-second stat timestamps, which is consistent with the precision mismatch you observed. I have not established that this causes the watcher loop. This evidence should be retained as a distinct freshness-comparison case; repeated reindexing is not a resolution when the unchanged file immediately reports changed again.

  10. DeusData commented on Oct 19, 2026

    @DeusData
    OwnerAuthor

    Thank you for the unchanged-file timestamp comparison. As the September reply noted, this is distinct evidence from the watcher-loop report, and repeated reindexing should not be requested as proof of a fix. I have no newly verified resolution for either path to add today.

  11. DeusData commented on Oct 25, 2026

    @DeusData
    OwnerAuthor

    Thank you for your patience. Sorry for the delay. The unchanged-file timestamp evidence remains separate from watcher churn, and both need maintainer follow-up. I’ll follow up soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.stability/performanceServer crashes, OOM, hangs, high CPU/memorywindowsWindows-specific issues

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions