Skip to content

Commit fb47438

Browse files
habdelraclaude
andcommitted
Skip module pre-warming on incremental indexing
Incremental indexing no longer pre-warms the definition cache for the modules in the change set. The module cache is already warm from the prior from-scratch, and any module a render needs that isn't cached resolves through the on-demand `lookupDefinition` read-through during the visit (PagePool-safe: the sub-prerender materializes its own tab). From-scratch indexing is unchanged — it still runs the realm-wide `.gts`/`.gjs` sweep plus the per-invalidation deps warm, where the module cache is cold by definition. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b2526ff commit fb47438

1 file changed

Lines changed: 14 additions & 44 deletions

File tree

packages/runtime-common/index-runner.ts

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ export class IndexRunner {
400400
current.#jobInfo,
401401
current.#virtualNetwork,
402402
);
403-
// Announce the job at kickoff — before invalidation and pre-warm — so
404-
// the dashboard shows it immediately. The total starts at 0 and the
403+
// Announce the job at kickoff — before invalidation — so the
404+
// dashboard shows it immediately. The total starts at 0 and the
405405
// first `file-visited` fills it in once the counts are known.
406406
current.#onProgress?.({
407407
type: 'indexing-started',
@@ -434,46 +434,15 @@ export class IndexRunner {
434434
}
435435
current.#scheduleClearCacheForNextRender();
436436
}
437-
// Still pre-warm, but only the modules this batch will actually
438-
// render. For each invalidation `preWarmModulesTable` primes the
439-
// definition cache for the invalidated module file itself (when
440-
// executable) plus the per-row `boxel_index` deps of the invalidated
441-
// cards (and the `adoptsFrom` module of a novel `.json`). Front-
442-
// loading those before the visit phase lets a dependent card's render
443-
// hit the cache instead of firing a same-affinity sub-`prerenderModule`
444-
// mid-render — the per-invalidation warming, bounded by invalidation
445-
// size rather than realm size.
446-
//
447-
// The empty base set drops only the realm-wide `.gts`/`.gjs` sweep.
448-
// That sweep exists to prime sibling modules a card references by
449-
// string (which never appear in any instance's runtime deps) and is
450-
// worth its O(realm) cost only on from-scratch, where the cache is
451-
// cold by definition. On an incremental the cache is already warm from
452-
// the prior from-scratch, and any miss resolves through the on-demand
437+
// Incremental indexing does no module pre-warming. The module cache
438+
// is already warm from the prior from-scratch, and any module a
439+
// render needs that isn't cached resolves through the on-demand
453440
// `lookupDefinition` read-through during the visit (PagePool-safe: the
454-
// sub-prerender materializes its own tab). Skipping it also avoids the
455-
// filesystem-mtimes walk this path would otherwise run only to build
456-
// the sweep.
457-
// Pre-warm reports each warmed module as a `file-visited`; modules and
458-
// the files visited below share one `totalFiles` so the dashboard bar
459-
// spans both phases.
441+
// sub-prerender materializes its own tab). Leaning on the read-through
442+
// keeps this path's cost bounded by the cards it actually visits
443+
// instead of fanning out a separate module-warming pass.
460444
let filesCompleted = 0;
461-
let preWarmedCount = await current.preWarmModulesTable(
462-
invalidations,
463-
[],
464-
({ moduleUrl, filesCompleted: completed, totalFiles }) => {
465-
filesCompleted = completed;
466-
current.#onProgress?.({
467-
type: 'file-visited',
468-
realmURL: current.realmURL.href,
469-
jobId: current.#jobInfo.jobId,
470-
url: moduleUrl,
471-
filesCompleted,
472-
totalFiles,
473-
});
474-
},
475-
);
476-
let totalFiles = preWarmedCount + invalidations.length;
445+
let totalFiles = invalidations.length;
477446

478447
let hrefs = urls.map((u) => u.href);
479448
let resumedRows = current.batch.resumedRows;
@@ -716,10 +685,11 @@ export class IndexRunner {
716685
// this layer the search fires a same-affinity `prerenderModule`
717686
// mid-card-render at lookup time, which is the wait-shape the
718687
// PagePool's tab-materialization for module/command callers is
719-
// meant to relieve. Populated only on from-scratch indexing, where
720-
// the module cache is cold; incrementals pass an empty base set and
721-
// rely on the cache the last from-scratch left warm (the cost of
722-
// this sweep is O(realm module count), not O(files changed)).
688+
// meant to relieve. This realm-wide sweep runs only on from-scratch
689+
// indexing, where the module cache is cold; incremental indexing does
690+
// no pre-warming and relies on the cache the last from-scratch left
691+
// warm (the cost of this sweep is O(realm module count), not O(files
692+
// changed)).
723693
//
724694
// `.gts` / `.gjs` only is an optimization, not a correctness gate:
725695
// `.ts` / `.js` files CAN host `CardDef` (e.g. command-input

0 commit comments

Comments
 (0)