Skip to content

Commit ce60b49

Browse files
authored
Merge pull request #5121 from cardstack/worktree-no-prewarm-incremental-index
Skip module pre-warming on incremental indexing
2 parents b2526ff + 40c5a7a commit ce60b49

1 file changed

Lines changed: 17 additions & 45 deletions

File tree

packages/runtime-common/index-runner.ts

Lines changed: 17 additions & 45 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,18 @@ 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
453-
// `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.
437+
// Incremental indexing does no module pre-warming. Query-backed field
438+
// expansion during a prerender `_search` reads the `queryFieldDefs`
439+
// pre-extracted onto each result instance's stored meta
440+
// (`populateQueryFieldsFromMeta`), so it needs no `modules`-table row
441+
// for the queried type. The prerender-search definition path is
442+
// cache-only by design — a read-through there would re-enter the same
443+
// affinity tab mid-render and deadlock the pool — while definition
444+
// needs outside it resolve through the on-demand `lookupDefinition`
445+
// read-through. There is nothing left for a pre-warm pass to
446+
// front-load here.
460447
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;
448+
let totalFiles = invalidations.length;
477449

478450
let hrefs = urls.map((u) => u.href);
479451
let resumedRows = current.batch.resumedRows;
@@ -716,10 +688,10 @@ export class IndexRunner {
716688
// this layer the search fires a same-affinity `prerenderModule`
717689
// mid-card-render at lookup time, which is the wait-shape the
718690
// 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)).
691+
// meant to relieve. This realm-wide sweep runs only on from-scratch
692+
// indexing, where the module cache is cold by definition; incremental
693+
// indexing does no pre-warming (the cost of this sweep is O(realm
694+
// module count), not O(files changed)).
723695
//
724696
// `.gts` / `.gjs` only is an optimization, not a correctness gate:
725697
// `.ts` / `.js` files CAN host `CardDef` (e.g. command-input

0 commit comments

Comments
 (0)