@zakkster/lite-signal 1.8.0-alpha.3 → 1.8.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,7 +4,41 @@ All notable changes to `@zakkster/lite-signal` are documented here.
4
4
  Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
  This project follows [Semantic Versioning](https://semver.org/).
6
6
 
7
- ## [Unreleased]
7
+ ## [1.8.0-alpha.4] -- 2026-07-27
8
+
9
+ Rolls up the post-`1.8.0-preview` changes into the `alpha.4` tag. The
10
+ effect-cleanup-return feature (an effect body may `return` a cleanup) ships in
11
+ the preview and is unchanged here; this cut carries the dangling-cursor crash fix
12
+ (below, now also exercised against the cleanup-return path), 100% coverage on
13
+ `Signal.js`, and the completed torture surface for the cleanup-return feature.
14
+
15
+ ### Added -- `cleanup-return-torture` now executes on the 1.8.0 engine
16
+
17
+ `bench/torture/`'s `cleanup-return-torture` scenario -- present but
18
+ feature-skipped on the 1.5.x-1.7.x lines -- now **runs** (400 seeds), since an
19
+ effect body returning a cleanup is a 1.8.0 primitive. It pins the timing (the
20
+ returned cleanup runs before each re-run and once on dispose, same points as
21
+ imperative `onCleanup`), the **compose order** (a returned cleanup is appended
22
+ after any `onCleanup` registered in the same body, so both fire in call order),
23
+ the self-dispose guard (a body that disposes itself registers nothing), and the
24
+ computed exclusion (a computed returning a function keeps it as the value, never
25
+ a cleanup). On the 1.8.0 engine the runner therefore executes **13 semantic**
26
+ scenarios and cleanly SKIPS the one remaining later-version scenario
27
+ (`dispose-torture` 1.9.0); the suite total is unchanged at **17 (14 semantic +
28
+ 3 soak)**.
29
+
30
+ ### Verified -- full suite green on the 1.8.0 engine (Node 22, `--expose-gc`)
31
+
32
+ - **Torture:** 17/17 -- `torture:semantic` 14/14 (13 executed incl.
33
+ `cleanup-return-torture`, 1 clean skip: `dispose` 1.9.0), `torture:soak` 3/3
34
+ (zero errors, every pool back to its leaf-only floor).
35
+ - **Unit (plain run):** 492 tests, 472 pass, 0 fail, 1 skip (the architectural
36
+ SSR N/A in `17-reactivity`). The only non-passes are the 19 in
37
+ `test/25-devtools-real-boot`, the real-rig that requires the sibling
38
+ `@zakkster/lite-devtools`; with that sibling resolvable the suite is 491 pass +
39
+ 1 skip. Engine-only, excluding `test/25`: 473 tests, 472 pass, 1 skip. (The c8
40
+ coverage run below reports a different count -- perf-smoke budgets skip under
41
+ instrumentation.)
8
42
 
9
43
  ### Changed -- bench protocol v3 (carried forward)
10
44
 
@@ -230,6 +264,76 @@ scheduler, or pool moved.
230
264
  to 1.6.0-alpha's opcode 6/7 additions. The 1.8 minor introduces no new
231
265
  hook-gate branches.
232
266
 
267
+ ### Verified -- fresh 1.8.0 bench sweep (Apple M4 Pro / Node 26)
268
+
269
+ Both v3 instruments were re-run in full on the 1.8.0 engine on **Apple
270
+ M4 Pro darwin/arm64, Node 26.3.1**, with `#STAMP`-verified outputs
271
+ committed to `bench/r.txt` (microscope aggregate, 4 engines across the
272
+ six first-party shapes) and `bench/rb.txt` (mirror sweep, Andrii's
273
+ canonical adapter verbatim, lite vs alien across 47 rows,
274
+ isolated-per-row, 10 reps). Fresh Andrii 15-framework log at
275
+ `bench/AndriiVolynetsReactiveBench.log`.
276
+
277
+ - **Andrii Volynets js-reactivity-benchmark position moves from 4th to
278
+ 3rd of 15** with geomean **95.4 ms**; lite is now ahead of 4th-place
279
+ @reactively (136.0, lite 1.43x faster) and 5th-place Preact Signals
280
+ (148.8, ~56% ahead), behind only alien-signals (77.5) and reflex
281
+ (89.7). **Outright-fastest-of-15 wins jumped to 20 shapes** (was 3 on
282
+ 1.3.0 log, 4 on 1.7.0-preview): the eight canonical propagation shapes
283
+ (`avoidablePropagation`, `broadPropagation`, `deepPropagation`,
284
+ `diamond`, `mux`, `repeatedObservers`, `triangle`, `unstable`), all four
285
+ wide fan-in / fan-out shapes (`manyEffectsFromOneSource`,
286
+ `manySourcesIntoOneComputedEffect`,
287
+ `manySourcesIntoOneComputedEffectWithDirect`,
288
+ `manySourcesIntoOneDirectEffect`), `molBench`, and seven of the
289
+ rectangular / layered DAG shapes (`64x6`, `24x8`, `120x7`, `40x10`,
290
+ both `256->512x32 layered-dag` variants, and `10x10 dynamic component`).
291
+ Top-3 count: **29/47** (was 21 on 1.3.0). The dramatic wins jump is
292
+ driven by the same engine bytes across every propagation function
293
+ except `executeEffect`, which is where the 1.8.0 effect-cleanup-return
294
+ check landed.
295
+ - **Microscope aggregate on M4 Pro (r.txt):** on the six v3 microscope
296
+ shapes, lite wins vs alien on **MUX +34.3%** (fan-in), **SELECTIVE DAG
297
+ +19.3%**, **DYNAMIC DAG +16.8%**, and **BROADCAST +9.4%** (recovered
298
+ from +6.2% on 1.7.0-preview) -- the allocation-heavy dynamic shapes and
299
+ fan-in / fan-out. The wins hold within noise of the 1.7.0-preview M4 Pro
300
+ sweep despite the `executeEffect` change (one `typeof` per effect run,
301
+ off the mark/pull path). Alien ahead on **KAIROS -15.9%** (widened
302
+ slightly from -11.7% on 1.7.0-preview) and **DEEP CHAIN -72.6%** (the
303
+ architectural weak spot: recursive JS-stack computed resolution against
304
+ alien's flatter chain). Speed wins vs alien: **4/6**; heap wins:
305
+ **5/6** with the sixth being a shared-zero on BROADCAST.
306
+ - **Microscope heap (the actual story) on M4 Pro:** on every shape where
307
+ GC pressure exists at all, lite allocates **one to four orders of
308
+ magnitude less transient heap than alien** -- DEEP CHAIN 0.5 KB vs 1062
309
+ KB (>2000x, on the shape lite loses on time), MUX 0 KB vs 781 KB,
310
+ KAIROS 23 KB vs 802 KB (34.3x), DYNAMIC DAG 3.3 MB vs 59.8 MB (18.3x),
311
+ SELECTIVE DAG 7.7 MB vs 77.8 MB (10.0x). Against preact-signals and
312
+ solid-signals the heap gap is even wider on the fan-in / fan-out
313
+ family; solid allocates ~17 MB on MUX and ~16 MB on SELECTIVE DAG where
314
+ lite allocates 0 KB and 7.7 MB on the same shapes. The differentiated
315
+ position is ALLOCATION, not raw propagation speed -- competitive-to-
316
+ winning throughput with dramatically lower GC pressure, and that is
317
+ the headline that reproduces across hosts.
318
+ - **Mirror sweep on M4 Pro (rb.txt):** Andrii's canonical 47-shape suite
319
+ re-run isolated-per-row lite vs alien on M4 Pro reproduces the same
320
+ honest framing: lite runs **parity-to-behind alien on throughput**
321
+ across the head-to-head suite (wins outright on **4/47** --
322
+ `1000x5 - 25 sources (wide dense)` +12.0%,
323
+ `manySourcesIntoOneComputedEffectWithDirect` +31.1%,
324
+ `manySourcesIntoOneComputedEffect` +29.5%, and `molBench` +0.3%), weak
325
+ on the deep/layered-burst family. That head-to-head result and the
326
+ "3rd of 15 with 20 outright wins" both live on the same log and are
327
+ not contradictory: the outright-of-15 rankings look at each shape
328
+ across every framework in the field, so shapes where alien beats lite
329
+ by 20-30% but reflex beats both by another 10% and everyone else is
330
+ slower can still count as a lite outright win when measured that way.
331
+ - **Third-party engine versions carried forward** from the 1.7.0-preview
332
+ sweep (alien-signals 3.2.1, @preact/signals-core 1.14.2,
333
+ @vue/reactivity 3.5.35, solid-js 1.9.13). No peer bumps this cycle;
334
+ the deltas here are the 1.8 engine's own footprint (the `executeEffect`
335
+ change) plus host noise.
336
+
233
337
  ### Migration
234
338
 
235
339
  - **Every existing user**: zero work needed. Effects that don't return a
@@ -393,9 +497,9 @@ monomorphic targets and inlines the body. In "eager" mode the inlined body is
393
497
  byte-identical to the 1.6.0 inline check `if (batchDepth === 0) flushEffects()`
394
498
  -- **zero behavioral or performance regression** for any existing user.
395
499
 
396
- This is NOT ledger §0b #6 (per-call closure-var load of a primitive). It is a
500
+ This is NOT ledger S0b #6 (per-call closure-var load of a primitive). It is a
397
501
  hoisted function reference resolved once at registry build time and is a NEW
398
- mechanism by the v1 roadmap §0b line 100 definition.
502
+ mechanism by the v1 roadmap S0b line 100 definition.
399
503
 
400
504
  The `getOwner` / `runWithOwner` port adds new user-API functions but touches no
401
505
  hot path. sha256 over the extracted function bodies of `pullComputed`,
@@ -440,7 +544,7 @@ pristine 1.7.0-preview byte-for-byte; the two new functions are inserted between
440
544
 
441
545
  Real wins, but smaller than the gap to Reflex on the same shapes. The residual
442
546
  gap is structural (per-write `gen` check, batch-revert epoch tracking, global
443
- version bumping) -- design decisions accepted by §0b and not in scope here.
547
+ version bumping) -- design decisions accepted by S0b and not in scope here.
444
548
  Modern V8's `try/finally` elision varies; expect higher absolute speedups on
