Skip to content

fix(memory): read at most the size cap when indexing a file - #499

Merged
mrnasil merged 2 commits into
mainfrom
fix/code-index-size-first
Nov 25, 2026
Merged

mrnasil merged 2 commits into
mainfrom
fix/code-index-size-first

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 25, 2026

Copy link
Copy Markdown
Member

index_file read the whole file into memory and only then dropped it if it was over 400 KB. A multi-GB dump.sql or data.json that is not gitignored (both are indexed extensions) was therefore read in full by the background index at session start.

read_indexable now reads at most one byte past the cap (File::take) and drops anything longer, so memory use no longer depends on the file's size. Files at or under 400 KB behave as before.

Test: a file exactly at the cap is read, one byte over is skipped, and a missing file is skipped. The existing huge.rs index test still passes.

🤖 Generated with Claude Code

index_file read the whole file and only then dropped it above 400 KB.
A non-ignored multi-GB `dump.sql` or `data.json` (both indexed
extensions) was allocated in full by the background index at session
start. The read now stops one byte past the cap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil enabled auto-merge (squash) November 25, 2026 15:39
@mrnasil
mrnasil merged commit a2db44c into main Nov 25, 2026
7 checks passed
@mrnasil
mrnasil deleted the fix/code-index-size-first branch November 25, 2026 23:32
@mrnasil mrnasil mentioned this pull request Nov 26, 2026
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