bench: 21'f — explicit-mode pair, full alloc+dec vs malloc+free

Closes the apples-to-apples gap from 21'e. Adds:
- examples/bench_list_sum_explicit.ailx — same algorithm and sizes
  as bench_list_sum, fully (borrow)/(own)/(drop-iterative)
  annotated so codegen emits proper inc/dec instrumentation.
- bench/reference/list_sum_explicit_free.c — same algorithm
  with explicit free() walking the chain after sum.

The full alloc+dec vs malloc+free comparison reveals two non-
trivial conclusions:

1. AILang's full RC pipeline is only 26% slower than glibc
   malloc+free on this workload (rc/c = 1.26x). The implicit-
   mode comparison's 1.42x was misleading — it counted neither
   pipeline's free path. The fair ratio is 1.26x, materially
   better than the previous read.

2. RC's dec is cheaper per cell than glibc free(). AILang
   dec-tax: ~3 ns/cell. C free-tax: ~5.5 ns/cell. Plausible
   cause: ailang_rc_dec operates on a known-shape cell with a
   fixed-offset refcount and a static per-type drop fn — no
   free-list bucketing, no header introspection, no global lock.

bump's advantage expresses fully: bench_list_sum_explicit.bump/c
= 0.42x means AILang at bump is 2.4x faster than C malloc+free.
Sets a useful upper bound on a slab/pool RC allocator's potential.

The 21'-family arc — bench-regression infrastructure — is now
substantively complete: 21'a (bench/check.py), 21'b (corpus
widening), 21'c (compile_check.py), 21'd (pure-compute fixtures
+ harness hardening), 21'e (cross-language hand-C), 21'f (explicit
apples-to-apples). 63 runtime metrics + 18 compile metrics + 25
cross-lang metrics under regression coverage. Any future iter
that regresses any axis beyond tolerance gets caught at the next
family close.

Remaining queue is back to substantive language work — Family 21
(typeclasses / polymorphic ADTs at runtime / pattern-binding
generalisation) is now an orchestrator-level fork that needs
direct user input.
This commit is contained in:
2026-05-09 01:21:15 +02:00
parent c897d2eef0
commit 75f7fda788
8 changed files with 369 additions and 25 deletions
+10
View File
@@ -54,6 +54,16 @@
"gc_rss_kb": { "baseline": 13624, "tolerance_pct": 15 },
"bump_rss_kb": { "baseline": 13860, "tolerance_pct": 15 },
"rc_rss_kb": { "baseline": 13880, "tolerance_pct": 15 }
},
"bench_list_sum_explicit": {
"gc_s": { "baseline": 0.139, "tolerance_pct": 10 },
"bump_s": { "baseline": 0.048, "tolerance_pct": 10 },
"rc_s": { "baseline": 0.152, "tolerance_pct": 10 },
"gc_over_bump": { "baseline": 2.89, "tolerance_pct": 8 },
"rc_over_bump": { "baseline": 3.14, "tolerance_pct": 8 },
"gc_rss_kb": { "baseline": 103772, "tolerance_pct": 5 },
"bump_rss_kb": { "baseline": 97636, "tolerance_pct": 5 },
"rc_rss_kb": { "baseline": 142424, "tolerance_pct": 8 }
}
},