445
549
  production V8 than on this sandbox.
446
550
 
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![npm version](https://img.shields.io/npm/v/@zakkster/lite-signal.svg?style=for-the-badge&color=latest)](https://www.npmjs.com/package/@zakkster/lite-signal)
6
6
  [![sponsor](https://img.shields.io/badge/sponsor-PeshoVurtoleta-ea4aaa.svg?logo=github)](https://github.com/sponsors/PeshoVurtoleta)
7
7
  ![Zero-GC](https://img.shields.io/badge/Zero--GC-Engine-00C853?style=for-the-badge&logo=leaf&logoColor=white)
8
- ![Benchmark](https://img.shields.io/badge/js--reactivity--benchmark-4th%20of%2015-00C853?style=for-the-badge)
8
+ ![Benchmark](https://img.shields.io/badge/js--reactivity--benchmark-3rd%20of%2015-00C853?style=for-the-badge)
9
9
  [![npm bundle size](https://img.shields.io/bundlephobia/minzip/@zakkster/lite-signal?style=for-the-badge)](https://bundlephobia.com/result?p=@zakkster/lite-signal)
10
10
  [![npm downloads](https://img.shields.io/npm/dm/@zakkster/lite-signal?style=for-the-badge&color=blue)](https://www.npmjs.com/package/@zakkster/lite-signal)
11
11
  [![npm total downloads](https://img.shields.io/npm/dt/@zakkster/lite-signal?style=for-the-badge&color=blue)](https://www.npmjs.com/package/@zakkster/lite-signal)
@@ -15,23 +15,25 @@
15
15
  ![Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)
16
16
  [![license](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](./LICENSE)
17
17
 
18
- ## 4th of 15 on the community reactivity benchmark -- and the only zero-GC engine in the field
18
+ ## 3rd of 15 on the community reactivity benchmark -- and the only zero-GC engine in the field
19
19
 
20
- On the independent [js-reactivity-benchmark](https://github.com/volynetstyle/js-reactivity-benchmark) (Andrii Volynets' fork; 15 reactive libraries, 47 tests), `lite-signal` places **4th overall by geomean (75.5)** -- now clearing 5th-place Preact Signals (79.2) by ~5%, a gap that widened on the 1.3.0 run, behind only three push-eager engines: alien-signals, reflex, and @reactively.
20
+ On the independent [js-reactivity-benchmark](https://github.com/volynetstyle/js-reactivity-benchmark) (Andrii Volynets' fork; 15 reactive libraries, 47 tests), `lite-signal` **1.8.0** places **3rd overall by geomean (95.4 ms)** -- up from 4th on every prior sweep, clearing 4th-place @reactively (136.0) by ~43% and 5th-place Preact Signals (148.8) by ~56%, behind only alien-signals (77.5) and reflex (89.7).
21
21
 
22
22
  It is the **only object-pooled, zero-GC engine in the entire field**, and it gets that result without giving up glitch-freedom or lazy evaluation. Against the mainstream reactivity libraries it leads decisively:
23
23
 
24
24
  | vs | lite-signal is |
25
25
  | ---------------------- | -------------- |
26
- | **@vue/reactivity** | **1.5x faster** |
27
- | **Signia** | **1.7x faster** |
28
- | **MobX** | **2.3x faster** |
29
- | **@solidjs/signals** | **2.7x faster** |
30
- | **SolidJS** | **4.2x faster** |
31
- | Preact Signals | **1.05x faster** (~5% ahead) |
32
- | alien-signals | 0.56x (the field leader) |
33
-
34
- `lite-signal` finishes **top-3 on 21 of the 47 tests** and is the **outright fastest of all 15** on three wide aggregation shapes -- `manyEffectsFromOneSource` (1 source -> many effects, fan-out), plus `manySourcesIntoOneComputedEffect` and `manySourcesIntoOneComputedEffectWithDirect` (many sources -> one computed, fan-in) -- the patterns that dominate live dashboards, scoreboards, and HUDs. It also edges the field leader alien-signals on a fourth (the 1-source linear-chain pull). The three engines ahead of it are all push-eager designs that allocate on the hot path; `lite-signal` is the only top-4 finisher that allocates **nothing** in steady state. (Note: this suite measures reactivity *libraries* -- Vue's reactivity core, MobX, Solid, Preact Signals, etc. -- not full UI frameworks like React or Angular.)
26
+ | **@reactively** | **1.43x faster** |
27
+ | **Preact Signals** | **1.56x faster** (~56% ahead) |
28
+ | **@vue/reactivity** | **2.4x faster** |
29
+ | **Signia** | **3.2x faster** |
30
+ | **MobX** | **4.1x faster** |
31
+ | **@solidjs/signals** | **4.4x faster** |
32
+ | **SolidJS** | **7.7x faster** |
33
+ | reflex | 0.94x (~6% behind, 2nd place) |
34
+ | alien-signals | 0.81x (the field leader) |
35
+
36
+ `lite-signal` finishes **top-3 on 29 of the 47 tests** (up from 21 on the 1.3.0-era log) and is the **outright fastest of all 15** on **twenty shapes** -- the eight canonical propagation shapes (`avoidablePropagation`, `broadPropagation`, `deepPropagation`, `diamond`, `mux`, `repeatedObservers`, `triangle`, `unstable`), all four wide fan-in / fan-out shapes (`manyEffectsFromOneSource`, `manySourcesIntoOneComputedEffect`, `manySourcesIntoOneComputedEffectWithDirect`, `manySourcesIntoOneDirectEffect`), `molBench` (the mixed-app graph the suite uses as its realistic-workload proxy), and seven of the rectangular / layered DAG shapes (`64x6`, `24x8`, `120x7`, `40x10`, both `256->512x32 layered-dag` variants, and `10x10 dynamic component`). These are the aggregation and dynamic-DAG patterns that dominate live dashboards, scoreboards, and HUDs. The two engines ahead of it (alien-signals and reflex) are both push-eager designs that allocate on the hot path; `lite-signal` is the only top-3 finisher that allocates **nothing** in steady state. (Note: this suite measures reactivity *libraries* -- Vue's reactivity core, MobX, Solid, Preact Signals, etc. -- not full UI frameworks like React or Angular.)
35
37
 
36
38
  ```bash
37
39
  npm install @zakkster/lite-signal
@@ -766,27 +768,29 @@ These are the questions you'd ask in a code review, with the answers:
766
768
 
767
769
  ## Benchmarks
768
770
 
769
- Honest numbers, against the same workload, with anti-DCE sinks and verified effect execution. All measurements: Node 22, **2016-era Intel MacBook Pro (4 cores, ~10 yr old hardware)**, **one engine per cold process**, median across reps. Newer/faster machines shift all libs up proportionally; the relative ordering between libs is what matters. Numbers below are lite-signal **@1.3.0** (default `prealloc: "eager"`) vs alien-signals on the same `benchmark.mjs` loop -- the harness now reports **median execution time + transient heap** rather than ops/s. 1.3.0's hot paths are byte-identical to 1.2.2, so these track the 1.2.2 measurement; the deltas are run-to-run noise on this old host, not engine changes. **1.4.0, 1.5.0, and 1.6.0 carry these forward unchanged** -- 1.4.0 added three `stats()` counters on existing acquire/dispose/grow edges (never the steady-state read path); 1.5.0 added the box handle shape (allocation-light construction; the read/write hot path is the same pooled-node engine); 1.6.0 added `flushPasses` plus opcodes 6/7, all gated behind the existing `mutationHook !== null` check, so the flush loop is byte-identical to 1.5.0 when no listener is attached. Throughput is unchanged across all three additions (fresh 1.4.0 / 1.5.0 / 1.6.0 bench runs will be published when available). Full per-engine tables: [`results.txt`](./results.txt) (this propagation suite) and [`resultsReactive.txt`](./resultsReactive.txt) (the cross-framework reactivity suite).
771
+ Honest numbers, against the same workload, with anti-DCE sinks and verified effect execution. All measurements: **Node 26.3.1, Apple M4 Pro (darwin/arm64)**, **one engine per cold process**, median across reps, machine-stamped `#STAMP` (engine + harness sha256, live registry config, host, node) on every output. Newer/faster machines shift all libs up proportionally; the relative ordering between libs is what matters -- and on this newer silicon the run-to-run noise floor is lower, so the sub-percent parity band tightens and the honest wins/losses stand out cleanly. Numbers below are the **fresh 1.8.0 bench sweep** on the v3 **microscope** (`benchmark.mjs`, six first-party shapes, default `prealloc: "eager"`) vs alien-signals -- the harness reports **median execution time + transient heap** rather than ops/s. 1.7.0 -> 1.8.0 changes the hot path only in `executeEffect` (the effect-cleanup-return check: one `typeof` per effect run, off the mark/pull path); sha256 over the 15 other function bodies is byte-identical between pristine 1.7.0-preview and pristine 1.8.0 (verified: `pullComputed`, `markDownstream`, `flushEffects`, `allocateLink`, `severTail`, `createNode`, `runCleanup`, `disposeNode`, `createRoot`, `createScope`, `flush`, `batch`, `signal`, `computed`, `effect`). Full outputs: [`bench/r.txt`](./bench/r.txt) (this microscope aggregate across four engines) and [`bench/rb.txt`](./bench/rb.txt) (the mirror sweep -- Andrii's canonical adapter verbatim, 47 rows, lite vs alien on the same M4 Pro host).
770
772
 
771
773
  | Scenario | What it stresses | lite-signal | alien-signals | lite vs alien | transient heap (lite / alien) |
772
774
  | ---------- | -------------------------------- | ----------- | ------------- | ------------- | ----------------------------- |
773
- | **SELECTIVE DAG** | sqrt-layered, set churn, 2 read/iter | **4744 ms** | 9176 ms | **+48% faster** | **1.5 MB / 37 MB** (24x less) |
774
- | **DYNAMIC DAG** | sqrt-layered, FAN=6, read flips each iter | **9670 ms** | 16888 ms | **+43% faster** | **5.1 MB / 24 MB** (4.7x less) |
775
- | **MUX** | 256 signals -> 1 sum -> 1 effect (fan-in) | **67 ms** | 108 ms | **+38% faster** | **38 KB / 3.9 MB** (104x less) |
776
- | **SMALL SELECTIVE** | 6 layers × 64 wide, 6 cand / 3 read | **1937 ms** | 2744 ms | **+29% faster** | **0.3 KB / 23.9 MB** (>=23934x less) |
777
- | **KAIROS** | 1 signal -> 1000 computeds -> 1 effect | 1339 ms | 1325 ms | -1% (parity) | 178 KB / 1.1 MB (6.4x less) |
778
- | **LARGE WEB APP** | 12 layers × ~80 wide, conditional reads | 2801 ms | 2701 ms | -4% (parity) | **0.3 KB / 41 KB** (41x less) |
779
- | **WIDE DENSE** | 5 layers × ~200 wide, dense fan-in | 2850 ms | 2740 ms | -4% (parity) | **0.3 KB / 11.6 MB** (>=11605x less) |
780
- | **BROADCAST** | 1 signal -> 1000 effects (fan-out) | 1182 ms | 1074 ms | -10% | 72 KB / 21 KB |
781
- | **DEEP CHAIN** | 256-deep computed chain -> 1 effect | 401 ms | **339 ms** | -18% | 18 KB / 905 KB (49.7x less) |
775
+ | **MUX** | 256 signals -> 1 sum -> 1 effect (fan-in) | **23.00 ms** | 35.00 ms | **+34.3% faster** | **0 KB / 781 KB** (100% less) |
776
+ | **SELECTIVE DAG** | sqrt-layered, set churn, 2 read/iter | **2012 ms** | 2493 ms | **+19.3% faster** | **7.7 MB / 77.8 MB** (90.0% less, 10.0x) |
777
+ | **DYNAMIC DAG** | sqrt-layered, FAN=6, read flips each iter | **3700 ms** | 4448 ms | **+16.8% faster** | **3.3 MB / 59.8 MB** (94.5% less, 18.3x) |
778
+ | **BROADCAST** | 1 signal -> 1000 effects (fan-out) | **433.51 ms** | 478.35 ms | **+9.4% faster** | ~0 KB / ~0 KB (both fit under GC floor) |
779
+ | **KAIROS** | 1 signal -> 1000 computeds -> 1 effect | 502.01 ms | 433.19 ms | -15.9% | **23 KB / 802 KB** (97.1% less, 34.3x) |
780
+ | **DEEP CHAIN** | 256-deep computed chain -> 1 effect | 170.10 ms | **98.57 ms** | -72.6% | **0.5 KB / 1062 KB** (100% less, >2000x) |
782
781
 
783
782
  *(lower time = faster; transient heap = average delta-heap per rep, lower = less GC pressure)*
784
783
 
785
- **Reading the table:** lite-signal's time wins cluster exactly where its zero-GC design pays off -- the **allocation-heavy dynamic shapes** (**SELECTIVE DAG +48%**, **DYNAMIC DAG +43%**, **SMALL SELECTIVE +29%**), where alien-signals churns the nursery and lite's object pool allocates near-nothing, plus **MUX +38%** (fan-in aggregation). These are the patterns that dominate live UI workloads under input churn: dashboards, scoreboards, HUDs, leaderboards. On the cheap, low-allocation **stable** shapes (KAIROS, large web app, wide dense) lite runs at **parity** with alien -- within a 1-4% band inside this old host's run-to-run noise. The two losses are **BROADCAST (-10%)** (pure fan-out, no retracking for the pool to amortize) and **DEEP CHAIN (-18%)**: on a 256-deep computed pipeline alien's flatter representation wins because the propagation path is long rather than wide.
784
+ **Reading the table:** lite-signal's time wins cluster exactly where its zero-GC design pays off -- the **allocation-heavy dynamic shapes** (**SELECTIVE DAG +19.3%**, **DYNAMIC DAG +16.8%**), where alien-signals churns the nursery and lite's object pool allocates near-nothing, plus **MUX +34.3%** (fan-in aggregation) and **BROADCAST +9.4%** (fan-out; recovered from +6.2% on 1.7.0-preview). These are the patterns that dominate live UI workloads under input churn: dashboards, scoreboards, HUDs, leaderboards. That is **4 wins of 6** on time; on this sweep the wins hold within noise of the 1.7.0-preview M4 Pro sweep despite the 1.7.0 -> 1.8.0 `executeEffect` change, which is what "one `typeof` per effect run, off the mark/pull path" looks like in the propagation numbers. The two losses:
785
+
786
+ - **DEEP CHAIN (-72.6%)** is the engine's structurally worst shape and the largest open performance gap it has. On a 256-deep pull chain alien's flatter representation wins outright (99 ms vs 170 ms). It is not closed and it is not going to be closed by tuning. Note the inversion: **lite loses the row on time by 73% while allocating >2000x less heap**.
787
+ - **KAIROS (-15.9%)** widened from -11.7% on 1.7.0-preview: 1 source -> 1000 computeds has almost nothing to retrack, so the pooled representation pays its per-node indirection with no allocation saving to show for it.
788
+
789
+ On **allocation pressure** `lite-signal` wins **5 of 6** and is one to four orders of magnitude below alien on every shape where GC pressure exists at all: DEEP CHAIN 0.5 KB vs 1062 KB (>2000x less -- yes, on the shape where lite is behind on time), MUX 0 KB vs 781 KB, KAIROS 23 KB vs 802 KB (34.3x), DYNAMIC DAG 3.3 MB vs 59.8 MB (18.3x), SELECTIVE DAG 7.7 MB vs 77.8 MB (10.0x). On BROADCAST both engines are effectively zero. Against preact-signals and solid-signals the heap gap is even wider on the fan-in / fan-out family -- solid allocates ~17 MB on MUX and ~16 MB on SELECTIVE DAG where lite allocates 0 KB and 7.7 MB respectively (`bench/r.txt`). **`lite-signal`'s differentiated position is ALLOCATION, not raw propagation speed**: competitive-to-winning throughput with dramatically lower GC pressure, not "fastest dynamic-graph engine". That headline is the one that reproduces across hosts, sweeps, and third-party version bumps -- because the object pool is the mechanism, not a tuning knob.
786
790
 
787
- On allocation pressure, `lite-signal` wins **8 of 9 scenarios** and is alone in the zero-alloc band: **~0.3 KB** of transient garbage on the stable app shapes (large web app, wide dense, small selective) across the whole run. The contrast is starkest on the dynamic DAGs -- lite allocates 1.5-5 MB (genuine retracking re-links) where alien-signals allocates 24-37 MB on the same shapes, and that allocation gap is the mechanism behind lite's +43-48% wins there once each engine is measured in isolation. The one scenario where lite allocates more is **BROADCAST** (72 KB vs alien's 21 KB), a pure fan-out with no retracking. `prealloc: "lazy"` trades a little extra first-construction allocation on the dynamic shapes for a smaller resident heap and faster cold start; the steady state is identical. preact and solid trail both engines on the dynamic shapes by 1-2 orders of magnitude on transient heap.
791
+ The mirror-sweep companion ([`bench/rb.txt`](./bench/rb.txt)) reproduces the picture across Andrii's 47 shapes on the same M4 Pro host: lite runs **parity-to-behind alien on throughput** across the head-to-head suite, wins outright on **4 of the 47** (`1000x5 - 25 sources (wide dense)` +12.0%, `manySourcesIntoOneComputedEffectWithDirect` +31.1%, `manySourcesIntoOneComputedEffect` +29.5%, and `molBench` +0.3%), weak on the deep/layered-burst family. That head-to-head result and the top-of-file "3rd of 15 with 20 outright wins" both live on the same log -- they are not contradictory: the outright-of-15 rankings look at each shape across every framework in the field, so shapes where alien beats lite by 20-30% but reflex beats both by another 10% and everyone else is slower can still count as a lite outright win when the leaderboard is measured that way.
788
792
 
789
- > Note on the +70.8 KB retained that lite-signal shows on KAIROS specifically: that's the pre-allocated pool sitting in memory holding the live graph (1002 nodes + ~2000 links). The pool *is* the working memory -- see the [Case for object pooling](#case-for-object-pooling) section. On the other benches the graph is small enough that the same pool floats below baseline after GC.
793
+ > Note on the +23 KB delta-heap that lite-signal shows on KAIROS: that's the pre-allocated pool sitting in memory holding the live graph (1002 nodes + ~2000 links). The pool *is* the working memory -- see the [Case for object pooling](#case-for-object-pooling) section. On the other shapes the graph is small enough that the same pool floats below the GC baseline.
790
794
 
791
795
  The benchmark harness is in [`bench/benchmark.mjs`](./bench/benchmark.mjs); a full methodology write-up -- including the anti-DCE design, workload diagrams, variance discipline, reproducibility recipe, and a self-validation procedure for the harness itself -- lives in [`bench/README.md`](./bench/README.md). It:
792
796
 
@@ -860,15 +864,62 @@ npm run test:gc
860
864
 
861
865
  ### Tier 3 -- Performance (comparative benchmark)
862
866
 
863
- `npm run bench` runs the **microscope** -- lite's recommended eager config on six first-party shapes (`bench/results.txt`). Cross-framework standing comes from the **mirror** (`node --expose-gc bench/mirror.mjs --self-verify` then `bench/sweep.mjs`), which runs Andrii's canonical adapter verbatim so rows diff 1:1 against his log. Every output carries a machine-generated `#STAMP` (engine + harness sha256, the live registry config, host, node), so a header can never disagree with the code that ran. The pre-v3 five-framework reactivity suite was **removed after 1.5.1** (bench protocol v3). Full methodology: [`bench/README.md`](./bench/README.md).
867
+ `npm run bench` runs the **microscope** -- lite's recommended eager config on six first-party shapes; the aggregate output is [`bench/r.txt`](./bench/r.txt) (four engines: lite, alien, preact, solid). Cross-framework standing comes from the **mirror** (`node --expose-gc bench/mirror.mjs --self-verify` then `bench/sweep.mjs`), which runs Andrii's canonical adapter verbatim so rows diff 1:1 against his log; the aggregate output is [`bench/rb.txt`](./bench/rb.txt) (lite vs alien, all 47 shapes). Every output carries a machine-generated `#STAMP` (engine + harness sha256, the live registry config, host, node), so a header can never disagree with the code that ran. The pre-v3 five-framework reactivity suite was **removed after 1.5.1** (bench protocol v3). Full methodology: [`bench/README.md`](./bench/README.md).
864
868
 
865
869
  ```bash
866
870
  npm run bench
867
871
  ```
868
872
 
869
- ### Tier 4 -- Torture soaks (crash detection under chaos)
873
+ ### Tier 4 -- Torture (correctness and resources under chaos)
874
+
875
+ `bench/torture/` holds the complete **17-scenario superset (14 semantic + 3
876
+ soak)** behind one runner (`run.mjs`), the forward-compatible set through 1.9.
877
+ They are not perf benchmarks: the ops/sec figures reflect random workload
878
+ composition, not engine throughput -- `bench/benchmark.mjs` remains the canonical
879
+ perf harness. Every scenario feature-detects and **skips cleanly** below the
880
+ engine version that introduces its feature, so on the 1.8.0 engine the runner
881
+ executes **13 semantic** scenarios (including `cleanup-return-torture`) and
882
+ reports a clean SKIP for the one remaining later-version scenario
883
+ (`dispose-torture` 1.9.0).
884
+
885
+ ```bash
886
+ npm run torture # everything
887
+ npm run torture:semantic # correctness only, CI-shaped
888
+ npm run torture:soak # resource soaks only
889
+ node bench/torture/run.mjs --list
890
+ ```
870
891
 
871
- `bench/torture/` contains three soak harnesses that build large randomised graphs (1,500 / 7,500 / 3,300 nodes) and run mixed fuzz workloads -- leaf writes, batched writes, computed rewires, effect rewires, nested-batch + untrack reads, and microtask-scheduled async flushes -- for 5-10 seconds. These are not perf benchmarks. The numbers they print (ops/sec) reflect random workload composition, not engine throughput; the existing `bench/benchmark.mjs` is the canonical perf harness. What the soaks DO assert, with a non-zero exit code on failure:
892
+ #### `semantic` -- deterministic, fast, asserts on **meaning**
893
+
894
+ Run these on every commit. The nine untagged scenarios run on any 1.4.x+ engine;
895
+ `box-torture` (1.5.0), `scope-torture` (1.6.0), `flush-torture` (1.7.0), and
896
+ `cleanup-return-torture` (1.8.0) run here because their features exist; the one
897
+ tagged `1.9.0+` scenario feature-detects and SKIPs on this engine.
898
+
899
+ | scenario | pins |
900
+ | -------- | ---- |
901
+ | `oracle-fuzzer` | every computed against an independent uncached reference evaluator, 400 seeds x 120 ops |
902
+ | `glitch-hunter` | glitch freedom across diamonds, plus exact wakeup counts |
903
+ | `work-accounting` | minimum body-execution counts across 10 fixed topologies |
904
+ | `op-accounting` | structural work counted from the `onGraphMutation` opcode lane (op 1-5), not wall-clock |
905
+ | `introspect-torture` (1.6.0) | the read-only introspection surface (`describe`/`nodeId`/`hasObservers`/`isTracking`/`forEach*`/`ownerOf`/`observeObservers`): walk-agreement against the reference dep set + op-3/op-4 lane, and the ABA gen-stamp guard on re-walkable descriptors |
906
+ | `concurrent-storm` | eight reentrancy and flush-ordering contracts |
907
+ | `scheduler-storm` | deferred execution under 10,000 effects: gen-bound thunk ABA guard, `FLAG_QUEUED` coalescing, a throwing scheduler contained |
908
+ | `box-torture` (1.5.0) | `signalBox`/`computedBox` interop: the oracle differential fuzz with every node realised as **either** a callable or a box |
909
+ | `scope-torture` (1.6.0) | `createScope` adoption contract, the disposal-crash repro + a 300-seed fuzz, `runWithOwner` re-attachment into a scope, pool balance over 200 rounds |
910
+ | `async-torture` | `watch`/`when`/`whenAsync` contracts + a 300-seed projection-guard storm |
911
+ | `capacity-torture` | the fail-closed pool boundary: exact ceilings, re-throw-on-read, `grow` crossing the same boundary |
912
+ | `flush-torture` (1.7.0) | the three `flushStrategy` modes by cross-strategy differential (same graph + op sequence under eager/sab/manual settling to identical values), per-strategy scheduling, re-entrant/empty `flush()`, and the `.subscribe()` contract under each |
913
+ | `cleanup-return-torture` (1.8.0) | an effect's returned cleanup: timing at re-run/dispose, compose order (appended after `onCleanup` from the same body), the self-dispose guard, and the computed exclusion -- 400 seeds |
914
+ | `dispose-torture` (1.9.0+) | `Symbol.dispose` / `using` on lifecycle objects -- SKIP on 1.8.0 |
915
+
916
+ #### `soak` -- wall-clock bound, asserts on **resources**
917
+
918
+ Three soak harnesses build large randomised graphs (1,500 / 7,500 / 3,300 nodes)
919
+ and run mixed fuzz workloads -- leaf writes, batched writes, computed rewires,
920
+ effect rewires, nested-batch + untrack reads, and microtask-scheduled async
921
+ flushes -- for 5-10 seconds. What they assert, with a non-zero exit code on
922
+ failure:
872
923
 
873
924
  - zero thrown exceptions during the run, and
874
925
  - after teardown, `activeNodes` / `activeLinks` return to the leaf-only baseline (the dispose path is sound under sustained churn).
@@ -896,7 +947,7 @@ npm run verify # test + test:gc + a sanity bench
896
947
  ## Performance Trade-offs & Topology Scaling
897
948
 
898
949
  <details>
899
- <summary>Stable vs dynamic topologies; Andrii Volynets' matrix, the 1.1.4 result, the 1.3.0 ranking, and the roadmap.</summary>
950
+ <summary>Stable vs dynamic topologies; Andrii Volynets' matrix, the 1.1.4 result, the 1.8.0 ranking, and the roadmap.</summary>
900
951
 
901
952
  `lite-signal` was built with a strict mandate: **absolute zero garbage collection**. By packing the dependency graph into a flat, pre-allocated memory arena, we eliminate the Scavenger GC pauses that plague 120fps Canvas/WebGL loops.
902
953
 
@@ -904,10 +955,10 @@ Through **v1.1.2**, that came with a mathematical trade-off: while memory alloca
904
955
 
905
956
  **Andrii Volynets** (author of the phenomenal [Alien Signals](https://github.com/stackblitz/alien-signals)) generously ran `lite-signal` through his advanced topology matrix on the **v1.1.2** engine. Those numbers -- the *pre-rewrite baseline* -- are below, followed by the 1.1.4 result.
906
957
 
907
- **1.3.0 on the official [js-reactivity-benchmark](https://github.com/volynetstyle/js-reactivity-benchmark) (15 libraries, 47 tests):** `lite-signal` holds **4th overall by geomean (75.5ms)**, behind only alien-signals (42.6, the field leader at 0.56x), reflex (48.9), and @reactively (59.3), and now **ahead of 5th-place Preact Signals (79.2, ~5%)** -- a gap that widened from 1.2.x. It finishes **top-3 on 21 of 47 tests** and is the **outright fastest of all 15 on three wide-aggregation shapes** -- `manyEffectsFromOneSource`, `manySourcesIntoOneComputedEffect`, and `manySourcesIntoOneComputedEffectWithDirect` -- even edging the leader alien-signals on those plus the 1-source linear-chain pull. It remains the only object-pooled, zero-GC engine in the field.
958
+ **1.8.0 on the official [js-reactivity-benchmark](https://github.com/volynetstyle/js-reactivity-benchmark) (15 libraries, 47 tests, raw log at [`bench/AndriiVolynetsReactiveBench.log`](./bench/AndriiVolynetsReactiveBench.log)):** `lite-signal` **moves into 3rd overall by geomean (95.4 ms)**, behind only alien-signals (77.5, the field leader at 0.81x) and reflex (89.7, 0.94x), and **ahead of 4th-place @reactively (136.0, 1.43x) and 5th-place Preact Signals (148.8, ~56%)**. It finishes **top-3 on 29 of 47 tests** and is the **outright fastest of all 15 on twenty shapes** -- the eight canonical propagation shapes (`avoidablePropagation`, `broadPropagation`, `deepPropagation`, `diamond`, `mux`, `repeatedObservers`, `triangle`, `unstable`), all four wide fan-in / fan-out shapes (`manyEffectsFromOneSource`, `manySourcesIntoOneComputedEffect`, `manySourcesIntoOneComputedEffectWithDirect`, `manySourcesIntoOneDirectEffect`), `molBench`, and seven of the rectangular / layered DAG shapes. This is a dramatic step from the 3 outright wins of the 1.3.0-era log and the 4 of 1.7.0-preview -- driven by the same engine bytes across every propagation function except `executeEffect`, which is where the 1.8.0 effect-cleanup-return check landed. It remains the only object-pooled, zero-GC engine in the field.
908
959
 
909
960
  #### 1. Stable Topologies (Fan-in / Fan-out / Broadcast)
910
- In stable environments (game engines, particle systems, visualizers), `lite-signal` is blisteringly fast and maintains a near-zero allocation profile, keeping frame times perfectly flat -- unchanged through 1.1.4.
961
+ In stable environments (game engines, particle systems, visualizers), `lite-signal` is blisteringly fast and maintains a near-zero allocation profile, keeping frame times perfectly flat -- unchanged through 1.1.4 and holding on 1.8.0.
911
962
 
912
963
  #### 2. Dynamic Topologies (Web Apps / Layered DAGs) -- closed in 1.1.4
913
964
  *Andrii's v1.1.2 baseline (his host) -- where the cursor retracking lost:*
@@ -917,27 +968,30 @@ In stable environments (game engines, particle systems, visualizers), `lite-sign
917
968
  | **1000x5 (25 sources, wide/dense)** | 304ms | 303ms | 1746ms |
918
969
  | **64x6 (selective dynamic DAG)** | 181ms | 196ms | 559ms |
919
970
 
920
- *1.3.0 (default eager) on the local harness (slow 2016 MacBook, one engine per cold process -- compare within-column, lite vs alien; the approximating scenarios from `bench/benchmark.mjs`):*
921
- | Scenario | alien-signals | lite-signal (1.3.0) | result |
971
+ *1.8.0 (default eager) on the v3 microscope (`bench/r.txt`, Apple M4 Pro darwin/arm64, Node 26.3.1, one engine per cold process -- compare within-column, lite vs alien):*
972
+ | Scenario | alien-signals | lite-signal (1.8.0) | result |
922
973
  | :--- | :--- | :--- | :--- |
923
- | **SELECTIVE DAG** (sqrt-layered, set churn) | 9176ms | 4744ms | **lite +48%** |
924
- | **DYNAMIC DAG** (sqrt-layered, FAN=6) | 16888ms | 9670ms | **lite +43%** |
925
- | **SMALL SELECTIVE** (~ 64x6) | 2744ms | 1937ms | **lite +29%** |
926
- | **LARGE WEB APP** (~ 1000x12) | 2701ms | 2801ms | alien +4% |
927
- | **WIDE DENSE** (~ 1000x5) | 2740ms | 2850ms | alien +4% |
928
-
929
- > **Honest note (1.3.0 isolated run):** measured one-engine-per-process, lite-signal's
930
- > wins are on the **allocation-heavy** dynamic shapes (SELECTIVE DAG +48%, DYNAMIC DAG
931
- > +43%, SMALL SELECTIVE +29%) -- exactly where alien churns the nursery and lite's pool
932
- > allocates near-nothing. The cheaper wide-app/dense shapes land within a few percent
933
- > either way (host noise on this old machine). 1.3.0's hot paths are byte-identical to
934
- > 1.2.2, so these match the 1.2.2 isolated numbers -- the deltas are run-to-run noise,
935
- > not engine changes. lite remains the only zero-alloc library on every stable scenario
936
- > (see [`results.txt`](./results.txt)).
937
-
938
- The cross-framework reactivity suite agrees independently, re-run on **1.3.0** (default eager, median-of-10, isolated): lite-signal is the **fastest of five frameworks on all five `dyn` rows** -- `dyn: large web app` **544ms** (+7% vs alien-signals' 586ms) and `dyn: wide dense` **902ms** (+3% vs 926ms), plus simple component (+17%), dynamic component (+15%), and deep (+14%) -- with preact 6-19× slower and vue 15-32× slower on the app-shaped graphs (see [`resultsReactive.txt`](./resultsReactive.txt)). On the tiny `S: updateComputations` micro-rows lite and alien trade the lead within a few percent (lite ahead on 3 of 7); these sub-60ms kernels are dominated by run-to-run noise on this old host. The retracking is verified correct by `retracking.difftest.mjs` -- 20,000 direct + 10,000 batched writes, 0 disagreements against the **published 1.1.5** reference (re-pinned for v1.2).
939
-
940
- **The Takeaway:** as of 1.1.4 you no longer have to choose, and 1.3.0 holds the line -- the engine still ranks **4th of 15** on the official js-reactivity-benchmark (the only zero-GC library in the field). `lite-signal` keeps the zero-GC, flat-arena profile for 120fps Canvas/WebGL **and** wins decisively on the high-churn dynamic and fan-in topologies that dominate live UI -- the shapes where zero allocation pays off most. It runs at parity with alien-signals on cheap stable shapes. The one shape where alien's flatter representation still leads is the 256-deep computed pipeline (DEEP CHAIN, -18% on the 1.3.0 isolated run).
974
+ | **MUX** (256 sigs -> sum -> effect) | 35.00 ms | 23.00 ms | **lite +34.3%** |
975
+ | **SELECTIVE DAG** (sqrt-layered, set churn) | 2493 ms | 2012 ms | **lite +19.3%** |
976
+ | **DYNAMIC DAG** (sqrt-layered, FAN=6) | 4448 ms | 3700 ms | **lite +16.8%** |
977
+ | **BROADCAST** (1 -> 1000 effects) | 478.35 ms | 433.51 ms | **lite +9.4%** (recovered from +6.2% on 1.7.0-preview) |
978
+ | **KAIROS** (1 -> 1000 computeds) | 433.19 ms | 502.01 ms | alien +15.9% (widened from -11.7% on 1.7.0-preview) |
979
+ | **DEEP CHAIN** (256-deep pull) | 98.57 ms | 170.10 ms | **alien +72.6%** |
980
+
981
+ > **Honest note (1.8.0 isolated run):** measured one-engine-per-process, lite-signal's
982
+ > wins cluster on the **allocation-heavy** dynamic shapes and fan-in / fan-out (MUX
983
+ > +34.3%, SELECTIVE DAG +19.3%, DYNAMIC DAG +16.8%, BROADCAST +9.4%) -- exactly where
984
+ > alien churns the nursery and lite's pool allocates near-nothing. The wins hold within
985
+ > noise of the 1.7.0-preview M4 Pro sweep despite the 1.7.0 -> 1.8.0 `executeEffect`
986
+ > change (one `typeof` per effect run, off the mark/pull path); every other propagation
987
+ > function is sha256-identical between the two engines. **BROADCAST recovered** from
988
+ > +6.2% to +9.4%; **KAIROS widened** slightly from -11.7% to -15.9%. lite remains one
989
+ > to four orders of magnitude below alien on transient heap on every shape where GC
990
+ > pressure exists at all (see [`bench/r.txt`](./bench/r.txt)).
991
+
992
+ The mirror sweep ([`bench/rb.txt`](./bench/rb.txt), Andrii's canonical adapter verbatim, isolated-per-row, 10 reps, lite vs alien across all 47 shapes on the same M4 Pro host) reproduces the same picture: lite runs **parity-to-behind alien on throughput** across the head-to-head suite, wins outright on **4/47** (`1000x5 - 25 sources (wide dense)` +12.0%, `manySourcesIntoOneComputedEffectWithDirect` +31.1%, `manySourcesIntoOneComputedEffect` +29.5%, and `molBench` +0.3%), weak on the deep/layered-burst family. Every row carries a `#STAMP` and the counters (`nodesRecomputed` / `edgesTraversed` / `sinkReads`) match Andrii's published suite exactly, so a lite-vs-alien delta here is identical work, not DCE. The retracking is verified correct by `retracking.difftest.mjs` -- 20,000 direct + 10,000 batched writes, 0 disagreements against the **published 1.1.5** reference.
993
+
994
+ **The Takeaway:** as of 1.1.4 you no longer have to choose, and 1.8.0 pushes the ranking up -- the engine now ranks **3rd of 15** on the official js-reactivity-benchmark (up from 4th on every prior sweep) and is the only zero-GC library in the field. `lite-signal` keeps the zero-GC, flat-arena profile for 120fps Canvas/WebGL **and** wins decisively on the high-churn dynamic and fan-in topologies that dominate live UI -- the shapes where zero allocation pays off most. On the M4 Pro microscope BROADCAST recovered from parity to a +9.4% win; KAIROS widened slightly. The one shape where alien's flatter representation still leads decisively is the 256-deep computed pipeline (DEEP CHAIN, -72.6% on the M4 Pro isolated run) -- and that gap is structural, not a tuning bug.
941
995
 
942
996
  ### Roadmap
943
997
  - **1.1.5** -- additions in service of `lite-devtools` (node identity/traversability on the introspection walkers, for full auto-discovered graph rendering). *Shipped.*
@@ -1269,7 +1323,7 @@ Wired as `npm run test:harness`.
1269
1323
  npm test # behavior suite, ~1.3s
1270
1324
  npm run test:gc # zero-gc suite, requires --expose-gc, ~3s
1271
1325
  npm run test:harness # profiler-tools hardening suite
1272
- npm run bench # comparative benchmark vs alien-signals (results.txt), ~5min
1326
+ npm run bench # microscope + mirror comparative benches (r.txt / rb.txt), ~5min
1273
1327
  node --expose-gc bench/mirror.mjs --self-verify # cross-framework mirror sweep (bench protocol v3)
1274
1328
  npm run harness:smoke # flushStrategy semantics -- asserts
1275
1329
  npm run harness:all # smoke + field + dispose + churn probes
package/Signal.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @zakkster/lite-signal v1.8.0-alpha.0 (ledger #18 corrected)
2
+ * @zakkster/lite-signal v1.8.0-alpha.4
3
3
  * Copyright (c) Zahary Shinikchiev <shinikchiev@yahoo.com>
4
4
  * MIT License
5
5
  * --------------------
package/llms.txt CHANGED
@@ -53,7 +53,36 @@ triggering write -- no `queueMicrotask`, no promises, no scheduler ticks.
53
53
 
54
54
  ## Version notes
55
55
 
56
- - **1.6.0-preview** (current): the **observability-and-lifecycle minor**, shipping
56
+ - **1.8.0-alpha.4** (current): the **effect-cleanup-return minor**. An EFFECT body
57
+ may now `return` a cleanup function (Solid/Vue/Reflex-compatible), run at the same
58
+ points as imperative `onCleanup` -- before each re-run and once on dispose -- and
59
+ APPENDED after any `onCleanup` from the same body, so both compose in call order.
60
+ Non-function returns are ignored; a self-disposed body registers nothing
61
+ (gen-guarded); computeds are excluded (a returned function stays the VALUE). Cost
62
+ is one `typeof` per effect run, off the mark/pull path; `executeEffect` is the only
63
+ hot body whose sha256 changed 1.7.0 -> 1.8.0. `alpha.4` also carries the
64
+ dangling-cursor crash fix (a one-line `disposeNode` cursor repair, which also
65
+ composes with the cleanup-return path; the dead `freeLink` `-1` arms removed) and
66
+ closes `Signal.js` to **100%** statements/branches/functions/lines. Torture: the
67
+ `cleanup-return-torture` scenario now **executes** (400 seeds: timing, compose
68
+ order, self-dispose guard, computed exclusion), so the 17-scenario runner runs
69
+ **13 semantic** + 1 skip (`dispose` 1.9.0). Verified green: torture 17/17; unit
70
+ **492 tests, 472 pass, 0 fail, 1 skip** (SSR N/A) -- 491 pass with the sibling
71
+ `@zakkster/lite-devtools` the 19-test `test/25` rig needs. Drop-in over 1.7.0.
72
+
73
+ - **1.7.0**: the **flush-strategy minor**. `createRegistry({flushStrategy})` gives
74
+ per-registry control over *when* effects deliver (`"eager"` default | `"sab"` |
75
+ `"manual"`), plus an explicit `r.flush()` on every registry; the lever resolves
76
+ once at init into two closure-captured `const` booleans, so the `"eager"` body is
77
+ byte-identical to 1.6.0. Also forward-ported `getOwner` / `runWithOwner` (the
78
+ gen-stamped capture-and-restore companion to `createRoot`) from 1.5.0-beta.2, and
79
+ fixed the propagation benchmark harness (every lite adapter had been built with
80
+ `flushStrategy: "sab"` while driving un-batched `.set` and never flushing, so
81
+ effects ran once at creation and never again -- every pre-1.7.0 number in
82
+ `bench/results.txt` is void). Torture added `flush-torture` (the three modes by
83
+ cross-strategy differential + `.subscribe()`).
84
+
85
+ - **1.6.0-preview**: the **observability-and-lifecycle minor**, shipping
57
86
  on the `preview` dist-tag while it settles. Two additions, both on existing
58
87
  hot-path-adjacent edges:
59
88
 
@@ -528,48 +557,72 @@ None of these touch the reactive engine -- no `FLAG_WATCHER` on `ReactiveNode`,
528
557
 
529
558
  The deliberate engineering for `watch`'s "0 per fire" is the hoisted `untrackedFire` closure with `currentNewValue` shared mutable state -- see source comment in `watch.js`. Inline arrow function inside the effect body would allocate per fire and break the zero-GC contract.
530
559
 
531
- ## Benchmark snapshot (Node 22, 2016-era Intel MacBook Pro, default eager, median across reps -- @1.3.0)
532
-
533
- `benchmark.mjs` head-to-head vs alien-signals on app-shaped scenarios (time = median
534
- execution; heap = average transient delta-heap per rep; lite-signal numbers are
535
- @1.3.0, hot paths byte-identical to 1.2.2):
536
-
537
- | Scenario | lite vs alien (time) | transient heap (lite / alien) |
538
- | -------------------------------- | -------------------- | ----------------------------- |
539
- | SELECTIVE DAG (set churn) | **+48% faster** | 1.5 MB / 37 MB |
540
- | DYNAMIC DAG (FAN=6, read flips) | **+43% faster** | 5.1 MB / 24 MB |
541
- | MUX (256 sigs -> sum -> effect) | **+38% faster** | 38 KB / 3.9 MB |
542
- | SMALL SELECTIVE (~64x6) | **+29% faster** | 0.3 KB / 23.9 MB |
543
- | KAIROS (1 -> 1000 computeds) | -1% (parity) | 178 KB / 1.1 MB |
544
- | LARGE WEB APP (~1000x12) | -4% (parity) | 0.3 KB / 41 KB |
545
- | WIDE DENSE (~1000x5) | -4% (parity) | 0.3 KB / 11.6 MB |
546
- | BROADCAST (1 -> 1000 effects) | -10% | 72 KB / 21 KB |
547
- | DEEP CHAIN (256-deep -> effect) | -18% | 18 KB / 905 KB |
548
-
549
- lite-signal's time wins are the allocation-heavy dynamic shapes (object pool allocates
550
- near-nothing; alien churns the nursery), plus MUX fan-in aggregation -- the patterns
551
- that dominate live UI under input churn. Parity on the cheap stable wide shapes (within
552
- run-to-run noise on this old host). Two losses: BROADCAST (pure fan-out, no retracking
553
- for the pool to amortize) and DEEP CHAIN (alien's flatter representation wins when the
554
- propagation path is long rather than wide). On allocation, lite wins 8/9 scenarios and
555
- is alone in the zero-alloc band (~0.3 KB transient on the stable app shapes). NOTE: the
556
- BROADCAST and KAIROS results are now parity-or-behind on 1.3.0's isolated harness;
557
- earlier ops/s snapshots that showed lite ahead on those were measured under a different
558
- (multi-engine, shared-heap) protocol.
559
-
560
- The cross-framework reactivity suite (5 frameworks) re-run on 1.3.0 (default eager,
561
- median-of-10): lite-signal is fastest on all five `dyn:*` rows -- `dyn: large web app`
562
- 544ms (+7% vs alien-signals' 586ms), `dyn: wide dense` 902ms (+3% vs 926ms), plus
563
- simple component (+17%), dynamic component (+15%), deep (+14%) -- with preact 6-19x
564
- slower and vue 15-32x slower on the app-shaped graphs. On the sub-60ms
565
- `S: updateComputations` micro-rows lite and alien trade the lead within a few percent
566
- (lite ahead on 3/7), noise-dominated on this host. Retracking verified correct by
567
- `retracking.difftest.mjs` (20,000 direct + 10,000 batched writes, 0 disagreements vs
568
- published 1.1.5). `prealloc: "lazy"` trades a little first-construction allocation on the
569
- dynamic shapes for a smaller resident heap and faster cold start; steady state identical.
560
+ ## Benchmark snapshot (Node 26.3.1, Apple M4 Pro darwin/arm64, default eager, median across reps -- @1.8.0)
561
+
562
+ v3 microscope (`benchmark.mjs`, six first-party shapes, `bench/r.txt`) head-to-head vs
563
+ alien-signals (time = median execution; heap = average transient delta-heap per rep;
564
+ lite-signal numbers are @1.8.0, hot paths byte-identical to 1.7.0-preview except for
565
+ `executeEffect`, which added the effect-cleanup-return `typeof` check off the mark /
566
+ pull path; sha256 over the 15 other function bodies matches pristine 1.7.0-preview
567
+ byte-for-byte):
568
+
569
+ | Scenario | lite | alien | lite vs alien (time) | transient heap (lite / alien) |
570
+ | -------------------------------- | -------- | -------- | -------------------- | ----------------------------- |
571
+ | MUX (256 sigs -> sum -> effect) | 23.00 ms | 35.00 ms | **+34.3% faster** | 0 KB / 781 KB (100% less) |
572
+ | SELECTIVE DAG (set churn) | 2012 ms | 2493 ms | **+19.3% faster** | 7.7 MB / 77.8 MB (10.0x) |
573
+ | DYNAMIC DAG (FAN=6, read flips) | 3700 ms | 4448 ms | **+16.8% faster** | 3.3 MB / 59.8 MB (18.3x) |
574
+ | BROADCAST (1 -> 1000 effects) | 433.51 ms | 478.35 ms | **+9.4% faster** | ~0 KB / ~0 KB (both zero) |
575
+ | KAIROS (1 -> 1000 computeds) | 502.01 ms | 433.19 ms | -15.9% | 23 KB / 802 KB (34.3x) |
576
+ | DEEP CHAIN (256-deep -> effect) | 170.10 ms | 98.57 ms | **-72.6%** | 0.5 KB / 1062 KB (>2000x) |
577
+
578
+ lite-signal's time wins on the 1.8.0 M4 Pro sweep cluster on the allocation-heavy
579
+ dynamic shapes (object pool allocates near-nothing; alien churns the nursery), plus
580
+ MUX fan-in aggregation and BROADCAST -- the patterns that dominate live UI under
581
+ input churn. **Speed wins vs alien: 4/6** (MUX, SELECTIVE DAG, DYNAMIC DAG, BROADCAST).
582
+ The four wins hold within noise of the 1.7.0-preview M4 Pro sweep -- **BROADCAST
583
+ recovered** from +6.2% to +9.4%; **KAIROS widened** slightly from -11.7% to -15.9%,
584
+ consistent with 1000 shared-source computeds having almost nothing to retrack. **DEEP
585
+ CHAIN -72.6%** is the same architectural weak spot the honest framing has always
586
+ named. On allocation, lite wins 5/6 shapes and is one to four orders of magnitude
587
+ below alien on every shape where GC pressure exists at all; the sixth is a shared-
588
+ zero on BROADCAST.
589
+
590
+ **The differentiated position is ALLOCATION, not raw propagation speed** -- competitive-
591
+ to-winning throughput with dramatically lower GC pressure, not "fastest dynamic-graph
592
+ engine". That headline reproduces across hosts, sweeps, and third-party version bumps
593
+ because the object pool is the mechanism, not a tuning knob.
594
+
595
+ Mirror sweep (`bench/rb.txt`, Andrii's canonical adapter verbatim, isolated-per-row,
596
+ 10 reps, lite vs alien only on the same M4 Pro host) reproduces the same picture
597
+ across all 47 shapes: lite runs parity-to-behind alien on throughput, wins outright
598
+ on **4/47**: `1000x5 - 25 sources (wide dense)` +12.0%,
599
+ `manySourcesIntoOneComputedEffectWithDirect` +31.1%, `manySourcesIntoOneComputedEffect`
600
+ +29.5%, and `molBench` +0.3%. Weak on the deep/layered-burst family. Every row carries
601
+ a `#STAMP` and the counters (`nodesRecomputed` / `edgesTraversed` / `sinkReads`) match
602
+ Andrii's published suite exactly, so a lite-vs-alien delta here is identical work,
603
+ not DCE. Retracking verified correct by `retracking.difftest.mjs` (20,000 direct +
604
+ 10,000 batched writes, 0 disagreements vs published 1.1.5).
605
+
606
+ **Andrii Volynets js-reactivity-benchmark position: 3rd of 15** (up from 4th on every
607
+ prior sweep) with geomean **95.4 ms** (raw log `bench/AndriiVolynetsReactiveBench.log`).
608
+ Behind alien-signals (77.5), reflex (89.7). Ahead of @reactively (136.0, lite 1.43x
609
+ faster), Preact Signals (148.8, ~56%), uSignal (195.4), $mol_wire (206.5),
610
+ @amadeus-it-group/tans (210.4), @vue/reactivity (229.4, 2.4x), Oby (242.5), Signia
611
+ (307.0, 3.2x), MobX (388.3, 4.1x), @solidjs/signals (420.6, 4.4x), s-js (480.1),
612
+ SolidJS (733.5, 7.7x). **20 outright wins** (was 3 on 1.3.0 log, 4 on 1.7.0-preview):
613
+ the eight canonical propagation shapes (avoidablePropagation, broadPropagation,
614
+ deepPropagation, diamond, mux, repeatedObservers, triangle, unstable), all four wide
615
+ fan-in / fan-out shapes (manyEffectsFromOneSource, manySourcesIntoOneComputedEffect,
616
+ manySourcesIntoOneComputedEffectWithDirect, manySourcesIntoOneDirectEffect), molBench,
617
+ and seven of the rectangular / layered DAG shapes (64x6, 24x8, 120x7, 40x10, both
618
+ `256->512x32 layered-dag` variants, and 10x10 dynamic component). Top-3 count: 29/47
619
+ (was 21/47 on 1.3.0). The dramatic wins jump is driven by the same engine bytes across
620
+ every propagation function except `executeEffect`, which is where the 1.8.0 effect-
621
+ cleanup-return check landed. lite-signal is the only object-pooled, zero-GC engine in
622
+ the field.
570
623
 
571
624
  Retained heap after forced GC: typically negative for all libs (V8 compacts).
572
- The one exception: lite-signal shows ~+71 KB retained on KAIROS, which is the
625
+ The one exception: lite-signal shows ~+23 KB retained on KAIROS, which is the
573
626
  pre-allocated pool holding the live 1002-node graph in steady state. This is
574
627
  the design: the pool IS the working memory. Not a leak.
575
628
 
@@ -663,7 +716,7 @@ function dumpOwnerTree(handle, depth = 0) {
663
716
  - `bench/benchmark.mjs` -- anti-DCE throughput harness (ops/s; results.txt).
664
717
  - `bench/benchmarkReactive.mjs` -- cross-framework reactivity suite vs alien-signals, preact, vue-reactivity, solid (resultsReactive.txt).
665
718
  - `bench/dispose-recycle.mjs` -- 1.2.2 targeted microbench: create/dispose/recreate cycle (the free-list invariant audit target).
666
- - `bench/torture/` -- crash-detection soaks: `graph-fuzzer`, `scheduler-bench`, `torture-soak`. Exit 0 iff zero errors AND post-teardown pool clean.
719
+ - `bench/torture/` -- the complete **17-scenario superset (14 semantic + 3 soak)** behind one runner (`run.mjs`), two groups, forward-compatible through 1.9. Every scenario feature-detects and SKIPS cleanly below the engine version that introduces its feature, so the whole set is safe on the 1.8.0 engine and stays green from 1.4.x forward. `semantic` (deterministic, fast, asserts on MEANING; CI on every commit) -- the **13 that execute on 1.8.0**: `oracle-fuzzer` (every computed vs an independent uncached reference, 400 seeds x 120 ops), `glitch-hunter` (glitch freedom + exact wakeups), `work-accounting` (minimum body-execution counts over 10 topologies), `op-accounting` (structural work from the `onGraphMutation` opcode lane, not wall-clock), `introspect-torture` (1.6.0: read-only introspection surface -- `describe`/`nodeId`/`hasObservers`/`isTracking`/`forEach*`/`ownerOf`/`observeObservers` -- walk-agreement + the ABA gen-stamp guard), `concurrent-storm` (8 reentrancy / flush-ordering contracts), `scheduler-storm` (gen-bound thunk ABA guard, FLAG_QUEUED coalescing, throwing-scheduler containment), `box-torture` (1.5.0: signalBox/computedBox interop -- the oracle differential fuzz with every node realised as callable OR box), `scope-torture` (1.6.0: `createScope` adoption + disposal-crash fuzz + `runWithOwner` re-attachment), `async-torture` (watch / when / whenAsync contracts + a 300-seed projection-guard storm), `capacity-torture` (the fail-closed pool boundary), `flush-torture` (1.7.0: the three `flushStrategy` modes by cross-strategy differential + per-strategy scheduling + `.subscribe()`), `cleanup-return-torture` (1.8.0: an effect's returned cleanup -- timing at re-run/dispose, compose order appended after `onCleanup`, self-dispose guard, computed exclusion; 400 seeds); plus **1 that skips cleanly** as a later-version feature: `dispose-torture` (1.9.0 `Symbol.dispose`). `soak` (wall-clock bound, asserts on RESOURCES; nightly): `graph-fuzzer`, `scheduler-bench`, `torture-soak` -- exit 0 iff zero errors AND post-teardown pool at or below its leaf-only floor AND the JIT sink advanced. Runner spawns each scenario as a child process (several assert on global pool accounting) and passes `--expose-gc` unconditionally. Scripts: `npm run torture`, `torture:semantic`, `torture:soak`.
667
720
  - `bench/run-all.sh` + `bench/aggregate.mjs` -- cold-process-per-engine protocol + per-scenario aggregation.
668
721
  - `harness/run.mjs` -- dispatcher for the run-on-demand probes (smoke, field, dispose, churn, owner, creation, perf, burst, pull, toe, all).
669
722
  - `harness/smoke.mjs` -- 1.7 flushStrategy semantics (eager/sab/manual) + `flush()`, and the 1.8 effect-cleanup-return contract (fires before re-run + on dispose, composes with onCleanup in call order, non-function returns ignored, computed-returning-a-function still yields the VALUE). ASSERTS, so it fails loudly on a regression. First in `harness:all` and `verify`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zakkster/lite-signal",
3
- "version": "1.8.0-alpha.3",
3
+ "version": "1.8.0-alpha.5",
4
4
  "description": "Zero-GC reactive graph. Monomorphic object pool, versioned push-pull propagation, 32-bit modular versioning. Built for hot paths and long-running processes.",
5
5
  "author": "Zahary Shinikchiev <shinikchiev@yahoo.com>",
6
6
  "license": "MIT",
@@ -45,7 +45,10 @@
45
45
  "profile:burst": "node --expose-gc harness/burst-dag.mjs ./Signal.js",
46
46
  "profile:pull": "node --expose-gc harness/pull-stress.mjs",
47
47
  "gate": "node harness/VersionMatrix/pre-publish.mjs",
48
- "verify": "npm test && npm run harness:smoke && npm run bench"
48
+ "verify": "npm test && npm run harness:smoke && npm run bench",
49
+ "torture": "node bench/torture/run.mjs",
50
+ "torture:semantic": "node bench/torture/run.mjs --group semantic",
51
+ "torture:soak": "node bench/torture/run.mjs --group soak"
49
52
  },
50
53
  "keywords": [
51
54
  "signal",