Skip to content

Commit 5107f26

Browse files
authored
Merge pull request #5078 from Widthdom/codex/split-large-types-20260812
Decompose large indexing and query orchestration
2 parents 35067ab + 068d1fb commit 5107f26

204 files changed

Lines changed: 35760 additions & 26693 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

TESTING_GUIDE.md

Lines changed: 40 additions & 14 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
category: fixed
3+
affected:
4+
- src/CodeIndex/Cli/QueryCommandRunner.Batch.cs
5+
- src/CodeIndex/Cli/QueryCommandRunner.BatchParallelExecution.cs
6+
---
7+
8+
## English
9+
10+
- **Parallel batch output limits no longer discard accepted, undispatched input records** — when `batch --parallel` reaches `--max-output-chars`, accepted nonblank input records that were not dispatched are returned to the shared bounded input pump in source order. The next batch invocation reparses those records with fresh line numbers and counters, ahead of input the pump already buffered, while commands that started remain owned by the first invocation.
11+
12+
## 日本語
13+
14+
- **parallel batch の出力上限で、受理済みかつ未 dispatch の input record が失われなくなりました**`batch --parallel``--max-output-chars` に達した場合、受理済みでも未 dispatch の nonblank input record を source 順のまま共有の bounded input pump に戻します。次の batch invocation は、すでに pump が buffer した入力より先にそれらの record を再 parse し、新しい line number と counter を割り当てます。開始済みの command は最初の invocation の所有のままです。
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
category: fixed
3+
affected:
4+
- src/CodeIndex/Database/CSharpBaseListParser.cs
5+
- src/CodeIndex/Database/DbContext.ConnectionFunctions.cs
6+
- src/CodeIndex/Database/DbReader.CSharpResolution.cs
7+
- src/CodeIndex/Database/DbWriter.CSharpMetadataTargets.cs
8+
---
9+
10+
## English
11+
12+
- **C# inheritance resolution now shares one grammar-aware base-list parser** — exact caller and metadata-target resolution no longer confuse generic `where` constraints with base types, and nested generics, tuples, arrays, alias qualifiers, and primary/base-constructor syntax are split consistently.
13+
14+
## 日本語
15+
16+
- **C# 継承解決が grammar-aware な base-list parser を共有するようになりました** — exact caller と metadata-target の解決で generic `where` constraint を基底型と誤認せず、nested generic、tuple、array、alias qualifier、primary / base constructor 構文を一貫して分割します。
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
category: fixed
3+
affected:
4+
- src/CodeIndex/Cli/IndexCommandRunner.FullScan.ExtractionPipeline.cs
5+
- src/CodeIndex/Cli/IndexCommandRunner.FullScan.ResultConsumer.cs
6+
- tests/CodeIndex.Tests/IndexCommandRunnerFullScanTests.cs
7+
---
8+
9+
## English
10+
11+
- **Full-scan extraction now preserves shared state and worker-resource ownership** — a later C# workspace drift no longer drops text-index mutations already committed for earlier files, and a fatal parallel worker result defers shared queue, cache, hook, and cancellation cleanup until every peer worker has stopped.
12+
13+
## 日本語
14+
15+
- **full-scan extraction が共有 state と worker resource の ownership を保持するようになりました** — 後段の C# workspace drift が先行 file で commit 済みの text-index mutation を失わず、parallel worker の fatal result では全 peer worker の停止まで共有 queue、cache、hook、cancellation の cleanup を延期します。
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
category: fixed
3+
affected:
4+
- src/CodeIndex/Database/DbReader.cs
5+
- src/CodeIndex/Database/DbSymbolReader.UnusedSymbols.Candidates.cs
6+
- src/CodeIndex/Database/DbSymbolReader.UnusedSymbols.cs
7+
---
8+
9+
## English
10+
11+
- **C# unused-symbol queries now remain safe on read-only legacy databases** — partial-type use filtering is applied before paging without issuing per-candidate database queries, while databases whose legacy chunk or symbol tables lack the required columns retain the existing degraded fallback instead of failing during SQL preparation.
12+
13+
## 日本語
14+
15+
- **C# の unused-symbol query が read-only legacy database でも安全に動作するようになりました** — partial type の使用判定を candidate ごとの database query なしで paging 前に適用し、必要な column が legacy chunk / symbol table にない database では SQL prepare で失敗せず、従来の degraded fallback を維持します。

