Skip to content

Commit 4a89b84

Browse files
committed
perf(signals): shrink the fresh-Loading hold wait (#4593, #4591)
One inline loop at the boundary seam instead of `waitHeld` and its two closures: no `.some`/`forEach`, no CONFIG_OVERRIDE mask or lane check, no held-output guard (a swap held in the same hold folds back as before), every held input recorded rather than the first. The #2937 exemption is now `!txOf(h)._open`: a first load re-asked under an open action reveals at its landing; under a plain write's hold (parked only while a flight the screen waits on is out) it waits for the commit. Hydrating (Show/For/Loading/Errored/lazy), local rolldown: +257 -> +145 B minified over next; floors unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE
1 parent f46d008 commit 4a89b84

2 files changed

Lines changed: 18 additions & 38 deletions

File tree

‎.changeset/loading-reveal-waits-held-write-4593.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@solidjs/signals": patch
33
---
44

5-
A `<Loading>` that has not shown content no longer reveals content derived from a write still held outside it (F-7, F-1). Two reveals did not consult the hold: a first load the held write re-asked (kept out of every hold, #2937) landed mainline and revealed its answer beside a screen still showing the frame before the write (#4593); and a reader settled by an answer staged in the hold — a rejection, which marks no frame reader (D-41) — revealed the content's stale committed value under a re-armed `on` boundary and let the held write commit early (#4591). The boundary now waits on the held node and reveals with that hold's commit; the rejection shows when a value for the same question would. A first load whose held write the screen shows nowhere still reveals at its landing (#2937).
5+
A `<Loading>` that has not shown content no longer reveals content derived from a write still held outside it (F-7, F-1). Two reveals did not consult the hold: a first load the held write re-asked (kept out of every hold, #2937) landed mainline and revealed its answer beside a screen still showing the frame before the write (#4593); and a reader settled by an answer staged in the hold — a rejection, which marks no frame reader (D-41) — revealed the content's stale committed value under a re-armed `on` boundary and let the held write commit early (#4591). The boundary now waits on the held node and reveals with that hold's commit; the rejection shows when a value for the same question would. A first load re-asked under an open action still reveals at its landing (#2937).

‎packages/signals/src/boundaries.ts‎

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -334,27 +334,6 @@ function release(b: Boundary): void {
334334
b._runs = null;
335335
}
336336

337-
/** `b` waits on the first node `n` reads that a transaction holds (`n`
338-
* itself not held), kept like a held reader until that commit (`prune`).
339-
* `shown`: only when the screen shows that hold's old frame — a render
340-
* effect it holds on screen, or a stale reader it re-derives — so the
341-
* content would show beside it (F-1). */
342-
function waitHeld(b: Boundary, n: Computed<any>, shown?: boolean): void {
343-
if (!(n._config & CONFIG_HELD))
344-
for (let d = n._deps; d; d = d._nextDep) {
345-
const h = d._dep as Computed<any>;
346-
const t = (h._config & (CONFIG_HELD | CONFIG_OVERRIDE)) === CONFIG_HELD && txOf(h);
347-
if (
348-
t &&
349-
!t._lane &&
350-
(!shown ||
351-
t._reruns.length ||
352-
t._nodes.some(r => (r as any)._type === EFFECT_RENDER && !hiddenBy(r as Computed<any>)))
353-
)
354-
return record(b, h);
355-
}
356-
}
357-
358337
/** Drop the readers that settled or died. Settled: a loading reader no
359338
* longer pending; an error's source neither errored nor in flight. A reader
360339
* that landed but is held (its value staged in a transaction) is not: the
@@ -443,23 +422,24 @@ function boundarySeam(): void {
443422
// A parked frame's boundary (zombie) keeps its state for its revival.
444423
if (flags & REACTIVE_ZOMBIE) continue;
445424
// A fresh boundary's content that derives from a write a hold keeps
446-
// belongs to that hold and reveals with its commit, not before (F-7,
447-
// D-12): the boundary waits on the held node (`waitHeld`). A reader
448-
// settled by an answer staged in the hold — a staged error marks no
449-
// frame reader (D-41), and the reveal showed the content's committed,
450-
// stale value beside the held write (#4591). A first load the write
451-
// re-asked: the seam keeps a loading source out of every hold (#2937,
452-
// D-6), so its answer lands mainline — beside a screen that still shows
453-
// the frame before the write, a torn frame (F-1, #4593); with nothing
454-
// on screen from that hold, it reveals at its landing (#2937). Not a
455-
// held reader or a held swap: those reveal with their own commit.
456-
if (!b._initialized && !(b._output!._config & CONFIG_HELD))
425+
// reveals with that hold's commit (F-7, D-12): the boundary waits on
426+
// the held node, kept like a held reader until it commits (`prune`).
427+
// The node a settled reader reads: an answer staged there — a staged
428+
// error marks no frame reader (D-41) — left the reader settled on its
429+
// stale committed value (#4591). The node a first load it waits on
430+
// reads: the seam keeps a loading source out of every hold (#2937,
431+
// D-6), so its answer landed mainline, torn from the frame a write's
432+
// hold keeps on screen (F-1, #4593); under an open action it still
433+
// reveals at its landing (#2937). Not a held reader: it reveals with its
434+
// own commit.
435+
if (!b._initialized)
457436
for (const [r] of b._readers)
458-
if (!(r._statusFlags & STATUS_PENDING)) waitHeld(b, r);
459-
else
460-
r._x?._pendingSources?.forEach(
461-
n => n._statusFlags & STATUS_UNINITIALIZED && waitHeld(b, n, true)
462-
);
437+
for (const n of r._statusFlags & STATUS_PENDING ? r._x?._pendingSources || [] : [r])
438+
if (!(n._config & CONFIG_HELD))
439+
for (let d = n._deps; d; d = d._nextDep) {
440+
const h = d._dep as Computed<any>;
441+
if (h._config & CONFIG_HELD && (n === r || !txOf(h)._open)) record(b, h);
442+
}
463443
prune(b);
464444
const o = b._output!;
465445
// A fallback staged into the very hold its readers landed in folds back

0 commit comments

Comments
 (0)