ReactiveEngine v3.0 and Intrusive Lists in JS: How Dropping Set and Map Speeds Up ReactivityArticle · digest for November 19
ReactiveEngine v3.0 and Intrusive Lists in JS: How Dropping Set and Map Speeds Up Reactivity
Article4 sections≈ 8 min

ReactiveEngine v3.0 and Intrusive Lists in JS: How Dropping Set and Map Speeds Up Reactivity

You write a regular computed with an if/else branch—say, a view switching between two tabs. It looks harmless. Yet in a naive reactivity engine, that's right where a bottleneck hides. As long as the dependency graph stays static, Set and Map fly. Once subscriptions start flipping on every tick, though, the engine spends its time hashing keys, deleting entries, and creating garbage for the GC.

That's the idea behind @pravosleva/reactive-engine v3.0.0 (latest patch 3.0.2 from November 18, 2026; source on GitHub). In a Habr breakdown, author @mad-den was surprised by the maintainer's approach: the public API stayed fully backward-compatible (even though v1 was "in a coma"), while the entire core was rewritten from scratch. Instead of Set and Map, it uses intrusive doubly-linked lists and an object pool—a classic Linux kernel technique adapted to plain JS in just 7.31 KB gzip.

Why Set and Map Stall When Subscriptions Flip

Signals are built on a reactive graph: signals (signal), computations (computed), and effects (effect) are nodes, while "who depends on whom" relationships are edges. The straightforward implementation stores a Set of subscribers on each signal and a Set of read signals on each computed.

When an if/else branch inside a computed changes, the engine unsubscribes from old dependencies and collects new ones:

// Naive dependency tracking using standard Sets
function recompute(node, computeFn) {
  for (const dep of node.deps) {
    // Hash lookup across Set buckets on every unsubscribe
    dep.subs.delete(node)
  }
  node.deps.clear()
  return computeFn()
}

With ten nodes, you won't notice. In a hot loop where branches flip thousands of times, every delete and add on a Set hashes values, pokes internal tables, and allocates temporary objects. GC pressure climbs, and V8 (Scavenger and Mark-Sweep) starts pausing right in the middle of updates. That's why modern signal engines—alien-signals, Vue 3.5+, Preact Signals—moved away from Set toward intrusive lists inspired by struct list_head in the Linux kernel.

Intrusive Lists and LinkPool Under the Hood

In a normal collection, the container allocates a wrapper node around your data. In an intrusive doubly-linked list, the prev and next pointers live right inside the link object itself—no external buckets or hashing.

In ReactiveEngine's src/core/core.ts, every graph edge is a NodeLink. It participates in two lists at once: the signal's subscribers (nextSubscriber / prevSubscriber) and the consumer's dependencies (nextDependency / prevDependency). Unsubscribing runs in O(1): instead of searching a Set, the engine simply rewires a couple of neighbor pointers.

Next comes the object pool (LinkPool). When a link breaks, NodeLink doesn't go to the garbage collector. Its clear() method resets fields and places the object into an array pool for immediate reuse:

// From src/core/core.ts (@pravosleva/reactive-engine v3.0.x)
export class NodeLink {
  public source: ReactiveNode | null = null
  public target: ReactiveNode | null = null
  public nextSubscriber: NodeLink | null = null
  public prevSubscriber: NodeLink | null = null
  public nextDependency: NodeLink | null = null
  public prevDependency: NodeLink | null = null
  public version: number = 0

  public clear(): void {
    this.source = null
    this.target = null
    this.nextSubscriber = null
    this.prevSubscriber = null
    this.nextDependency = null
    this.prevDependency = null
    this.version = 0
  }
}

export class LinkPool {
  private static pool: NodeLink[] = []
  private static size = 0
  // Hard cap of 2048 (~64–96 KB in V8 Old Space)
  private static maxPoolSize = 2048

  public static acquire(
    source: ReactiveNode,
    target: ReactiveNode
  ): NodeLink {
    if (this.size > 0) {
      this.size--
      const link = this.pool[this.size]
      this.pool[this.size] = null as unknown as NodeLink
      link.source = source
      link.target = target
      return link
    }
    const link = new NodeLink()
    link.source = source
    link.target = target
    return link
  }

