panproto-jit
Compiles panproto expressions to native machine code via LLVM for faster data migration.
What it does
When you migrate data, field transforms run once per record. For a table with a million rows, even a simple expression like if x > threshold then x * rate else x gets evaluated a million times by the default tree-walking interpreter. The interpreter is convenient but carries overhead on every step: dispatch on expression variants, bounds checks, environment lookups.
This crate compiles panproto expressions to native code using LLVM JIT before the migration starts, then hands back a function pointer that runs at full CPU speed. Arithmetic operations lower to build_int_add and friends; conditionals lower to br i1; lambdas become closure structs with a function pointer; higher-order builtins like map and filter become loops over an array. The compilation mapping for every Expr variant is documented in the mapping module.
The actual JIT engine requires the inkwell-jit feature flag and a local LLVM installation. Without the feature, the crate still compiles cleanly and exports the mapping specification and error types, so you can depend on it unconditionally and gate the fast path with #[cfg(feature = "inkwell-jit")].
Quick example
API overview
| Export | What it does |
|---|---|
JitCompiler |
Owns the LLVM context; create once and reuse (inkwell-jit feature) |
CompiledExpr |
A compiled, callable function pointer for one expression (inkwell-jit feature) |
ExprMapping |
Documents how each Expr variant maps to LLVM IR constructs |
JitError |
Error variants: compilation failures, type mismatches, execution errors |