datalog: indexed dl-find-bindings + chain-15 differential (Phase 5c, 153/153)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 59s

dl-find-bindings now uses dl-fb-aux lits db subst i n (indexed
iteration via nth) instead of recursive (rest lits). Eliminates
O(N²) list-copy per body of length N. chain-15 saturation 25s
→ 16s; chain-25 finishes in 33s real (vs. timeout previously).

Bumped semi_naive tests to chain-10 differential + chain-15
semi-only count (was chain-5/chain-5). Blocker entry refreshed.
This commit is contained in:
2026-05-08 08:50:24 +00:00
parent de302fc236
commit 790c17dfc1
4 changed files with 32 additions and 20 deletions

View File

@@ -256,19 +256,27 @@ large graphs.
## Blockers
- **Saturation perf on long chains.** Resolved one bottleneck (hash-set
membership in `dl-add-fact!`) but `dl-saturate!` still spends
significant time per iteration on rule body joins — chain-15 takes
~25s real / 3s user under contention even after the membership fix.
Two follow-ups to consider: (a) avoid `(rest lits)` in
`dl-find-bindings`/`dl-fbs-aux` (uses indexed iteration like the
membership fix), (b) memoize the per-rule body shape so `(len lits)`
and accessor calls don't re-walk the list each step.
- **Saturation perf** improving but not free. Resolved hash-set
membership in `dl-add-fact!` and replaced recursive `(rest lits)` in
`dl-find-bindings` with indexed iteration. chain-15 drops from ~25s
to ~16s and chain-25 saturates in ~33s real / 11s user — most CPU
now in unification (assoc-based subst dict copies) and dict
lookups during walks. Future: a per-rule "compiled" body that
pre-resolves arg positions and intern variable indices, then
unification can use array slots instead of dict assoc.
## Progress log
_Newest first._
- 2026-05-08 — Phase 5c perf: indexed `dl-find-bindings`. Replaced
the recursive `(rest lits)` walk with `dl-fb-aux lits db subst i n`
using `nth lits i`. Eliminates O(N²) list-copy per body of length
N. chain-15 saturation 25s → 16s; chain-25 finishes in 33s real
(vs. timeout previously). Bumped semi_naive tests: differential
on chain-10, semi-only count on chain-15 (was chain-5/chain-5).
153/153.
- 2026-05-08 — Phase 10 syntactic demo. New `lib/datalog/demo.sx`
with three programs over rose-ash-shaped data: federation
(`mutual`, `reachable`, `foaf`), content recommendation