fix(sync): avoid argument-stack overflow gathering unresolved refs on large syncs#1283
Open
ianmage wants to merge 1 commit into
Open
fix(sync): avoid argument-stack overflow gathering unresolved refs on large syncs#1283ianmage wants to merge 1 commit into
ianmage wants to merge 1 commit into
Conversation
… large syncs Two unresolved-ref readers in the DB query layer chunked their IN-list under SQLite's parameter limit but then collected the matched rows with `rows.push(...chunkRows)`. Chunking the file-path / name list bounds the SQL parameters, not the returned ROW count: on a large `codegraph sync` (fresh index, big changelist, first sync after a branch switch) a single chunk matches hundreds of thousands of rows, and spreading them as call arguments blows V8's argument-stack limit — the sync aborts with "Maximum call stack size exceeded" (arg-spread ceiling ~125k). Append row-by-row instead of spreading, in both readers: - getUnresolvedReferencesByFiles (pending refs for changed files) - getRetryableFailedReferences (failed-ref retry path, colbymchenry#1240) Adds two regression tests (db-perf) that overflow on the pre-fix spread and pass on the fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
codegraph syncaborts withRangeError: Maximum call stack size exceededon large projects — reproduced on a large Perforce workspace (Unreal Engine C++/Python, ~6k files, ~1.1M references), and reproducible on any fresh index, large changelist, or first sync after a branch switch.Captured stack:
Root cause
Two unresolved-ref readers chunk their
IN (...)list under SQLite's parameter limit, then collect the matched rows withrows.push(...chunkRows). Chunking the file-path / name list bounds the SQL parameters, not the returned row count: one 500-item chunk can match hundreds of thousands of rows, and spreading them as call arguments exceeds V8's argument-stack limit (~125k args). Affected:getUnresolvedReferencesByFiles— pending refs for changed files (the sync git-fast-path)getRetryableFailedReferences— the failed-ref retry path (Incremental sync misses cross-file relations after a new export is added #1240)Fix
Append row-by-row (
for (const row of chunkRows) rows.push(row)) in both readers. No behavior change; only removes the arg-spread. The existing file-path / name chunking (for the SQLite parameter limit, #540) is unchanged.Tests
Two regression tests in
__tests__/db-perf.test.tsdrive each reader past the arg-spread ceiling. Both throwMaximum call stack size exceededon the pre-fix spread and pass on the fix. Fulldb-perf+pr19-improvementssuites green (55 tests). Verified end-to-end: a forced full re-sync of the ~1.1M-ref workspace that previously threw now completes.