Skip to content

Commit e44f824

Browse files
ryansolidclaude
andauthored
perf(signals): mangle the store family's private fields (#4494)
* perf(signals): mangle the store family's private fields Rename the store family link `fam` -> `_fam` (on store targets and on the projection computed) and the StoreFamily fields `overlaid`, `asked`, `woke` and `shallow` to `_`-prefixed names so the mangle-props pass shortens them. Pure rename, no behavior change. `live`, `node` and `st` stay unprefixed: they are read in core files (affects-marks, async, seat, deferred) whose first-encounter slots in the mangle order would push hot core fields (`_fn`, `_verdictLane`) to two-char names, raising minified in every non-store scenario. `opt`, `key`, `map` and `run` save one char each and their reshuffle cost more brotli than it saved. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * chore(signals): pin the store family's mangled field names The build added `_fam`, `_overlaid`, `_asked`, `_woke` and `_shallow` to mangle-props.json at the next free short names; every existing pin keeps its name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 --------- Co-authored-by: Claude <[email protected]>
1 parent 19e0951 commit e44f824

17 files changed

Lines changed: 128 additions & 113 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
Smaller store bundles: the store family field (`_fam`) and its `_overlaid`, `_asked`, `_woke` and `_shallow` fields are now `_`-prefixed internals, so the prod and observe builds mangle them (no behavior change).

‎packages/signals/scripts/mangle-props.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"_acted": "nt",
44
"_armLane": "B",
55
"_armed": "h",
6+
"_asked": "dn",
67
"_blocked": "fe",
78
"_born": "ro",
89
"_boundRunEffect": "W",
@@ -32,6 +33,7 @@
3233
"_evaluating": "gt",
3334
"_extraConfig": "xe",
3435
"_fallback": "L",
36+
"_fam": "rr",
3537
"_fb": "re",
3638
"_firstChild": "pe",
3739
"_flags": "R",
@@ -82,6 +84,7 @@
8284
"_open": "tt",
8385
"_order": "yt",
8486
"_output": "j",
87+
"_overlaid": "cn",
8588
"_owned": "Mt",
8689
"_owner": "H",
8790
"_parentComputed": "Ke",
@@ -110,6 +113,7 @@
110113
"_runs": "M",
111114
"_scope": "oo",
112115
"_served": "$e",
116+
"_shallow": "It",
113117
"_show": "ne",
114118
"_shown": "Ue",
115119
"_shownError": "Te",
@@ -138,12 +142,14 @@
138142
"_verdictLane": "J",
139143
"_witness": "io",
140144
"_witnessMark": "rt",
145+
"_woke": "Tt",
141146
"_x": "T"
142147
},
143148
"observe": {
144149
"_acted": "nt",
145150
"_armLane": "B",
146151
"_armed": "h",
152+
"_asked": "dn",
147153
"_blocked": "fe",
148154
"_born": "ro",
149155
"_boundRunEffect": "W",
@@ -199,6 +205,7 @@
199205
"_evaluating": "rs",
200206
"_extraConfig": "ct",
201207
"_fallback": "L",
208+
"_fam": "rr",
202209
"_fb": "re",
203210
"_firstChild": "ze",
204211
"_flags": "R",
@@ -251,6 +258,7 @@
251258
"_open": "tt",
252259
"_order": "Zt",
253260
"_output": "j",
261+
"_overlaid": "cn",
254262
"_owned": "ls",
255263
"_owner": "H",
256264
"_parentComputed": "Pt",
@@ -280,6 +288,7 @@
280288
"_runs": "M",
281289
"_scope": "oo",
282290
"_served": "Ut",
291+
"_shallow": "nr",
283292
"_show": "ne",
284293
"_shown": "Nt",
285294
"_shownError": "Te",
@@ -308,6 +317,7 @@
308317
"_verdictLane": "J",
309318
"_witness": "io",
310319
"_witnessMark": "bt",
320+
"_woke": "tr",
311321
"_x": "T"
312322
}
313323
}

