Skip to content

Commit a678a59

Browse files
ahrzbclaude
authored andcommitted
chore(backlog): TASK-44 Done — M-cranelift merged (PR #27)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 78b95e4 commit a678a59

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

backlog/tasks/task-44 - Specializer-M-cranelift-codegen-backend-behind-the-same-interface.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
id: TASK-44
33
title: 'Specializer M-cranelift: codegen backend behind the same interface'
4-
status: In Progress
4+
status: Done
55
assignee: []
66
created_date: '2026-07-25 02:31'
7-
updated_date: '2026-07-26 06:05'
7+
updated_date: '2026-07-26 07:55'
88
labels: []
99
milestone: m-7
1010
dependencies:
@@ -23,10 +23,10 @@ Cranelift-jit backend for the imperative IR (design doc §7; cranelift-jit 0.126
2323

2424
## Acceptance Criteria
2525
<!-- AC:BEGIN -->
26-
- [ ] #1 Every v0-subset prepared query compiles under cranelift and agrees with the interpreter backend on the corpus and on randomized inputs
27-
- [ ] #2 Uncovered ops fall back to the interpreter backend rather than failing prepare
28-
- [ ] #3 p50/p99 ns/call reported at n in {1, 8, 64, 1024} against the interpreter control and the existing native + codegen engines
29-
- [ ] #4 mise gate-specializer green
26+
- [x] #1 Every v0-subset prepared query compiles under cranelift and agrees with the interpreter backend on the corpus and on randomized inputs
27+
- [x] #2 Uncovered ops fall back to the interpreter backend rather than failing prepare
28+
- [x] #3 p50/p99 ns/call reported at n in {1, 8, 64, 1024} against the interpreter control and the existing native + codegen engines
29+
- [x] #4 mise gate-specializer green
3030
<!-- AC:END -->
3131

3232
## Implementation Plan
@@ -38,3 +38,15 @@ Stretch plan (recorded 2026-07-26, design doc §7 + §10):
3838
3. Differential: gen.rs random-IR fuzz interpreter-vs-cranelift (same seeds, byte-identical outputs incl. NaN/-0.0/arena strings); corpus replay + duck_check suite through the cranelift backend; gate green.
3939
4. Bench per §10: baseline the boundary with a no-op f first, then p50/p99 ns/call at n in {1,8,64,1024}, interpreter as control, next to the existing native + codegen engines; committed as a script, numbers into the task.
4040
<!-- SECTION:PLAN:END -->
41+
42+
## Implementation Notes
43+
44+
<!-- SECTION:NOTES:BEGIN -->
45+
All four stretches landed in one session (commits 6fd137b/0362b37/222138c on claude/specializer-m-cranelift, PR #27). Backend shape: one JIT'd fn per program, called per row — extern "C" fn(*mut Cx) -> i64 (0 emit / 1 skip / 2 helper trap / 3+k term trap); Cx is repr(C), the generated code reads only trap_flag at offset 0 (checked after every fallible helper). Coverage-first: consts/float arith/int cmp/logic/select/itof/fabs inline in CLIF; everything nontrivial calls extern helpers delegating to the interpreter's own semantic fns (casemap, substr_window, duck_fcmp, DuckF64, arena) — backends cannot drift where they share code. Strings = (off,len) i64 pairs; IR blocks map 1:1 to CLIF blocks+params. CraneliftFn owns a compiled InterpFn (checks, statics, fallback). The 500-seed random-IR differential caught two real bugs pre-landing: load.opt and sload.opt must normalize payloads to type defaults under a false flag. DuckDBInferFn compiles cranelift-first with interpreter fallback (AC #2) + SPECIALIZER_FORCE_INTERP knob + .backend getter; the whole pytest suite (607 + corpus 53/625/0) now exercises the JIT. Bench (scripts/bench_specializer.py, §10 discipline): pydantic boundary dominates end-to-end — noop passthrough within ~20% of a full join; cranelift==interp through Python; both beat native/codegen ~1.5-2x at larger n. Raw compute isolation (backend_compute_bench, ignored test): cranelift 13.2 ns/row vs interp 37.6 ns/row = 2.8x — the JIT win is real and waiting behind the boundary (M-boundary's job). MILESTONE COMPLETE pending review; hard stop before M-boundary.
46+
<!-- SECTION:NOTES:END -->
47+
48+
## Final Summary
49+
50+
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
51+
M-cranelift delivered on claude/specializer-m-cranelift (PR #27): cranelift-jit 0.126 backend with FULL IR instruction coverage behind the same interface. Per-row extern "C" ABI; coverage-first op strategy (inline CLIF where trivially safe, shared-semantics extern helpers elsewhere — the two backends physically share the semantic functions). 500-seed interpreter-vs-cranelift random-IR differential green (caught two real payload-normalization bugs before landing); whole pytest suite incl. 678-case corpus replay (53 match / 625 clean-unsupported / 0 FAIL) runs on the JIT; interpreter fallback + force knob wired (AC #2). Bench per design doc §10 at n in {1,8,64,1024} vs interp control + native + codegen: boundary dominates end-to-end (JIT==interp through Python, both ~1.5-2x ahead of the existing engines); raw compute isolated: 13.2 vs 37.6 ns/row = 2.8x for cranelift. Gate green (cargo + 607 pytest, 12 xfail). Next milestone (M-boundary, generated row marshaller) is where the compute win becomes end-to-end visible.
52+
<!-- SECTION:FINAL_SUMMARY:END -->

0 commit comments

Comments
 (0)