What is O(k) Reactivity?
Most reactivity is O(n). O(k) reactivity isΒ O(k).
When you mutate one piece of state, the system should only do work proportional to how many things actually depend on itβββnot the size of the wholeΒ graph.
cost(mutation) = O(k) where k = |affected frontier|cost(mutation) = O(n) where n = |entire graph| β React, Zustand, most stores
Thatβs it.
O(n) vsΒ O(k)
O(n): You change price. The framework scans 3000 components/nodes to find who usesΒ price.
O(k): You change price. The runtime jumps directly to the 3 nodes that depend on price. It never sees the otherΒ 2997.
How
Inverted Dependency Indexing.
Instead of storing derived β sources, we maintain:
source path β set of dependent derived paths
On write toΒ p:
T(Ξp) = O(|Reach_D(p)| + C_eval)
We follow the frontier, we donβtΒ scan.
Why itΒ matters
Because explainability becomesΒ free.
InΒ .me:
me['!'].explain('order.total')// β { value, expr, inputs, dependsOn, recomputed, sourcePath }Returning the computation trace is a lookup over the indexβββnot a secondΒ pass.
Benchmark (3000 nodes, 300 mutations):
- baseline p95:Β 0.0122ms
- with explain() p95:Β 0.0189ms
- overhead: +0.007ms
Faithful trace for 7 microseconds because k <<Β n.
The formula
I = (path, ciphertext, T, A, C)k = |Reach_D(p)|cost = O(k)
Readability (A) is not topology (T). Capability (C) is not identity. And cost is notΒ size.
Go deeper
- Inverted Dependency Indexing: suign.github.io/InvertedIndex.html
- Equations: suign.github.io/Equations.html#ok-reactivity
- Benchmark: me vs React vsΒ Zustand
O(k) is not an optimization. Itβs a different complexity class.

What is O(k) Reactivity? was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.