
{"id":214676,"date":"2026-08-18T06:01:15","date_gmt":"2026-08-18T06:01:15","guid":{"rendered":"https:\/\/mycryptomania.com\/?p=214676"},"modified":"2026-08-18T06:01:15","modified_gmt":"2026-08-18T06:01:15","slug":"what-is-ok-reactivity","status":"publish","type":"post","link":"https:\/\/mycryptomania.com\/?p=214676","title":{"rendered":"What is O(k) Reactivity?"},"content":{"rendered":"<h4>Most reactivity is O(n). O(k) reactivity is\u00a0O(k).<\/h4>\n<p>When you mutate one piece of state, the system should only do work proportional to how many things <em>actually depend on it<\/em>\u200a\u2014\u200anot the size of the whole\u00a0graph.<\/p>\n<p>cost(mutation) = O(k)   where k = |affected frontier|cost(mutation) = O(n)   where n = |entire graph|  \u2190 React, Zustand, most stores<\/p>\n<p>That\u2019s it.<\/p>\n<p><a href=\"https:\/\/suign.github.io\/Equations.html\">The Equations<\/a><\/p>\n<h3>O(n) vs\u00a0O(k)<\/h3>\n<p>O(n): You change price. The framework scans 3000 components\/nodes to find who uses\u00a0price.<\/p>\n<p><strong>O(k)<\/strong>: You change price. The runtime jumps directly to the 3 nodes that depend on price. It never sees the other\u00a02997.<\/p>\n<h3>How<\/h3>\n<p><strong>Inverted Dependency Indexing.<\/strong><\/p>\n<p><a href=\"https:\/\/suign.github.io\/InvertedIndex.html\">Inverted Dependency Indexing<\/a><\/p>\n<p>Instead of storing derived \u2192 sources, we maintain:<\/p>\n<p>source path \u2192 set of dependent derived paths<\/p>\n<p>On write to\u00a0p:<\/p>\n<p>T(\u0394p) = O(|Reach_D(p)| + C_eval)<\/p>\n<p>We follow the frontier, we don\u2019t\u00a0scan.<\/p>\n<h3>Why it\u00a0matters<\/h3>\n<p>Because explainability becomes\u00a0free.<\/p>\n<p>In\u00a0.me:<\/p>\n<p>me[&#8216;!&#8217;].explain(&#8216;order.total&#8217;)\/\/ \u2192 { value, expr, inputs, dependsOn, recomputed, sourcePath }<\/p>\n<p>Returning the computation trace is a lookup over the index\u200a\u2014\u200anot a second\u00a0pass.<\/p>\n<p>Benchmark (3000 nodes, 300 mutations):<\/p>\n<p>baseline p95:\u00a00.0122mswith explain() p95:\u00a00.0189msoverhead: +0.007ms<\/p>\n<p>Faithful trace for 7 microseconds because k &lt;&lt;\u00a0n.<\/p>\n<h3>The formula<\/h3>\n<p>I = (path, ciphertext, T, A, C)k = |Reach_D(p)|cost = O(k)<\/p>\n<p>Readability (A) is not topology (T). Capability (C) is not identity. And cost is not\u00a0size.<\/p>\n<h3>Go deeper<\/h3>\n<p>Inverted Dependency Indexing: <a href=\"https:\/\/l.meta.ai\/?u=https%3A%2F%2Fsuign.github.io%2FInvertedIndex.html&amp;h=AUCux5J0x49BmYnWrprqMO1pI-CEp1esLf7JEZQj_O7-ZNK-hDS52GI5GOFfVD8WW0wFCWlL8rmWGzJwAwgViLNa3Svgx4U-50ZOp8ngW_e_UYEEWGOwizydUEd1YFLr6TPsjghyJoSfeDLxjrXsEKmFNJZ6gLqwO10\">suign.github.io\/InvertedIndex.html<\/a>Equations: <a href=\"https:\/\/l.meta.ai\/?u=https%3A%2F%2Fsuign.github.io%2FEquations.html%23ok-reactivity&amp;h=AUCux5J0x49BmYnWrprqMO1pI-CEp1esLf7JEZQj_O7-ZNK-hDS52GI5GOFfVD8WW0wFCWlL8rmWGzJwAwgViLNa3Svgx4U-50ZOp8ngW_e_UYEEWGOwizydUEd1YFLr6TPsjghyJoSfeDLxjrXsEKmFNJZ6gLqwO10\">suign.github.io\/Equations.html#ok-reactivity<\/a>Benchmark: <a href=\"https:\/\/l.meta.ai\/?u=https%3A%2F%2Fdev.to%2Fsuign%2Fme-is-dramatically-faster-than-react-and-zustand-here-are-the-numbers-1o9&amp;h=AUCux5J0x49BmYnWrprqMO1pI-CEp1esLf7JEZQj_O7-ZNK-hDS52GI5GOFfVD8WW0wFCWlL8rmWGzJwAwgViLNa3Svgx4U-50ZOp8ngW_e_UYEEWGOwizydUEd1YFLr6TPsjghyJoSfeDLxjrXsEKmFNJZ6gLqwO10\">me vs React vs\u00a0Zustand<\/a><\/p>\n<p>O(k) is not an optimization. It\u2019s a different complexity class.<\/p>\n<p>What is\u00a0O(K)?<\/p>\n<p><a href=\"https:\/\/medium.com\/coinmonks\/what-is-o-k-reactivity-f777318509c8\">What is O(k) Reactivity?<\/a> was originally published in <a href=\"https:\/\/medium.com\/coinmonks\">Coinmonks<\/a> on Medium, where people are continuing the conversation by highlighting and responding to this story.<\/p>","protected":false},"excerpt":{"rendered":"<p>Most reactivity is O(n). O(k) reactivity is\u00a0O(k). When you mutate one piece of state, the system should only do work proportional to how many things actually depend on it\u200a\u2014\u200anot the size of the whole\u00a0graph. cost(mutation) = O(k) where k = |affected frontier|cost(mutation) = O(n) where n = |entire graph| \u2190 React, Zustand, most stores That\u2019s [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":214677,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-214676","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-interesting"],"_links":{"self":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts\/214676"}],"collection":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=214676"}],"version-history":[{"count":0,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts\/214676\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/media\/214677"}],"wp:attachment":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=214676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=214676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=214676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}