* Resolve references in batches to keep memory bounded on large codebases. * Processes chunks of unresolved refs, persisting results after each batch.
(
onProgress?: (current: number, total: number) => void,
onSynthesisProgress?: (done: number, total: number) => void,
// The WAL valve's writer-side backstop, threaded into the batch loop's
// pool-idle boundaries. Without it the valve's only lever during
// resolution is timer-driven passive checkpoints, which the pool's
// continuous reads keep perpetually partial — the WAL then accretes the
// whole phase's write volume (22GB on a 4.6GB DB at kernel scale).
backpressure?: () => Promise<void> | null,
synthesize: boolean = true,
// The caller has just re-detected the frameworks on this index, so the
// resolver pool's workers needn't each read the project again to do it.
frameworksCurrent: boolean = false
)
| 2331 | * Processes chunks of unresolved refs, persisting results after each batch. |
| 2332 | */ |
| 2333 | async resolveReferencesBatched( |
| 2334 | onProgress?: (current: number, total: number) => void, |
| 2335 | onSynthesisProgress?: (done: number, total: number) => void, |
| 2336 | // The WAL valve's writer-side backstop, threaded into the batch loop's |
| 2337 | // pool-idle boundaries. Without it the valve's only lever during |
| 2338 | // resolution is timer-driven passive checkpoints, which the pool's |
| 2339 | // continuous reads keep perpetually partial — the WAL then accretes the |
| 2340 | // whole phase's write volume (22GB on a 4.6GB DB at kernel scale). |
| 2341 | backpressure?: () => Promise<void> | null, |
| 2342 | synthesize: boolean = true, |
| 2343 | // The caller has just re-detected the frameworks on this index, so the |
| 2344 | // resolver pool's workers needn't each read the project again to do it. |
| 2345 | frameworksCurrent: boolean = false |
| 2346 | ): Promise<ResolutionResult> { |
| 2347 | return this.resolver.resolveAndPersistBatched(onProgress, undefined, onSynthesisProgress, { |
| 2348 | dbPath: this.db.getPath(), |
| 2349 | shareFrameworks: frameworksCurrent, |
| 2350 | // Bulk-edge-load hooks: on big runs the resolver drops the non-unique |
| 2351 | // edge indexes for the batch loop and recreates them before synthesis |
| 2352 | // (which reads kind-keyed). Concurrent readers (a daemon serving this |
| 2353 | // project mid-index) stay CORRECT during the window — target/kind reads |
| 2354 | // just degrade to scans until the recreate. |
| 2355 | bulkEdgeLoad: { |
| 2356 | begin: () => this.db.beginBulkEdgeLoad(), |
| 2357 | end: () => this.db.endBulkEdgeLoad({ deferSynthesisSite: true }), |
| 2358 | deferred: () => this.db.createSynthesisSiteIndex(), |
| 2359 | }, |
| 2360 | refIndexLoad: { |
| 2361 | begin: () => this.db.beginBulkRefLoad(), |
| 2362 | end: () => this.db.endBulkRefLoad(), |
| 2363 | }, |
| 2364 | backpressure, |
| 2365 | }, synthesize); |
| 2366 | } |
| 2367 | |
| 2368 | /** |
| 2369 | * References extracted but never attempted by a resolution pass. Zero on a |