Files
AILang/bench/baseline_cross_lang.json
T
Brummel 75f7fda788 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.
2026-05-09 01:21:15 +02:00

119 lines
2.7 KiB
JSON

{
"version": 1,
"captured": "2026-05-09",
"captured_via": "bench/cross_lang.py",
"note": "Cross-language wall-time baseline. Per-fixture: AILang at --alloc=rc, AILang at --alloc=bump, hand-C at clang -O2. Ratios rc/c and bump/c are the headline answer to CLAUDE.md's LLVM-linkable performance claim. The C reference uses malloc-and-leak to mirror AILang's implicit-mode RC; an explicit-mode + free() variant is queued.",
"fixtures": {
"bench_list_sum": {
"ail_rc_s": {
"baseline": 0.138906,
"tolerance_pct": 15
},
"ail_bump_s": {
"baseline": 0.050245,
"tolerance_pct": 15
},
"c_s": {
"baseline": 0.09749,
"tolerance_pct": 15
},
"rc_over_c": {
"baseline": 1.42483,
"tolerance_pct": 12
},
"bump_over_c": {
"baseline": 0.515393,
"tolerance_pct": 12
}
},
"bench_tree_walk": {
"ail_rc_s": {
"baseline": 0.100173,
"tolerance_pct": 15
},
"ail_bump_s": {
"baseline": 0.038673,
"tolerance_pct": 15
},
"c_s": {
"baseline": 0.036567,
"tolerance_pct": 15
},
"rc_over_c": {
"baseline": 2.739449,
"tolerance_pct": 12
},
"bump_over_c": {
"baseline": 1.057606,
"tolerance_pct": 12
}
},
"bench_compute_intsum": {
"ail_rc_s": {
"baseline": 0.000362,
"tolerance_pct": 15
},
"ail_bump_s": {
"baseline": 0.000371,
"tolerance_pct": 15
},
"c_s": {
"baseline": 0.000361,
"tolerance_pct": 15
},
"rc_over_c": {
"baseline": 1.002676,
"tolerance_pct": 12
},
"bump_over_c": {
"baseline": 1.028255,
"tolerance_pct": 12
}
},
"bench_compute_collatz": {
"ail_rc_s": {
"baseline": 0.057994,
"tolerance_pct": 15
},
"ail_bump_s": {
"baseline": 0.057159,
"tolerance_pct": 15
},
"c_s": {
"baseline": 0.05776,
"tolerance_pct": 15
},
"rc_over_c": {
"baseline": 1.00405,
"tolerance_pct": 12
},
"bump_over_c": {
"baseline": 0.989593,
"tolerance_pct": 12
}
},
"bench_list_sum_explicit": {
"ail_rc_s": {
"baseline": 0.150754,
"tolerance_pct": 15
},
"ail_bump_s": {
"baseline": 0.0495,
"tolerance_pct": 15
},
"c_s": {
"baseline": 0.119204,
"tolerance_pct": 15
},
"rc_over_c": {
"baseline": 1.264667,
"tolerance_pct": 12
},
"bump_over_c": {
"baseline": 0.415253,
"tolerance_pct": 12
}
}
}
}