Skip to content

Reduce rebuild memory amplification - #5068

Merged
Widthdom merged 2 commits into
mainfrom
fix-issue5056
Aug 10, 2026
Merged

Reduce rebuild memory amplification#5068
Widthdom merged 2 commits into
mainfrom
fix-issue5056

Conversation

@Widthdom

Copy link
Copy Markdown
Owner

Summary

  • Reuse same-line C# recovery decisions across declaration-pattern candidates instead of repeating regex work for every pattern.
  • Temporarily disable SQLite memory mapping only during high-churn CLI/MCP bulk-load scopes, then restore the configured value on success, failure, and cancellation paths.
  • Add allocation and SQLite lifecycle regression tests, plus bilingual developer documentation and a changelog fragment.

Before/after profile

Same-machine Release rebuild command:

dotnet ./src/CodeIndex/bin/Release/net8.0/cdidx.dll index . --rebuild --yes --memory-trace --json --no-progress

Metric Before (fd3c303) After (71b4e920) Change
Elapsed 127,818 ms 128,568 ms +0.6%
Total allocated 22,456,726,496 bytes 19,239,696,416 bytes -14.3%
Peak working set 1,218,101,248 bytes 928,333,824 bytes -23.8%
Peak managed heap 161,139,736 bytes 158,261,816 bytes -1.8%

The after run indexed 1,261 files, persisted all 47,607 extracted symbols and all 477,700 extracted references, left every graph/index trust flag ready, and reported zero reference-cap hits. Relative to the baseline recorded in #5056, the after run reduced total allocations by 13.7%, peak working set by 31.9%, and elapsed time by 4.3%.

A stable synthetic regression fixture covering 1,000 dense C# generic properties measured 6,495,928 allocated bytes after the change versus 7,015,928 before it (-7.4%), with a 6,800,000-byte ceiling.

Validation

  • dotnet restore CodeIndex.sln
  • dotnet build CodeIndex.sln -c Release --no-restore -p:UseSharedCompilation=false — net8.0/net9.0, 0 warnings, 0 errors
  • Full Release suite before the final upstream merge:
    • net8.0: 11,211 passed, 7 skipped, 0 failed
    • net9.0: 10,744 passed, 413 skipped, 0 failed
  • Post-merge focused CLI/MCP indexing suite:
    • net8.0: 218 passed, 1 skipped, 0 failed
    • net9.0: 216 passed, 3 skipped, 0 failed
  • Post-merge new regression tests:
    • net8.0: 2 passed, 0 failed
    • net9.0: 1 passed, 1 expected framework skip, 0 failed
  • dotnet format CodeIndex.sln --verify-no-changes --no-restore
  • dotnet run --project tools/CodeIndex.Changelog -- check
  • Fresh local index status: 1,263 files, 47,681 symbols, 479,583 references; all completion/trust flags ready, zero cap hits, indexed HEAD matches the workspace
  • Codex adversarial review: no actionable defects found. The reviewer independently passed build, targeted tests, changelog validation, formatting verification, and diff checks. Its additional unfiltered Debug test attempt encountered an unrelated macOS temporary-keychain environment failure.

Documentation and changelog

  • Updated both English and Japanese SQLite tuning sections in DEVELOPER_GUIDE.md.
  • Added changelog.d/unreleased/5056.changed.md.

Follow-ups

None.

Fixes #5056

@Widthdom
Widthdom marked this pull request as ready for review August 10, 2026 06:10
@Widthdom
Widthdom merged commit 03554d0 into main Aug 10, 2026
11 checks passed
@Widthdom
Widthdom deleted the fix-issue5056 branch August 10, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce reference-graph rebuild allocation and working-set amplification

1 participant