diff --git a/app/services/prefetcher.ts b/app/services/prefetcher.ts index ff0d485..dedb136 100644 --- a/app/services/prefetcher.ts +++ b/app/services/prefetcher.ts @@ -354,8 +354,9 @@ export class Prefetcher { const room = this.spoolBytes < coordinatorConfig.spool.maxBytes // With at most perRange connections a range, enough ranges still being fetched for all loops: fully // spooled ones count as ready but need no connection (30 of 40 busy on small ranges; LOG.md 2026-10-10 (2)). + // 8 more than that: ranges with a chunk or two left take fewer than perRange (with +2, 3 of 40 loops idle). const { perRange } = coordinatorConfig.spool - const short = perRange > 0 ? Math.ceil(this.loops / perRange) + 2 - (leased.length + started.length) : 0 + const short = perRange > 0 ? Math.ceil(this.loops / perRange) + 8 - (leased.length + started.length) : 0 const want = Math.max(ahead - Number(ready), short) const fresh = room && want > 0 ? await rows(db.query()).where('r.status', 'planned').where('r.spooled_chunks', 0).whereRaw('r.next_id <= r.end_id').orderBy([{ column: 'r.priority' }, { column: 'r.id' }]).limit(want)