  public static release(link: NodeLink): void {
    link.clear()
    if (this.size < this.maxPoolSize) {
      this.pool[this.size] = link
      this.size++
    }
  }
}

The smart detail here is the hard cap maxPoolSize = 2048 (around 64–96 KB in V8's Old Space). If a one-off spike swells the graph, extra links won't stay pinned in memory forever—V8 Scavenger reclaims them. Meanwhile, steady hot loops recycle the exact same objects with zero new allocations.

What Benchmarks and Graph Correctness Tests Show

In transitive-bullshit/js-reactivity-benchmark, engines are scored by geometric mean relative to the fastest entrant (1.00× is the leader; lower is better).

Enginekairomoldynamiccellxs
alien-signals (3.2.1)1.00×1.03×1.00×1.10×1.02×
Preact Signals (1.14.4)1.19×1.03×1.52×1.32×1.37×
@pravosleva/reactive-engine (3.0.0)1.69×1.06×1.30×1.22×3.69×
@vue/reactivity (3.5.44)1.89×1.00×2.03×1.51×1.54×
@angular/signals (22.1.7)2.72×1.05×3.32×1.63×3.29×
SolidJS (1.9.17)3.78×1.27×4.39×1.63×3.89×
Svelte v5 (5.57.0)3.92×1.03×2.80×111.18×3.40×
MobX (7.0.6)4.41×1.28×4.37×2.54×4.90×

The picture is honest. In dynamic workloads, the new core comfortably beats both Vue and Angular Signals: dynamic constantly rewires subscriptions, kairo tests wide fan-out and if/else switching, and mol runs ten thousand iterations with conditional dependencies that punish any GC pause. On the s suite, however, the overall score is noticeably weaker, trailing both alien-signals and Vue (though it pulls ahead on the targeted updateComputations1000to1 test).

In heavy dynamic runs, the gap over major frameworks stands out clearly:

Heavy dynamic benchmark runtime (lower is better)

On the dense wide dense grid and broadPropagation, swapping hash tables for pointer rewiring and zero-allocation pooling buys substantial headroom.

In the johnsoncodehk/reactive-framework-test-suite correctness suite, the engine passed 159 out of 161 checks (98.8%)—matching @vue/reactivity 3.5.45, which fails two different cases (#123 and #141). Both ReactiveEngine failures (#212 and #213) involve Inner Write—writing back into a root signal from inside an effect that depends on it. In practice that's an anti-pattern, and both the official TC39 Signals polyfill (signal-polyfill) and @solidjs/signals trip on the exact same two cases.

Angular-Style Services and DI—Without Angular

Why did the Habr review compare it to @angular/core? Because of how it structures code. ReactiveEngine organizes business logic around service classes (AbstractService) and Dependency Injection (DI)—instead of instantiating services inside components, you pull them from a shared container via engine.inject(...).

import { AbstractService } from '@pravosleva/reactive-engine'
import { ReactiveEngine } from '@pravosleva/reactive-engine/react'

// Logic lives in a plain class with no React dependency
class CounterService extends AbstractService {
  public counter = this.engine.signal<number>(0, 'counter:value')

  public inc = () => {
    this.counter.value += 1
  }
}

const engine = new ReactiveEngine()

export const CounterWidget = () => {
  const logic = engine.inject(CounterService)
  // Uses useSyncExternalStore under the hood to prevent UI tearing
  const counter = engine.use(logic.counter)

  return (
    <button onClick={logic.inc}>
      Count: {counter}
    </button>
  )
}

The package is MIT-licensed with zero external dependencies and ships adapters for React (^18.0.0 || ^19.2.0), Vue (>=3.2.0), and Angular (>=16.0.0). Its Russian documentation even includes a patterns section walking through common tasks.

Still, be realistic about maturity. Despite the clean core and test coverage, the community around the repo is tiny (0 GitHub stars at the time of review, meaning a bus factor of one). If your app already lives inside Vue 3 or Angular, built-in reactivity is almost always simpler to maintain. If you want clean DI services with a fast signal graph in React or vanilla JS—or just want to study how intrusive lists work in JS—ReactiveEngine v3.0 is well worth exploring.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 6