Skip to content

Commit e36a6b9

Browse files
committed
perf(signals): offset the held recovery's floor bytes
Four perf-neutral rewrites in the floors' own code pay for most of the fix. `recompute` now captures its outgoing error and pending sources with `&&` instead of `? : undefined`. `notifyStatus` and `propagateStatus` do the same for the pending source. Every reader of those values is truthy-guarded, and `settleErroredDependents` now also skips a null error, which it never needed to walk. The core floor goes from +36 B to +7 B minified over next, the frameworks' floors from +35 B to +6 B, and the live server-components floor ends at 115,182 B. The ledger is re-recorded against next @ 1b32ff2. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2
1 parent 9b777de commit e36a6b9

3 files changed

Lines changed: 19 additions & 30 deletions

File tree

‎packages/signals/src/core/async.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -904,8 +904,7 @@ export function notifyStatus(el: Computed<any>, status: number, error?: any): vo
904904
)
905905
error = new StatusError(el, error);
906906

907-
const pendingSource =
908-
status === STATUS_PENDING && error instanceof NotReadyError ? error.source : undefined;
907+
const pendingSource = status === STATUS_PENDING && error instanceof NotReadyError && error.source;
909908
// (CARVE 2: the lane assignment went with the engine.)
910909

911910
if (status === STATUS_PENDING && pendingSource) {
@@ -967,8 +966,7 @@ export function notifyStatus(el: Computed<any>, status: number, error?: any): vo
967966
* propagates the derive's status from each leaf to the leaf's readers
968967
* (store/projection.ts `wakeFamily`), exactly as a memo's would reach its. */
969968
export function propagateStatus(el: Computed<any>, status: number, error: any): void {
970-
const pendingSource =
971-
status === STATUS_PENDING && error instanceof NotReadyError ? error.source : undefined;
969+
const pendingSource = status === STATUS_PENDING && error instanceof NotReadyError && error.source;
972970
forEachDependent(el, (sub, link) => {
973971
sub._time = clock;
974972
// A pending mark on a kept-tail link re-derives the subscriber instead of

‎packages/signals/src/core/core.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,9 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
461461
// Capture both error and pending status before the compute clears them.
462462
// A conditional can drop its pending source and recover to an unchanged
463463
// value, leaving blocked dependents outside that source’s settle walk.
464-
const outgoingError = el._statusFlags & STATUS_ERROR ? el._x?._error : undefined;
464+
const outgoingError = el._statusFlags & STATUS_ERROR && el._x?._error;
465465
const wasPending = (el._statusFlags & STATUS_PENDING) !== 0;
466-
const outgoingPendingSources = wasPending ? el._x?._pendingSources : undefined;
466+
const outgoingPendingSources = wasPending && el._x?._pendingSources;
467467
// Pending SOURCE-hood, captured before the compute clears status: a node
468468
// whose own flight parked dependents self-registers in _pendingSources
469469
// (notifyStatus, isSource). If this recompute supersedes that flight and
@@ -850,7 +850,7 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
850850
// recoveries ride insertSubs above; a comparator throw re-errored the node
851851
// (el._x?._error re-set), so this only runs on a genuinely clean recovery.
852852
if (!valueChanged && !el._x?._error) {
853-
if (outgoingError !== undefined) settleErroredDependents(el, outgoingError);
853+
if (outgoingError) settleErroredDependents(el, outgoingError);
854854
// Self-registration (this node's own superseded flight) is the #3181
855855
// sweep's business below — retiring it here too would walk twice.
856856
if (outgoingPendingSources)

0 commit comments

Comments
 (0)