src/CodeIndex/Cli/IndexCommandRunner.FileByteTracking.cs

Lines changed: 92 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -93,94 +93,113 @@ or NotSupportedException
9393
}
9494
}
9595

96-
private static bool ShouldUseFullScanFtsBulkLoad(
97-
bool rebuild,
98-
bool startedWithNoIndexedFiles,
99-
int extractionWorkItemCount,
100-
FilePurgePlan staleFilePurgePlan,
101-
bool scanHadErrors,
102-
ReadableFileByteTracker readableFileBytes,
103-
ReusableIndexedFileStatsSnapshot reusableIndexedFileStats,
104-
IReadOnlyList<FullScanFileTarget> fileTargets,
105-
IReadOnlyList<int>? extractionFileIndexes,
106-
Action throwIfCancelled)
96+
private sealed partial class FullScanPreWriteSession
10797
{
108-
if (rebuild || startedWithNoIndexedFiles)
109-
return true;
110-
if (extractionWorkItemCount == 0 && staleFilePurgePlan.Count == 0)
111-
return false;
112-
113-
var dirtyBytes = staleFilePurgePlan.DeletedBytes;
114-
var persistedSizeExcessBytes = 0L;
115-
var byteEstimateComplete = !scanHadErrors
116-
&& staleFilePurgePlan.ByteEstimateComplete
117-
&& readableFileBytes.EstimateComplete;
118-
119-
void AddDirtyFileBytes(int fileIndex)
98+
internal void DecideFtsBulkLoad()
12099
{
121-
throwIfCancelled();
122-
try
100+
var request = Request;
101+
var options = request.Core.Options;
102+
var baseline = request.Baseline;
103+
var runtime = request.Runtime;
104+
var scan = State.Scan;
105+
var csharp = State.CSharp;
106+
var selection = State.Selection;
107+
if (options.Rebuild || baseline.StartedWithNoIndexedFiles)
123108
{
124-
var target = fileTargets[fileIndex];
125-
var info = new FileInfo(target.FilePath);
126-
if (!info.Exists || info.Length < 0)
109+
selection.UseFtsBulkLoad = true;
110+
return;
111+
}
112+
113+
if (selection.ExtractionWorkItemCount == 0
114+
&& scan.StaleFilePurgePlan.Count == 0)
115+
{
116+
selection.UseFtsBulkLoad = false;
117+
return;
118+
}
119+
120+
var dirtyBytes = scan.StaleFilePurgePlan.DeletedBytes;
121+
var persistedSizeExcessBytes = 0L;
122+
var byteEstimateComplete = !baseline.ScanHadErrors
123+
&& scan.StaleFilePurgePlan.ByteEstimateComplete
124+
&& selection.ReadableFileBytes.EstimateComplete;
125+
126+
void AddDirtyFileBytes(int fileIndex)
127+
{
128+
ThrowIfFullScanCancelled();
129+
try
130+
{
131+
var target = runtime.FileTargets[fileIndex];
132+
var info = new FileInfo(target.FilePath);
133+
if (!info.Exists || info.Length < 0)
134+
{
135+
byteEstimateComplete = false;
136+
return;
137+
}
138+
139+
selection.ReadableFileBytes.Remember(
140+
fileIndex,
141+
info.Length);
142+
var persistedSize = csharp.ReusableIndexedFileStats!
143+
.GetPersistedSize(target.IndexPath);
144+
if (!FtsBulkLoadTriggerGuard.TryAccumulateDirtyFileBytes(
145+
dirtyBytes,
146+
persistedSizeExcessBytes,
147+
info.Length,
148+
persistedSize,
149+
out dirtyBytes,
150+
out persistedSizeExcessBytes))
151+
{
152+
byteEstimateComplete = false;
153+
}
154+
}
155+
catch (Exception ex) when (
156+
ex is IOException
157+
or UnauthorizedAccessException
158+
or NotSupportedException
159+
or ArgumentException)
127160
{
128161
byteEstimateComplete = false;
129-
return;
130162
}
163+
}
131164

132-
readableFileBytes.Remember(fileIndex, info.Length);
133-
var persistedSize = reusableIndexedFileStats.GetPersistedSize(target.IndexPath);
134-
if (!FtsBulkLoadTriggerGuard.TryAccumulateDirtyFileBytes(
135-
dirtyBytes,
136-
persistedSizeExcessBytes,
137-
info.Length,
138-
persistedSize,
139-
out dirtyBytes,
140-
out persistedSizeExcessBytes))
165+
if (selection.ExtractionFileIndexes != null)
166+
{
167+
foreach (var fileIndex in selection.ExtractionFileIndexes)
168+
AddDirtyFileBytes(fileIndex);
169+
}
170+
else
171+
{
172+
for (var fileIndex = 0;
173+
fileIndex < runtime.FileTargets.Length;
174+
fileIndex++)
141175
{
142-
byteEstimateComplete = false;
176+
AddDirtyFileBytes(fileIndex);
143177
}
144178
}
145-
catch (Exception ex) when (
146-
ex is IOException
147-
or UnauthorizedAccessException
148-
or NotSupportedException
149-
or ArgumentException)
179+
180+
byteEstimateComplete &=
181+
selection.ReadableFileBytes.EstimateComplete;
182+
var totalBytes = selection.ReadableFileBytes.KnownBytes;
183+
if (!selection.ReadableFileBytes.EstimateComplete
184+
|| totalBytes
185+
> long.MaxValue - scan.StaleFilePurgePlan.DeletedBytes)
150186
{
151187
byteEstimateComplete = false;
152188
}
153-
}
189+
else
190+
{
191+
totalBytes += scan.StaleFilePurgePlan.DeletedBytes;
192+
}
154193

155-
if (extractionFileIndexes != null)
156-
{
157-
foreach (var fileIndex in extractionFileIndexes)
158-
AddDirtyFileBytes(fileIndex);
159-
}
160-
else
161-
{
162-
for (var fileIndex = 0; fileIndex < fileTargets.Count; fileIndex++)
163-
AddDirtyFileBytes(fileIndex);
164-
}
194+
if (totalBytes > long.MaxValue - persistedSizeExcessBytes)
195+
byteEstimateComplete = false;
196+
else
197+
totalBytes += persistedSizeExcessBytes;
165198

166-
byteEstimateComplete &= readableFileBytes.EstimateComplete;
167-
var totalBytes = readableFileBytes.KnownBytes;
168-
if (!readableFileBytes.EstimateComplete
169-
|| totalBytes > long.MaxValue - staleFilePurgePlan.DeletedBytes)
170-
{
171-
byteEstimateComplete = false;
172-
}
173-
else
174-
{
175-
totalBytes += staleFilePurgePlan.DeletedBytes;
199+
selection.UseFtsBulkLoad = byteEstimateComplete
200+
&& FtsBulkLoadTriggerGuard.ShouldUseForDirtyBytes(
201+
dirtyBytes,
202+
totalBytes);
176203
}
177-
178-
if (totalBytes > long.MaxValue - persistedSizeExcessBytes)
179-
byteEstimateComplete = false;
180-
else
181-
totalBytes += persistedSizeExcessBytes;
182-
183-
return byteEstimateComplete
184-
&& FtsBulkLoadTriggerGuard.ShouldUseForDirtyBytes(dirtyBytes, totalBytes);
185204
}
186205
}

0 commit comments

Comments
 (0)