Skip to content

Perf: reduce initial full-index extraction and reference work - #5386

Merged
Widthdom merged 7 commits into
mainfrom
perf/initial-full-index-throughput-20260918
Sep 19, 2026
Merged

Widthdom merged 7 commits into
mainfrom
perf/initial-full-index-throughput-20260918

Conversation

@Widthdom

@Widthdom Widthdom commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Summary

Initial full indexing repeatedly evaluates impossible declaration regexes, resolves identical reference sources, and scans unrelated same-name symbols or earlier occurrences on dense lines. These changes reduce that work while preserving the logical index contents and existing resolution rules.

  • Reject impossible C# declaration suffixes and add audited punctuation gates for C#, Java, Kotlin, C/C++, JavaScript and TypeScript, including C# aliases.
  • Resolve repeated fresh reference-source identities once per qualifying insertion batch, and seek candidates through the existing file/name and container/name indexes. These writer improvements apply across languages and preserve scoped and retained-graph refreshes.
  • Scan C# lambda captures once per body, reuse structured scope keys, and use proven recorded reference positions to avoid repeated line scans. Preserve Unicode/escaped identifiers, overlapping matches, ties and trimmed-column fallbacks.

Performance and compatibility

The benchmark uses the fixed a33c5a8eb source snapshot: 1,577 files, 59,387 symbols and 562,615 references. Each version was measured twice on macOS ARM64, Release .NET 8, with a new database and --parallelism 2 --memory-trace; heavy tests were stopped during measurement.

Independent comparison Mean elapsed time Change
Declaration suffixes, shared source lookups and lambda captures 72.9 s → 62.3 s About 15% lower
Punctuation gates, scoped candidate seeks and reference positions, relative to 8533dff4f 60.2 s → 44.7 s About 26% lower

Each percentage describes its own measurement session. The second comparison reduced total managed allocations from 8.09–8.10 GB to 7.48 GB (about 8%); the first comparison increased allocations from 7.93–7.96 GB to 8.10 GB.

All runs completed without warnings, errors or extraction cap hits. Logical file, chunk, symbol, reference-line, issue, reference and resolution-candidate records match after normalizing generated IDs and indexing timestamps. The fixture is C#-heavy; these measurements are not a general speed guarantee. Scoped candidate seeks add a small fixed cost for unique names or names already confined to eligible scopes; the measured tradeoff is documented.

Validation

  • Whole solution at 8d90c292b: dotnet test CodeIndex.sln -c Release --no-restore -p:UseSharedCompilation=false --settings tests/CodeIndex.Tests/CodeIndex.Tests.runsettings --blame-crash --blame-hang --blame-hang-timeout 5m.
  • .NET 8: 12,682 passed, 9 skipped, 0 failed. .NET 9: 12,188 passed, 435 skipped, 0 failed.
  • Cross-language output-parity tests and regression budgets for SQLite VM instructions, regex attempts, occurrence searches and allocations; no new wall-clock thresholds.
  • Bilingual changelog fragment validation and git diff --check passed.
  • Formatting correction 0d3027832: ./dev.sh lint passed (the same script invoked by CI's make lint), and both affected test classes passed all 57 cases on each of .NET 8 and .NET 9. Independent review confirmed that only test whitespace changed; production code and test semantics are unchanged.
  • Independent adversarial review of origin/main..HEAD: No blocking/actionable issues found.
  • Canonical index and workspace checks passed at the final commit: 1,585 matching files, both workspace members healthy.

Documentation and changelog

Updated TESTING_GUIDE.md and the English/Japanese measurement and compatibility notes in docs/initial-index-performance.md.

Bilingual fragments:

  • changelog.d/unreleased/+initial-index-confirmation-suffixes.changed.md
  • changelog.d/unreleased/+initial-index-shared-reference-sources.changed.md
  • changelog.d/unreleased/+initial-index-lambda-captures.changed.md
  • changelog.d/unreleased/+initial-index-scope-candidate-seeks.changed.md
  • changelog.d/unreleased/+initial-index-declaration-punctuation.changed.md
  • changelog.d/unreleased/+initial-index-reference-occurrences.changed.md

No issue auto-close references or separate follow-up candidates are included.

@Widthdom
Widthdom merged commit dd6f6fe into main Sep 19, 2026
11 checks passed
@Widthdom
Widthdom deleted the perf/initial-full-index-throughput-20260918 branch September 19, 2026 10:19
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.

1 participant