‎packages/signals/src/affects-marks.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function repoll(
4848
if (!(sub as any)._type) repoll(sub, seen, readers);
4949
// A derived store's derive: its leaves' readers derive from it too
5050
// (store/projection.ts; a live target's property, has and keys nodes).
51-
const fam = (sub as any).fam;
51+
const fam = (sub as any)._fam;
5252
if (fam)
5353
for (const t of fam.live)
5454
for (const o of [t.n, t.h, { k: t.k, d: t.dk }])
@@ -69,7 +69,7 @@ function marked(el: Marked, seen: Set<Marked>): boolean {
6969
if (c._statusFlags & STATUS_ERROR || seen.has(el)) return false;
7070
seen.add(el);
7171
if (c._config & CONFIG_SLOT_NODE) {
72-
const derive: Marked | null | undefined = (c as any)._host?.fam?.node;
72+
const derive: Marked | null | undefined = (c as any)._host?._fam?.node;
7373
return derive != null && marked(derive, seen);
7474
}
7575
const tail = c._flags & REACTIVE_RECOMPUTING_DEPS ? c._depsTail : undefined;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export function stageError(el: Computed<any>, error: any, inPass?: boolean): boo
207207
if (
208208
!(
209209
el._config & CONFIG_HELD ||
210-
(inPass && el._flags & REACTIVE_STAGED_READ && globalQueue._running && !(el as any).fam)
210+
(inPass && el._flags & REACTIVE_STAGED_READ && globalQueue._running && !(el as any)._fam)
211211
) ||
212212
passLane
213213
)
@@ -249,7 +249,7 @@ function stageMark(node: Computed<any>, el: Computed<any>): void {
249249
queuePendingNode(node);
250250
// A derived store's readers are its family's (store/projection.ts): they
251251
// re-derive from the staging, as from the derive's status (#4189).
252-
(node as any).fam?.st(STATUS_ERROR);
252+
(node as any)._fam?.st(STATUS_ERROR);
253253
settlePendingSource(node);
254254
}
255255
}
@@ -387,7 +387,7 @@ export function settlePendingSource(el: Computed<any>, source: Computed<any> = e
387387
// its readers wait on the derive itself, not on this source, so they
388388
// settle with it, as a memo's would through its dependents (F-9, A9).
389389
// Only a store build has one (`storeParkHook`).
390-
else if (storeParkHook) (node as any).fam?.st();
390+
else if (storeParkHook) (node as any)._fam?.st();
391391
if (node._x !== null) node._x._blocked = false;
392392
// Fully settled with nobody watching: release candidate (#2934). Checked
393393
// again at release time — deferred so unobserved() can't unlink subs
@@ -1135,7 +1135,7 @@ export function propagateStatus(el: Computed<any>, status: number, error: any):
11351135
notifyStatus(sub, status, error);
11361136
// A derived store's derive (store/projection.ts): marked, not re-run —
11371137
// its leaves' readers are not its dependents, so the family walks them.
1138-
(sub as any).fam?.st(status, error);
1138+
(sub as any)._fam?.st(status, error);
11391139
}
11401140
});
11411141
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ export function slot(
751751
const laneHas = !laneNP(el, guess, staged, uninit) && !flying;
752752
// A folded lane (D-34): a deriving pass outside the lane reads the
753753
// hold's world and joins it; lane work and leaves keep the guess.
754-
if (l.folded && guess && !inLane && !leaf && (el as any)._host?.fam?.node !== c)
754+
if (l.folded && guess && !inLane && !leaf && (el as any)._host?._fam?.node !== c)
755755
return pred(rowBase + "D4'", staged ? SLOT_P : SLOT_C, RAISE_H, resolveTx(l._parent ?? l));
756756
if (!tracked) {
757757
// An untracked read outside lane work: the screen (D4''); inside, the

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function observeFlight(c: Computed<any>, el: Computed<any>): boolean {
140140
// A derived store's derive whose store has no reader (`fam.live` empty:
141141
// no leaf has a node) is no display: it observes nothing and holds nothing
142142
// (F-3, D-11) — it stays live only to keep the store's data.
143-
if (globalQueue._running && (c as any).fam?.live.size !== 0) {
143+
if (globalQueue._running && (c as any)._fam?.live.size !== 0) {
144144
joinFuture(null);
145145
if (!(el._config & CONFIG_HELD)) queuePendingNode(el);
146146
verdictRead(c, flushTransaction!, true);

‎packages/signals/src/deferred.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function lagOf(c: Computed<any>, seen: Set<Computed<any>>): Computed<any> | unde
5353
if (lagging.has(c)) return c;
5454
if (seen.has(c)) return;
5555
seen.add(c);
56-
if (c._config & CONFIG_SLOT_NODE) return lagOf((c as any)._host?.fam?.node ?? c, seen);
56+
if (c._config & CONFIG_SLOT_NODE) return lagOf((c as any)._host?._fam?.node ?? c, seen);
5757
const tail = c._flags & REACTIVE_RECOMPUTING_DEPS ? c._depsTail : undefined;
5858
if (tail !== null)
5959
for (let d = c._deps ?? null; d !== null; d = d._nextDep) {

‎packages/signals/src/store/affects.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function storeMarks(t: StoreTarget, key: PropertyKey | undefined): Marked
5959
const entry = scopeOf(node, key);
6060
if (key === undefined) {
6161
const found: Marked[] = [node];
62-
walk(t.px, entry, found, t.fam, new Set());
62+
walk(t.px, entry, found, t._fam, new Set());
6363
return found;
6464
}
6565
entry._scope.add(t.v);
@@ -87,7 +87,7 @@ function walk(
8787
if (t !== undefined) {
8888
if (t.pb !== null) entry._scope.add(t.v);
8989
// The writer's view: the tick's own unflushed guesses are in motion too.
90-
if (optHooks && t.fam?.opt === true) raw = optHooks.view(t, raw, true);
90+
if (optHooks && t._fam?.opt === true) raw = optHooks.view(t, raw, true);
9191
const nodes = t.n;
9292
if (nodes !== null)
9393
for (const k of Reflect.ownKeys(nodes))
@@ -98,7 +98,7 @@ function walk(
9898
if (has !== null) for (const k of Reflect.ownKeys(has)) found.push(has[k as any]);
9999
if (t.k !== null) found.push(t.k);
100100
if (t.dk !== null) found.push(t.dk);
101-
fam = t.fam ?? fam;
101+
fam = t._fam ?? fam;
102102
}
103103
for (const k of Reflect.ownKeys(raw))
104104
if (k !== $OWNER) {

‎packages/signals/src/store/edges.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export function storeName(x: object | undefined): string | undefined {
3030
// Up to the root; a target on the way named as a root of its own is one
3131
// object in two stores.
3232
while (t.u !== null) {
33-
if (t.fam !== null || t.ch || signalName(t) !== undefined) return undefined;
33+
if (t._fam !== null || t.ch || signalName(t) !== undefined) return undefined;
3434
t = t.u;
3535
}
36-
if (t.fam !== null || t.ch) return undefined;
36+
if (t._fam !== null || t.ch) return undefined;
3737
return signalName(t) || undefined;
3838
}

‎packages/signals/src/store/hooks.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface OptHooks {
2727
has(t: StoreTarget, key: PropertyKey): boolean | undefined;
2828
/** A guessed key's descriptor (`null`: removed; `undefined`: no guess). */
2929
descriptor(t: StoreTarget, key: PropertyKey): PropertyDescriptor | null | undefined;
30-
/** The flush's commit: targets no lane holds leave `overlaid`. */
30+
/** The flush's commit: targets no lane holds leave `_overlaid`. */
3131
sweep(): void;
3232
/** The container comparator's lane arm: an arrangement guess against a
3333
* landing (or another arrangement), by row identity. */

0 commit comments

Comments
 (0)