Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions packages/runtime-common/index-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,23 +675,45 @@ export class IndexRunner {
}

let failed = 0;
for (let moduleUrl of toWarm) {
try {
await this.#definitionLookup.getCachedDefinitions(moduleUrl, {
priority: this.#jobPriority,
});
} catch {
failed += 1;
// Bounded-parallel sweep. The bound matches the default
// `#fileAdmissionCap` of the prerender server's PagePool
// (`affinityTabMax − 1`, default 4). Tying it to the
// file-admission cap keeps the parallel pre-warm from
// oversubscribing the per-affinity tab budget — at most
// `#fileAdmissionCap` file/render tabs will be in flight in the
// realm's affinity, and pre-warm modules borrow the same headroom
// before the visit phase starts. The visit phase pays no penalty
// because pre-warm runs strictly before it. Concurrency above 4
// re-introduces the contention that motivated the original serial
// shape; below 4 leaves the prerender server's idle tabs unused
// for the duration of the sweep.
let prewarmConcurrency = 4;
let urls = [...toWarm];
Comment on lines +690 to +691
let cursor = 0;
Comment on lines +678 to +692
let worker = async () => {
while (cursor < urls.length) {
let i = cursor++;
let moduleUrl = urls[i];
try {
await this.#definitionLookup.getCachedDefinitions(moduleUrl, {
priority: this.#jobPriority,
});
} catch {
failed += 1;
}
}
}
};
await Promise.all(
Array.from({ length: Math.min(prewarmConcurrency, urls.length) }, worker),
);
if (failed > 0) {
this.#log.warn(
`${jobIdentity(this.#jobInfo)} ${failed} of ${toWarm.size} module pre-warm lookups failed; the visit phase will retry on-demand if needed`,
);
}

this.#perfLog.debug(
`${jobIdentity(this.#jobInfo)} pre-warm complete in ${Date.now() - preWarmStart} ms (candidates=${toWarm.size} failed=${failed})`,
`${jobIdentity(this.#jobInfo)} pre-warm complete in ${Date.now() - preWarmStart} ms (candidates=${toWarm.size} failed=${failed} concurrency=${prewarmConcurrency})`,
);
Comment on lines +706 to 717
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same — index keys are fine for a read-only list; ${type}:${email} triggers dup-key warnings Copilot earlier asked us to avoid.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

Expand Down
Loading