"매 unchanged 매 recompute X". Incremental computation 매 prior result 의 reuse — 매 input change 만 propagate. 매 2026 rust-analyzer (Salsa), Bazel, Buck2, Turbopack 매 standard. 매 trade-off: 매 memory vs recompute time.
매 핵심
매 mechanism 분류
Memoization: 매 (input → output) cache. 매 pure function 필수.
Demand-Driven: 매 query-based; pull 시 dependency graph 추적 (Salsa, Adapton).
Change-Driven: 매 push; input change → invalidate downstream (React reactivity).
Self-Adjusting Computation: 매 Acar — formal foundation, dynamic dependency graph.
매 invalidation strategy
Hash-based: 매 input fingerprint compare (Bazel digest).
fromfunctoolsimportlru_cache@lru_cache(maxsize=10_000)defexpensive(x:int,y:int)->int:returnslow_compute(x,y)# 매 hash(args) → cached result; LRU evict oldest
3. React useMemo (Reference Equality)
constexpensive=useMemo(()=>{returnitems.filter(i=>i.active).sort();},[items]);// 매 items reference unchanged → skip
4. Bazel Action Cache
# WORKSPACE — 매 each action keyed by:# hash(inputs) + hash(command) + hash(env)# Output stored in CAS (content-addressable storage)# Remote cache — 매 distributed reuse across team
5. Self-Adjusting Computation (OCaml-style)
letm=Mod.create()leta=Var.createm1letb=Var.createm2letsum=Mod.bindm(fun()->Var.reada+Var.readb)Var.writea10(* sum auto-recomputes only its branch *)
6. Incremental Diff (Patch Generation)
functiondiff<T>(old: T[],new_: T[]):Patch[]{// 매 Myers diff — O(ND) — minimal edit script
// 매 used by git, react reconciler, immer
}
7. Signal-Based Reactivity (SolidJS)
const[count,setCount]=createSignal(0);constdoubled=createMemo(()=>count()*2);// 매 fine-grained — only doubled recomputes when count changes
// 매 NO virtual DOM diff
매 결정 기준
상황
Approach
Pure function repeat
lru_cache / memoize
Compiler / IDE
Salsa, Adapton
UI reactivity
Signals (Solid) > Virtual DOM (React)
Build system
Bazel / Buck2 / Turbo
Stream pipeline
Materialize, ksqlDB
기본값: 매 pure function memoize, 매 large pipeline 매 Salsa pattern.
언제: 매 build pipeline design, 매 query system architecture, 매 cache invalidation logic.
언제 X: 매 input always changes (no reuse benefit), 매 memory-constrained embedded.
❌ 안티패턴
Cache invalidation bug: 매 stale result return. 매 dependency graph correctness 매 critical.
Unbounded memo: 매 OOM. 매 LRU/TTL bound 필수.
Impure function memo: 매 random()/now() 매 cache 시 incorrect.
Over-fine-grained: 매 cache overhead > recompute cost.