From 69ea88ccc5ea18cd81443a1b8ad81f26809fc562 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 17 Jun 2025 15:52:17 -0700 Subject: [PATCH] reduce codebase indexer file batch size --- core/indexing/CodebaseIndexer.test.ts | 10 +--------- core/indexing/CodebaseIndexer.ts | 14 +++++--------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index b697520aa..f2a31209c 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -124,14 +124,6 @@ describe("CodebaseIndexer", () => { return updates; } - async function refreshIndexFiles(files: string[]) { - const updates = []; - for await (const update of codebaseIndexer.refreshFiles(files)) { - updates.push(update); - } - return updates; - } - async function getAllIndexedFiles() { const files = await testIndex.getIndexedFilesForTags( await testIde.getTags(testIndex.artifactId), @@ -197,7 +189,7 @@ describe("CodebaseIndexer", () => { test("should successfuly re-index specific files", async () => { // Could add more specific tests for this but uses similar logic const before = await getAllIndexedFiles(); - await refreshIndexFiles(before); + await codebaseIndexer.refreshCodebaseIndexFiles(before); const after = await getAllIndexedFiles(); expect(after.length).toBe(before.length); diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index 86933f8bd..d2de0c512 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -43,7 +43,7 @@ export class CodebaseIndexer { * - To limit memory usage for indexes that perform computations locally, e.g. FTS * - To make as few requests as possible to the embeddings providers */ - filesPerBatch = 500; + filesPerBatch = 200; private indexingCancellationController: AbortController | undefined; private codebaseIndexingState: IndexingProgressUpdate; private readonly pauseToken: PauseToken; @@ -75,16 +75,10 @@ export class CodebaseIndexer { this.pauseToken = new PauseToken(initialPaused); } - /** - * Set the paused state of the indexer - */ set paused(value: boolean) { this.pauseToken.paused = value; } - /** - * Get the current paused state of the indexer - */ get paused(): boolean { return this.pauseToken.paused; } @@ -235,7 +229,9 @@ export class CodebaseIndexer { } } - async *refreshFiles(files: string[]): AsyncGenerator { + private async *refreshFiles( + files: string[], + ): AsyncGenerator { let progress = 0; if (files.length === 0) { yield { @@ -525,7 +521,7 @@ export class CodebaseIndexer { repoName, )) { yield { - progress: progress, + progress, desc, status: "indexing", };