Revert v0.5.424 β-memory cache — cluster regression confirmed
Two cluster runs of v0.5.424 (b9138673, 6ea91461) both showed a
~40-50% slowdown across all recipe sizes vs the v0.5.423 baseline:
size v0.5.423 v0.5.424 run1 v0.5.424 run2
4_ings 1.65s 2.63s 2.63s
16_ings 9.04s 11.88s 11.95s
40_ings 22.65s 33.58s 33.80s
This is the opposite of what local cProfile predicted (-12% cumtime
on test_benchmark_two_origins). The discrepancy reveals that the
local two_origins fixture isn't representative of cluster recipe
behaviour: in test, alphas are activated few times per recipe and
the cache hit rate is moot; on cluster combined_40 runs, the cache
overhead per call (dict.get + dict.set + tuple alloc for the (gen,
result) value) compounds across hundreds of thousands of activations
faster than evaluate() itself would.
Even combined_4 — which has very few related-alpha activations —
went 1.65s → 2.63s. The slowdown affects orchestration globally,
not just RelatedNodeAlpha. Possible mechanism: adding
self._source_eval_cache = {} to AlphaNode subclass __init__ creates
a per-instance dict on every alpha that's referenced on every
activate call (via the override's `self._source_eval_cache.get(...)`).
The instance attribute lookup on a subclass with frozen=False might
trigger a dict resize or other overhead at scale.
Tests stay green, CO2 invariant holds either way. The β-memory idea
itself is sound (proven by PerRelatedNodeAlpha._source_eval_cache);
this attempt to extend the same pattern to RelatedNodeAlpha and
CrossNodePropertyAlpha was net-negative on the dev cluster shape.
Reverts:
- 7797eb2f9 perf(rete): per-sweep eval cache on CrossNodePropertyAlpha
- 420f88d20 perf(rete): per-sweep eval cache on RelatedNodeAlpha (β-memory analog)
The branch perf/beta-discrimination is preserved on origin for
post-mortem reference. The Phase 0 falsifier (commit 99ded2911)
remains shipped as diagnostic infrastructure; it correctly measured
75.4% noop ratio but the noop short-circuit path turned out to be
cheaper than the cache-hit path on cluster.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>