Skip to content

Commit a370c5f

Browse files
committed
Reintroduce renderJoin barrier; searchData depends on it, not flushJoin.
1 parent be4ffd6 commit a370c5f

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

builder/scheduler.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export class Scheduler {
3636
if (!def.on_demand) this._remaining++;
3737
}
3838

39+
// render counter: activated when all render:i tasks complete.
40+
this._renderCount = 0;
41+
this._renderExpected = 0;
42+
3943
// flush counter: activated by per-worker timing messages.
4044
this._flushCount = 0;
4145
this._flushStats = { written: 0, offlineWritten: 0, offlineMisses: 0 };
@@ -189,6 +193,18 @@ export class Scheduler {
189193
// State mutation.
190194
if (def) def.submit(output, this.state, this);
191195

196+
// Render counter: activate renderJoin when all render:i complete.
197+
if (name?.startsWith("render:") && this._renderExpected > 0) {
198+
this._renderCount++;
199+
if (this._renderCount === this._renderExpected) {
200+
this.addDynamicTasks(1);
201+
const joinIdx = this._idMapping.nameToIdx.get("renderJoin");
202+
if (joinIdx != null) {
203+
Atomics.store(this._views.status, joinIdx, READY);
204+
}
205+
}
206+
}
207+
192208
this._remaining--;
193209
if (this._remaining === 0) {
194210
this._finish();

builder/tbdocs.mjs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,17 @@ const TASKS = {
325325
submit() {},
326326
},
327327

328+
// Barrier: all render:i deltas merged into state.pages (renderedContent
329+
// available). Activated by counter in _onWorkerDone. Tasks that only
330+
// need renderedContent (not page HTML on disk) depend on this.
331+
renderJoin: {
332+
expected: [],
333+
on_demand: true,
334+
runOnMain: true,
335+
execute() { return {}; },
336+
submit() {},
337+
},
338+
328339
// Barrier: all workers have flushed their stashed pages to disk.
329340
// Activated by counter in _onPerWorkerTiming, not by SAB dep counts.
330341
flushJoin: {
@@ -499,6 +510,7 @@ const TASKS = {
499510
},
500511
submit(out, _state, scheduler) {
501512
const N = out.chunks.length;
513+
scheduler._renderExpected = N;
502514

503515
for (let i = 0; i < N; i++) {
504516
scheduler.tasks.set(`render:${i}`, {
@@ -548,11 +560,12 @@ const TASKS = {
548560
submit() {},
549561
},
550562

551-
// Write search-data.json. Depends on flushJoin (pages have
552-
// renderedContent) and prepDest (_site/ exists). Result passes
553-
// through to writeAux so its search.json field reaches writeOffline.
563+
// Write search-data.json. Depends on renderJoin (pages have
564+
// renderedContent in memory) and prepDest (_site/ exists). Result
565+
// passes through to writeAux so its search.json field reaches
566+
// writeOffline.
554567
searchData: {
555-
expected: ["flushJoin", "prepDest"],
568+
expected: ["renderJoin", "prepDest"],
556569
runOnMain: true,
557570
async execute(_, ctx, state) {
558571
if (ctx.opts.dryRun) return { entries: 0, json: "" };
@@ -636,7 +649,7 @@ const GANTT_SECTION = {
636649
seo: "Spine", resolveBookChapters: "Spine",
637650
deriveRedirects: "Spine", deriveSitemap: "Spine",
638651
dispatch: "Render", prepDest: "Render", prepPageDirs: "Render",
639-
flush: "Write", flushJoin: "Write",
652+
renderJoin: "Render", flush: "Write", flushJoin: "Write",
640653
writeAssets: "Write", searchData: "Write", writeAux: "Write", writeOffline: "Write", writePdf: "Write",
641654
};
642655
const GANTT_SECTION_ORDER = ["Seeds", "Spine", "Render", "Write"];

0 commit comments

Comments
 (0)