A Faster FFI
summary
Claims a JIT-backed FFI pipeline that beats handwritten C: a Ruby-side translator generates C extensions with tiny trampolines that smuggle type metadata (magic marker FF50) so ZJIT emits an ffi_call instruction instead of a generic C dispatch. Prototype tools include Fjit, FFX, fiddle, fisk, jit-buffer and hacks; RJIT dependency is a drawback. Benchmarks: libffi ~15M iters/sec, native C ~45M, FFX-trampoline ~54M; a SQLite extension runs ~1.4× faster with ZJIT+FFX.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 1:15What is FFI
- 3:58Why use FFI
- 7:10How C extensions work
- 10:35Why FFI is slow
- 12:06Faster FFI with JIT
- 16:50Problems with Fjit
- 17:54ZJIT API and FFX
- 20:30Conveying type info
- 24:54ZJIT using metadata
- 27:12Benchmark results
- 28:24SQLite extension demo
- 30:34Ruby faster than C
- 31:00Future work








