lumbda
A Lisp/Scheme-derived, just-in-time lambda language. Four independent implementation tiers with MOAD defect isolation. Native binaries, browser WebAssembly, and portable state migration across UNIX systems.
Feedback is all you need: continuations within a process, portals across processes, S-expressions across implementations, sockets across machines, bend across accelerators.
russell@unturf, TimeHexOn, fox, Zoë Trout
lumbda.com · uncloseai.com · permacomputer.com
Source: git.unturf.com/engineering/unturf/lumbda
Second Edition (Version 2) — December 2026 · Reference Commit 5cb8cd7
Abstract
License: AGPL-3.0-only · This implementation, its bytecode VMs, & all associated code carry the GNU Affero General Public License v3.0 (only). You may use, modify, & distribute under those terms. No proprietary relicensing exists.
Lumbda is a Lisp/Scheme-derived language designed around one primitive and one discipline: feedback (a function that receives its own continuation composes every control-flow pattern) and MOAD defect isolation (every implementation audited against the canonical Mother-of-all-Defects patterns, with every defect confined to its own implementation tier rather than propagating through shared infrastructure — see §10). One primitive becomes universal when a function receives its own continuation: a continuation lets a program loop, branch, yield, checkpoint, resume, and migrate. Extending feedback across time (portals), across implementations (source-as-wire-format), across machines (TCP sockets), and across accelerators (bend) recovers the full scope of computation without introducing disjoint control-flow silos.
Lumbda ships in four independent implementation tiers — each built from first principles, each MOAD-isolated, each executing the same portable R7RS-small Scheme source and exchanging the same S-expression wire format:
Tier 1 — Python (lumbda.py) — 7,004 lines in one file: tree-walking interpreter plus flat-slot bytecode VM with shared operand stack, fused superinstructions, full multi-shot first-class continuations, exact rationals, and JSON/S-expression portals (1.7×–6.1× faster in v2; 577/577 tests PASS).
Tier 2 — C + x86-64 JIT (c/lumbda) — 514 KB native binary (plus 644 KB Emscripten WASM): tree-walker, hybrid stack-slot + upvalue bytecode VM (--fast, 13.9 KB L1-hot vm_run_loop, OP_SWITCH_LOCAL hash jump tables, 2-instruction NaN-box checks), and pattern-matched x86-64 native JIT (--jit), runtime-promoted arbitrary-precision BigInt, Boehm GC, and JSON/S-expression portals (5.36×–18.3× faster in v2; 93/93 C unit + 212/212 JIT tests PASS).
Tier 3 — Standalone Zero-Dependency Rust (rust/, NEW in v2) — 10,084 lines of pure Rust std with zero external crates, compiling one bytecode VM + arbitrary-precision BigInt + embedded stdlib.lsp to both a 1.1 MB native CLI/REPL binary and a 437 KB (160 KB gzipped) wasm32-unknown-unknown browser module (46/46 unit + 12/12 cross-tier integration tests PASS).
Tier 4 — Pure x86-64 Assembly (asm/lumbda.s) — 11,786 lines of GNU assembler (GAS, AT&T syntax), zero libc, raw Linux syscalls, O(1) sym->global_val and 1-byte sf_id dispatch tables, 26 zero-cons tagged-fixnum fast paths, and epoch-guarded in-place self-TCO frame reuse (5.9×–37.6× faster in v2; 549/549 tests PASS). Ships in three additive flavors — asm/lumbda (88 KB bump-only), asm/lumbda-gc (98 KB mark-sweep + meta-GC arena), and asm/lumbda-full (100 KB CL-compat + macros + embedded prelude) — alongside a 30 KB hand-written WebAssembly Text (wasm/asm/lumbda.wat) browser runtime.
All four tiers run live in any modern browser on lumbda.com Playground and REPL in "all four (race)" mode (Pyodide, Emscripten C, Rust wasm32, and hand-written WAT), verifying byte-identical output side by side.
Head-to-head performance (commit 5cb8cd7, Intel Core i5-8350U, 6-benchmark total): C --jit leads overall at 170.7 ms, followed by C --fast (218.6 ms), ASM gc (246.4 ms), ASM bump (296.0 ms), Rust (595.9 ms), C tree-walker (1,354.6 ms), Python --fast (9,644.7 ms), and Python tree-walker (23,718.3 ms). On mutual recursion (tak(15,10,6) at 3.6 ms) and hash-table workloads (hash(5k) at 11.5 ms), hand-written x86-64 assembly beats every other tier including the C JIT.
Interchange, networking, and verification. All tiers share Scheme source itself as a zero-schema portal wire format (16/16 producer × consumer matrix green, with bit-identical xoshiro256** PRNG state preserved across checkpoints). The same 90-line HTTP/1.0 server runs unmodified across tiers, with the bare-metal asm tier sustaining 2,994 req/s and streaming multi-megabyte static assets via zero-copy sendfile(2) at 474 req/s (1,208 MiB/s) in 4.2 MB peak RSS — within 2% of Caddy at 9× lower memory. The paper also presents the first machine-checked treatment of the EML universality theorem (eml(x, y) = exp(x) - ln(y)), proved formally in Lean 4 with zero sorry and verified cold in 46 ms by a self-hosted Scheme symbolic rewriter running inside Lumbda itself.
Feedback is the primitive. Continuations are its mechanism in time. Portals are its mechanism across time. S-expressions are its mechanism across implementations. Sockets are its mechanism across machines. bend is its mechanism across compute devices.
1. The Problem: Interpreters That Cannot Feed Back
Most language implementations treat control flow as a tree of special cases. if branches. while loops. return exits. try/catch unwinds. Each form carries its own implementation, its own edge cases, and its own interaction with the host call stack. When a program needs a pattern that crosses these boundaries — a generator that yields mid-loop, a coroutine that resumes from a checkpoint, or a computation that migrates between machines — the tower of special cases collapses.
The insight: every control-flow pattern is a special case of feedback. A loop feeds the tail position back to the head. A generator feeds a value out and a resumption point in. An exception feeds control to the nearest handler. A checkpoint feeds the entire machine state to storage. When the language exposes feedback as a first-class primitive, all of these patterns compose without special cases.
Scheme discovered this in 1975 with call-with-current-continuation. Yet most implementations compromise: they restrict continuations to escape-only, emulate them via setjmp/longjmp over the C stack, or require whole-program CPS transformation that obscures the source. Lumbda takes a direct path: an explicit frame stack that makes continuations an ordinary data structure rather than a stack-manipulation trick.
2. Multi-Tier Architecture & Execution Model
Lumbda v2 architecture: four independently engineered, MOAD-isolated implementation tiers (Python, C + x86-64 JIT, standalone zero-dependency Rust, and pure x86-64 assembly) plus their four corresponding browser WebAssembly runtimes, all sharing one R7RS-small source language and S-expression portal wire format.
2.1 Four Independent Tiers
Each implementation tier exists for a distinct engineering constituency and is intentionally isolated from the others so that an implementation defect in one tier cannot contaminate the rest:
Tier |
Source LOC |
Binary Footprint |
Execution Engines |
Memory & Numerics |
Verified Tests |
|---|---|---|---|---|---|
Python (lumbda.py) |
7,004 |
Script (Python 3 host) |
Tree-walker + flat-slot bytecode VM (--fast) |
Host GC; exact Fraction & arbitrary-precision int |
577/577 unit + 189 functional |
C + JIT (c/lumbda) |
~19k runtime C |
514 KB native; 644 KB Emscripten WASM |
Tree-walker + slot/upvalue bytecode VM (--fast) + x86-64 JIT (--jit) |
Boehm GC; 64-bit NaN-box + auto-promoted BigInt |
93/93 unit + 212/212 JIT + 189 functional |
Rust (rust/, NEW) |
10,084 pure std |
1.1 MB native; 437 KB (160 KB gz) wasm32 |
Stack-slot bytecode VM + compile-time macro expander |
Rc/RefCell; i64 + pure-std BigInt |
46/46 unit + 12/12 integration + demo parity |
x86-64 ASM (asm/lumbda.s) |
11,786 GAS AT&T |
88 KB bump; 98 KB GC; 100 KB full (zero libc) |
Direct evaluator + O(1) dispatch tables + 26 fixnum fast paths + in-place TCO |
Bump pointer or mark-sweep + meta-GC arena; 61-bit tagged fixnum |
549/549 across bump, GC, and full builds |
Browser WAT (wasm/asm/) |
5,684 WAT |
30 KB .wasm |
Hand-written WebAssembly Text evaluator |
Linear-memory allocator; tagged fixnums |
Node unit + cross-tier browser race |
All four native tiers support both file execution and interactive REPLs, and all four compile into the browser stack deployed at lumbda.com. The C tier also builds as a single Actually Portable Executable (c/lumbda.com via Cosmopolitan) and a Node CLI featuring a dynamic WebAssembly JIT (c/jit_wasm.c).
Python reference tier: source → reader → (tree-walker | flat-slot bytecode compiler → bytecode VM) → builtins / environments / full continuations / portal.
C tier: source → reader → (leval tree-walker | hybrid slot/upvalue compiler → 13.9 KB L1-hot vm_run_loop | pattern-matched x86-64 JIT via mmap(PROT_EXEC)).
x86-64 Assembly tier: entire runtime in one register file and raw Linux syscalls (zero libc). Heap bump pointer in %r15, global env in %r14, low-3-bit value tagging, O(1) sym->global_val and sf_id tables, and 26 zero-cons fixnum fast paths.
2.2 Type System & Numeric Tower
Core Scheme types remain minimal and consistent across every tier: interned Symbols (identity comparison), Pairs (cons cells), singleton Nil (), Closures / Compiled Procedures, Strings, Vectors, Bytevectors, Hash Tables, Ports, Error Objects, Macros (syntax-rules and define-macro), and first-class Continuations (Python and C VMs).
Each tier picks the value representation that matches its host machine:
Python: Native host objects with __slots__-compact Pair, Proc, CompiledProc, FullCont, and Env. Exact rationals use Python's Fraction ((/ 1 3) yields 1/3 verbatim).
C: 64-bit NaN-boxing encoding doubles, 48-bit signed fixnums, specials, and tagged pointers into a single uint64_t word with 2-instruction tag checks. Integer operations that overflow the fast fixnum range automatically promote to a Boehm-GC-managed arbitrary-precision BigInt (c/bignum.c), so expressions such as (expt 2 256) and (expt 2 1024) evaluate to exact, bit-identical values across Python, C, and Rust.
Rust: Compact tagged Value enum combining unboxed i64, f64, bool, char, and SymbolId(u32) with Rc-managed heap containers and a standalone pure-std arbitrary-precision BigInt (rust/src/bigint.rs). Arithmetic transparently promotes i64 to BigInt on overflow and demotes back when results fit in i64.
x86-64 Assembly: 64-bit words tagged in the low 3 bits (0 = 61-bit signed fixnum n << 3, 1 = pair, 2 = symbol, 3 = closure, 4 = builtin, 5 = special/port, 6 = string, 7 = container family). Tag-7 containers distinguish real vectors (length ≥ 0 at offset 0) from negative sentinels (-1 hash-table, -2 hash-set, -3 bytevector, -4 error object), keeping the entire type system within 3 tag bits.
2.3 Bytecode Representation & Explicit Frame Stack
The Python, C, and Rust VMs share the same fundamental execution architecture: compile Scheme expressions into compact bytecode arrays and execute them on an explicit frame stack rather than the host language's call stack.
Each bytecode compiler handles if, begin, and, or, when, unless, cond, case, define, set!, lambda, let, named-let, let*, letrec, letrec*, do, guard, for-each, call/cc, and function calls with tail-call optimization. Macros expand at compile time; dynamic forms such as runtime eval bridge back cleanly without restricting the language.
The instruction set pairs core control/environment opcodes (constants, lexical slot/upvalue/global loads and stores, jumps, OP_SWITCH_LOCAL jump tables, calls, tail calls, self-tail calls, closure construction, OP_CALL_CC) with specialized opcodes for hot primitives (+, -, *, +1, -1, comparisons, car, cdr, cons, null?, pair?, not, zero?, vector-ref, vector-set!, bytevector-u8-ref, hash-table-ref, hash-table-set!).
Because activation records live on an explicit VM frame stack rather than the host call stack:
Tail-call optimization replaces the active frame in place instead of pushing a new frame, so tail-recursive loops of arbitrary depth execute in constant memory.
Host recursion limits vanish: Python's default 1,000-frame recursion limit and fixed C/WASM stack depths do not constrain Scheme recursion; programs recurse tens of thousands of frames deep cleanly.
Continuations become ordinary data structures: capturing the current continuation requires copying the explicit frame stack and operand stack — no setjmp/longjmp, no stack-copying assembly hacks, and no host-stack corruption.
3. Continuations: Feedback as a Data Structure
With an explicit frame stack, capturing a continuation is simply snapshotting a data structure:
class FullCont:
frames # copied frame stack (instrs, ip, env/locals, stack_base)
stack # copied operand stack
ip # instruction pointer
instrs # instruction sequence (shared, immutable)
env # copied lexical environment chain (excluding global)
vm_id # unique identifier per VM invocation
When OP_CALL_CC executes:
Copy the lexical frame state (excluding the global environment, which holds bindings shared across the process).
Copy the active frame stack and operand stack.
Record the instruction pointer and immutable instruction sequence.
Wrap the snapshot in a FullCont object and invoke the receiver procedure with it.
When a continuation is invoked, the VM unwinds to the matching vm_id, restores the saved frames, stack, environment, and instruction pointer, pushes the passed value onto the restored stack, and resumes execution. Because the machine state is copied at capture time, multi-shot continuations work out of the box: each invocation restores an independent snapshot, enabling generators, coroutines, and backtracking search.
3.1 Generators from Continuations
A generator in Lumbda uses call/cc directly — no special generator syntax, no coroutine runtime:
(auto-compile! #t)
(define (make-gen thunk)
(let ((k #f) (done #f))
(lambda ()
(if done 'done
(call/cc (lambda (return)
(if k (k return)
(begin (thunk (lambda (val)
(call/cc (lambda (next)
(set! k next) (return val)))))
(set! done #t) (return 'done)))))))))
(define counter (make-gen (lambda (yield)
(let loop ((i 0)) (yield i) (loop (+ i 1))))))
(counter) ; => 0
(counter) ; => 1
(counter) ; => 2
3.2 Why "Feedback Is All You Need"
Every control-flow pattern reduces to a feedback operation:
Loop: tail-call feeds the function back to itself.
Generator: call/cc feeds a value out, saves a resumption point, and feeds control back in on the next call.
Exception: call/cc feeds control to a handler registered via guard / dynamic-wind.
Checkpoint: portal serializes the continuation and feeds machine state to storage.
Migration: portal deserializes on another machine and feeds the continuation back to a fresh VM.
Cross-implementation exchange: S-expression serialization feeds bindings across implementations sharing no binary layout.
Network & accelerator dispatch: sockets and (bend ...) feed requests to remote peers or GPUs and feed results back.
3.3 Five Scopes of Feedback
One abstraction spans five nested scopes:
Scope |
Mechanism |
Unit of Travel |
Implementation |
|---|---|---|---|
Within process |
call/cc, tail-call |
Live continuation |
Explicit frame stack (§2.3, §3) |
Across process |
Portal (JSON or binary) |
VM state + continuation |
Graph serializer / heap dump (§6) |
Across tier |
Source-as-interchange |
Bindings (as Scheme data) |
The reader (§6.1–§6.2) |
Across machine |
TCP sockets |
Request / response bytes |
Six tcp-* primitives (§9.2–§9.4) |
Across compute |
(bend ...) |
Call shipped to GPU worker |
Wire protocol + spawn-process-stdio (§9.7) |
Five scopes of feedback as concentric crossings: within-process continuations, across-process portals, across-tier source-as-data, across-machine sockets, and across-compute GPU dispatch.
4. Cross-Tier Compiler & VM Breakthroughs (v2)
Version 1 established semantic parity and portability across Python, C, and x86-64 assembly, but left substantial execution overhead on the table: dynamic environment-chain allocations per call, boxed per-frame operand stacks, linear special-form dispatch in assembly, and chained linked-list hash buckets.
Version 2 systematically applies classical Lisp compiler engineering — tracing directly to Guy Steele's 1978 *RABBIT* compiler (compile-time lexical analysis, self-tail loop lowering, inline primitive open-coding) and De Bruijn lexical indexing (replacing runtime symbol-chain walks with compile-time frame/slot coordinates) — independently across all four tiers. Every tier remains MOAD-isolated; no runtime shares code with another, yet all four converged on the same structural invariants.
4.1 C Bytecode VM & x86-64 JIT (c/vm.c, c/types.c, c/bignum.c)
The C tier achieves 5.36×–18.3× speedups over v1 while keeping 93/93 C unit tests and 212/212 JIT cross-tier tests green:
Hybrid stack-slot + upvalue bytecode compiler: Procedures whose lexical variables do not escape to dynamic eval compile with use_slots = true into fixed-offset stack slots (n_locals) and flat captured-variable upvalue descriptors (upval_specs), eliminating heap Env node allocation on every function entry. Procedures that require first-class dynamic environments fall back cleanly to heap Env frames within the same VM.
Zero-allocation self-tail named-let & for-each loops: Self-recursive tail loops lower to OP_SELF_TAIL_CALL with compile-time scope_depth tracking, overwriting parameter slots in place and jumping directly to loop entry with zero frame or environment allocation. Tight for-each traversals compile inline without closure-dispatch overhead.
OP_SWITCH_LOCAL open-addressed hash jump tables: Multi-way cond and case forms dispatching on a local variable compile into a power-of-two JumpTable of SwitchSlot entries hashed with ht_mix64, turning O(K) branch ladders into O(1) indirect jumps.
Open-addressed hash tables & 2-instruction NaN-box checks: c/types.c replaces chained buckets with cache-friendly open addressing, and hot VM tag tests reduce to two machine instructions on the NaN-boxed uint64_t word.
13.9 KB L1-instruction-cache-hot vm_run_loop: Cold paths (slow-path promotions, error formatting, dynamic fallbacks) are outlined so the threaded VM dispatch loop fits inside a 32 KB L1i cache at 13.9 KB. Bytecode instruction arrays and source maps are allocated via ul_malloc_atomic (pointer-free so Boehm GC never scans bytecode), with pointer-bearing constants gathered into a compact gc_roots array and a trailing OP_HALT sentinel eliminating per-instruction bounds checks.
x86-64 Native JIT (c/jit.c): Pattern-matched procedures compile directly to x86-64 machine code via mmap(PROT_EXEC) with native loop jumps, inline arithmetic/comparison fast paths, and automatic promotion to c/bignum.c on fixnum overflow.
4.2 x86-64 Assembly Fast Paths (asm/lumbda.s)
Version 1 speculated that assembly's ~3× gap behind C --fast stemmed from per-call env_define allocation and the absence of a bytecode layer. Version 2 eliminates those bottlenecks directly in hand-written x86-64 GNU assembly — delivering 5.9×–37.6× speedups across the benchmark suite while keeping 549/549 tests green across all three build flavors (88 KB bump, 98 KB GC, 100 KB full):
O(1) sym->global_val and 1-byte sf_id jump table: Every interned symbol struct now stores its global binding directly at offset 0 (SYM_OFF_VAL, initialized to VAL_UNBOUND) and a 1-byte special-form ID at offset 8 (SYM_OFF_SFID, 0 = normal, 1..18 = special form or macro). Global lookups drop from environment-chain pointer chases to a single indexed memory load; special-form recognition drops from sequential symbol comparisons to a single indirect jump table.
O(1) builtin jump table + 26 zero-cons inline fast paths: Builtin dispatch indexes directly through a jump table, and 26 hot primitives (arithmetic, comparisons, list/pair accessors, predicates, hash-table/vector ops) execute straight-line machine code directly on tagged 61-bit fixnums (n << 3), bypassing cons-list argument boxing and intermediate untag/retag cycles.
Epoch-guarded zero-allocation in-place self-TCO & named-let frame reuse: When a closure tail-calls itself (or loops via named-let) and no inner closure has captured the frame since entry (tracked by a lightweight escape epoch), the evaluator overwrites the existing binding cells in place and jumps back to the body with zero heap allocation.
As §5 shows, these changes shrink the gap to C --jit to under 1.5× overall and let asm/lumbda-gc beat C --jit outright on both tak(15,10,6) (3.6 ms vs 26.8 ms) and hash(5k) (11.5 ms vs 24.0 ms).
4.3 Python Bytecode VM (lumbda.py)
The single-file Python reference implementation applies the same flat-slot discipline while preserving 100% of its full multi-shot call/cc semantics, achieving 1.7×–6.1× speedups over v1 with 577/577 tests in tests.py passing:
Flat local slots & shared operand stack: Compiled frames store lexical locals in indexed Python lists instead of per-call Env dicts and share a single contiguous operand stack across frames rather than allocating a fresh list on every OP_CALL.
Inline tail-only named-let & for-each: Loop bindings update flat slots in place without frame push/pop or closure re-instantiation.
Fused superinstructions & zero-alloc hash keys: Frequent opcode pairs (local load + arithmetic/compare + conditional jump) fuse into single VM dispatches; hash-table primitives avoid wrapper tuple allocations on scalar keys.
Peephole optimizer, inline cache, and constant folding: Dead OP_VOID/OP_POP and redundant jumps are stripped with synchronized source maps; pure constant expressions fold at compile time; global lookups cache validated binding targets.
4.4 Standalone Zero-Dependency Rust + wasm32 Tier (rust/, NEW in v2)
Version 2 introduces a fourth independent implementation tier written in 10,084 lines of pure Rust std with an intentionally empty [dependencies] section in rust/Cargo.toml — zero external crates, zero build.rs code generation, offline-buildable out of the box.
The architecture spans clean, self-contained modules:
reader.rs (529 LOC): Full R7RS S-expression lexer/parser supporting rationals/floats/bignums, vectors, bytevectors, quasiquote, and datum comments.
value.rs (787 LOC) & bigint.rs (626 LOC): Compact tagged Value enum, symbol Interner (SymbolId(u32)), HashKey value equality, and a standalone arbitrary-precision BigInt engine with transparent i64 overflow promotion.
compiler.rs (1,970 LOC): Lexical slot/upvalue bytecode compiler with flat global index table (GlobalTable), compile-time macro expansion (syntax-rules with ellipsis matching + define-macro), specialized primitive opcodes, and tail-call lowering.
vm.rs (1,796 LOC) & builtins.rs (3,496 LOC): Explicit-frame stack VM with guard exception handlers, embedded stdlib.lsp (via include_str!), full file/string ports, xoshiro256** PRNG, hash tables, bytevectors, and bitwise operations.
main.rs (277 LOC) & wasm_api.rs (206 LOC): Dual entry points compiling the exact same VM to two deployment targets:
Native x86-64 CLI / REPL: 1.1 MB release binary (opt-level = 3, thin LTO, single codegen unit). Runs examples and playground demos byte-for-byte identically to the Python reference oracle.
Browser wasm32-unknown-unknown: 437 KB raw (160 KB gzipped, opt-level = "z", full LTO, panic = "abort", stripped). Exposes lumbda_init, lumbda_reset, and streaming evaluation with host imports for incremental output (emit_chunk), monotonic clock (host_now_ms), cooperative pause polling (pause_requested), and bend_call dispatch.
Verified by 46/46 unit tests and 12/12 cross-tier integration tests passing cleanly.
4.5 Browser WebAssembly Stack (lumbda.com Playground & REPL)
All four implementation tiers compile to WebAssembly and run client-side in any modern browser without a backend server, deployed live across lumbda.com Playground and interactive REPL:
Browser Tier |
Toolchain / Source |
Artifact Footprint |
Runtime Characteristics |
|---|---|---|---|
Python |
Pyodide 0.27.2 + lumbda.py |
CPython WASM + 260 KB source |
Full reference semantics, multi-shot call/cc, exact rationals |
C |
Emscripten emcc (c/*.c) |
644 KB .wasm + 103 KB glue |
Tree-walker + slot/upvalue bytecode VM + Boehm GC (Asyncify stack spill) |
Rust (NEW) |
rustc wasm32-unknown-unknown |
437 KB (160 KB gzipped) |
Zero external crates, BigInt, embedded stdlib.lsp, streaming stdout |
Assembly (WAT) |
wat2wasm (wasm/asm/lumbda.wat) |
30 KB .wasm |
Hand-written WebAssembly Text; near-instant cold start |
Both the Playground and REPL feature "all four (race)" mode: a single Scheme program (including Mandelbrot, Fib+Ack, Sieve of Eratosthenes, and a metacircular self-interpreter) executes concurrently across all four WebAssembly tiers in the browser, timing each tier live and asserting identical output.
5. Benchmarks: Four Tiers Head-to-Head (Commit 5cb8cd7)
5.1 Methodology & Reproducibility
All native benchmarks run on a single laptop: Intel Core i5-8350U (8th-gen mobile, 4 cores / 8 threads, 1.70 GHz base), Ubuntu 24.04, Linux 6.17, gcc 13.3, GNU assembler 2.42 (GAS AT&T syntax), Rust stable (release profile), Python 3.12, and loopback TCP for socket workloads.
Every benchmark suite has a reproducible Makefile target backed by scripts in tests/ running under a six-layer safety envelope (set -e, ulimit -v virtual memory cap, EXIT cleanup traps, timeout, explicit process termination, and straggler verification):
Cross-tier head-to-head: make bench-3way, make friction, make rust-test
Python internal (tree-walker vs bytecode VM): make bench
ASM native hash-set vs portable Scheme: make bench-hashset
ASM memory strategies (bump, naive GC, meta-GC arena, HTTP soak): make bench-gc, make bench-gc-arena, make bench-gc-adaptive, make bench-gc-http
Portals, HTTP, RPC chains, static serving, and EML proof: make bench-portal, make bench-portal-cross, make bench-web, make bench-rpc-chain, make bench-www-race, make bench-proof
5.2 Head-to-Head Across All Four Tiers (6-Benchmark Suite)
The six-benchmark suite exercises tight self-tail loops (count(200k)), iterative accumulator loops (sum-to(200k) via named-let), exponential tree recursion (fib(25)), 3-argument mutual recursion (tak(15,10,6)), deep nested recursion (ack(3,6)), and hash-table throughput (hash(5k set+ref)). Exact measurements at commit 5cb8cd7 (milliseconds, lower is better; bold marks the fastest runtime per row):
Benchmark |
C -j |
C --fast |
ASM gc |
ASM bump |
Rust |
C tree |
Py --fast |
Py tree |
|---|---|---|---|---|---|---|---|---|
count(200k) self-TCO |
20.2 |
27.9 |
37.8 |
58.4 |
70.5 |
192.0 |
1,172.4 |
2,865.0 |
sum-to(200k) named-let |
20.9 |
37.1 |
57.6 |
74.3 |
97.9 |
333.8 |
1,920.0 |
4,361.2 |
fib(25) tree-rec |
53.2 |
64.9 |
67.8 |
77.4 |
242.0 |
409.4 |
2,552.2 |
7,605.1 |
tak(15,10,6) |
26.8 |
26.8 |
3.6 |
7.0 |
23.2 |
38.6 |
922.3 |
1,188.7 |
ack(3,6) |
25.6 |
33.3 |
68.1 |
65.3 |
131.3 |
341.1 |
1,735.2 |
6,503.8 |
hash(5k set+ref) |
24.0 |
28.6 |
11.5 |
13.6 |
31.0 |
39.7 |
1,342.6 |
1,194.4 |
6-Benchmark Total (ms) |
170.7 |
218.6 |
246.4 |
296.0 |
595.9 |
1,354.6 |
9,644.7 |
23,718.3 |
6-benchmark total execution time across all eight runtime configurations on Intel Core i5-8350U (commit 5cb8cd7, log scale). C --jit (170.7 ms) is 139× faster than the Python tree-walker and 56× faster than Python --fast; ASM gc (246.4 ms) beats the C tree-walker by 5.5×.
Per-workload breakdown across the five fast native tiers. C --jit leads tight loops and deep recursion (count, sum-to, fib, ack), while hand-written x86-64 ASM gc takes the crown on tak(15,10,6) (3.6 ms) and hash(5k set+ref) (11.5 ms).
5.3 v1 → v2 Speedup Analysis
The compiler and runtime breakthroughs in §4 transform the performance hierarchy compared to v1:
Tier |
v1 → v2 Speedup |
Primary Drivers |
|---|---|---|
x86-64 Assembly |
5.9× – 37.6× |
O(1) sym->global_val + 1-byte sf_id jump table, 26 zero-cons tagged-fixnum fast paths, epoch-guarded in-place self-TCO / named-let frame reuse |
C (--fast / --jit) |
5.36× – 18.3× |
Hybrid stack-slot + upvalue bytecode compiler, 13.9 KB L1-hot vm_run_loop, OP_SWITCH_LOCAL hash jump tables, open-addressed hash tables, 2-instruction NaN-box checks |
Python (--fast) |
1.7× – 6.1× |
Flat local slots, shared operand stack, inline tail-only named-let & for-each, fused superinstructions, zero-alloc hash keys |
Rust (rust/) |
New Tier (595.9 ms total) |
Pure std bytecode VM beating C tree-walker by 2.27× and Python --fast by 16.2×, while also targeting 437 KB wasm32 |
Four architectural takeaways stand out from the commit 5cb8cd7 numbers:
ASM gc (246.4 ms) outperforms ASM bump (296.0 ms) by 17%. Reclaiming transient frames inside a tight ~1 MB working set keeps heap allocations L1/L2 cache-resident and eliminates repeated mmap page faults that the bump allocator pays as it expands.
ASM gc beats C --jit on tak(15,10,6) (3.6 ms vs 26.8 ms) and hash(5k) (11.5 ms vs 24.0 ms). On 3-argument Takeuchi recursion and tight hash-table loops, direct tagged-fixnum register arithmetic and native sentinel-tagged hash buckets bypass all bytecode/JIT transition overhead.
Rust delivers strong native speed alongside zero-dependency portability. At 595.9 ms total (and 23.2 ms on tak, beating C --fast and C --jit), the pure-std Rust VM sits 2.3× ahead of C's tree-walker and 16× ahead of Python --fast without a single external crate or unsafe JIT emitter.
No recommended mode blows the host stack. Python --fast, C --fast/--jit, Rust, and x86-64 ASM all handle deep tail recursion in constant stack space; only C's diagnostic tree-walker uses the host C stack by design.
5.4 Native Container Primitives & Memory Management (Meta-GC)
Native container fast paths (make bench-hashset). Moving a chained hash-set's inner bucket walk from portable Scheme into straight-line assembly (bi_hash_set_add: one hash_value call, one AND mask, one bucket load, and a tight hs_chain_find loop over raw tagged pairs) yields a 15×–20× speedup over the identical algorithm interpreted in Scheme (N = 5,000 integers: insert ~130 ms → ~7 ms, hit lookup ~125 ms → ~9 ms, miss lookup ~240 ms → ~15 ms). The layout reuses vector tag 7 with negative sentinels (-1 hash-table, -2 hash-set, -3 bytevector, -4 error object), consuming zero extra tag bits.
Bump vs Mark-Sweep vs Meta-GC Arena in Assembly. The assembly tier compiles from one source file into three additive binaries via assemble-time flags (as --64 lumbda.s vs --defsym GC_NAIVE=1 vs --defsym CL_FULL=1 --defsym GC_NAIVE=1). On a 2,000-iteration build-sum-discard workload over 200-element lists (512 MB ulimit -v):
Assembly Build / Strategy |
Wall Time |
Peak RSS |
Collection Behavior |
|---|---|---|---|
Bump-only (no GC) |
727 ms |
133.1 MB |
Unbounded growth (no reclaim) |
Naive mark-sweep (GC_NAIVE=1) |
918 ms |
1.1 MB |
~200 full sweeps (122× less memory) |
Meta-GC (with-arena thunk) |
1,030 ms |
1.2 MB |
1 full GC + 2,000 O(1) bulk resets (0 escapes, 205 MB reclaimed) |
Peak RSS across the three assembly memory strategies on the 2,000-iteration build-sum-discard workload. Naive mark-sweep bounds memory at 1.1 MB (122× below bump-only); (with-arena thunk) replaces 199 of 200 full sweeps with O(1) bulk pointer resets.
Meta-GC three-way policy. On exit from (with-arena thunk), the collector checks: (1) if an implicit full GC already fired inside the thunk, the snapshot is stale — return; (2) otherwise zero volatile registers to prevent conservative false-escape pointers, run the mark phase with the return value as an extra root, and scan [snapshot_r15, %r15) — if unmarked, rewind %r15 in O(1); (3) if any block in the arena range is marked, abort reset and fall through to the full sweep so escaping data stays safely live. An optional EMA-driven adaptive dispatcher (arena-set-mode 1) skips the escape verifier when recent escape rate exceeds 50%, probing every 16th call to detect phase changes; on synthetic friendly/hostile/mixed workloads it tracks within measurement noise of greedy while exposing live counters via (gc-stats) and (arena-stats).
Three-way meta-GC policy at every (with-arena thunk) exit: green = O(1) bulk reset, red = escape detected (safe fall-through to sweep), orange = implicit GC invalidated snapshot.
Precise block typing & 50,000-request HTTP soak. Every heap block in the GC build carries an explicit 8-bit type tag in its 8-byte header:
[ size:48 | type:8 | flags:8 (mark bit 0) ]
Setting the type byte cleanly via movb $HT_X, -7(%rax) at allocation/reuse sites eliminates size-guessing heuristics and the entire class of conservative-scan type-confusion defects (e.g., walking a string payload as a vector). Under sustained HTTP load (50,000 requests × 16 concurrent clients, make bench-gc-http):
Configuration |
req/s |
Baseline RSS |
Peak RSS |
Growth (50k req) |
|---|---|---|---|---|
asm no-GC + heap-snapshot |
~630 |
96 KB |
100 KB |
4 KB |
asm GC + heap-snapshot |
~633 |
116 KB |
120 KB |
4 KB |
asm no-GC + no snapshot |
~625 |
100 KB |
458,812 KB |
OOM (unbounded) |
asm GC + no snapshot |
~610 |
240 KB |
1,092 KB |
852 KB (steady state) |
With zero manual arena management, asm/lumbda-gc holds steady at a single ~1 MB heap chunk indefinitely while staying within 3% of the no-GC throughput ceiling.
6. Portal: Feedback Across Time
A continuation is feedback within a process. A portal is feedback across processes: capture machine state, serialize it, reload it elsewhere, and resume. Lumbda ships three portal formats balancing portability, completeness, and raw speed:
Format |
Consumers |
Size |
Save |
Load |
Resumes |
|---|---|---|---|---|---|
S-expression |
All tiers (Python, C, Rust, asm, asm-gc) |
~310 B |
0.9 ms |
0.7 ms |
Bindings + RNG |
JSON (graph-aware) |
Python, C |
~26 KB |
3.1 ms |
— |
Full VM + k + RNG |
Binary heap dump |
asm (bump build) |
~10 KB |
0.1 ms |
0.1 ms |
Raw asm heap + RNG |
Times measured on a 4-binding workload (int + list + string + fib(30) result) excluding process startup; k denotes a live continuation.
6.1 S-Expression Portal — The Portable Format
The simplest format is the most durable. An S-expression portal is plain Scheme source:
;; lumbda-portal v1
(define my-int 42)
(define my-list '(1 2 3 4 5 6 7 8 9 10))
(define my-str "hello world")
(define my-result 832040)
No schema compiler, no versioned binary decoder, no ABI lock-in. Because Lisp is homoiconic, the language is its own wire format: saving emits define forms via display/write; loading evaluates them via (load ...). Every tier — including the new Rust tier and the asm-gc collecting build — speaks this format natively.
6.2 Cross-Implementation Exchange Matrix
Producer → / Consumer ↓ |
Python |
C |
Rust |
asm |
asm-gc |
|---|---|---|---|---|---|
Python |
✓ |
✓ |
✓ |
✓ |
✓ |
C |
✓ |
✓ |
✓ |
✓ |
✓ |
Rust |
✓ |
✓ |
✓ |
✓ |
✓ |
asm |
✓ |
✓ |
✓ |
✓ |
✓ |
asm-gc |
✓ |
✓ |
✓ |
✓ |
✓ |
Automated cross-tier verification (make bench-portal-cross / tests/portal-cross-test.sh) exercises the 16/16 matrix across Python, C, asm, and asm-gc, and S-expression portals load identically in the Rust tier via (load ...).
6.3 JSON Portal — Graph-Aware, Continuation-Preserving
When a checkpoint must preserve shared references, cyclic closures, or a live continuation, the JSON portal (Python and C) performs two-pass graph-aware serialization:
Tracks object identity (id(obj) → ref_id) to preserve sharing and cycles.
Serializes environment chains, compiled CodeObj procedures, and complete FullCont frame stacks.
Reconstructs builtins from the target runtime's prelude on resume.
Two-pass deserialization allocates empty object shells first, then populates fields and pointers so self-referential closures restore cleanly. During execution, (portal-checkpoint! "state.portal") captures the live continuation at safe points (OP_JUMP / OP_TAIL_CALL) and writes the checkpoint; resuming restarts from the exact bytecode instruction:
python3 lumbda.py --portal-resume state.portal
6.4 Binary Heap Dump & GC-Build S-Expression Fallback
The bump-only assembly build provides a raw binary heap dump: write a fixed header (magic LUMBDAB2, heap size, base address, %r14, %r15, and 4-word RNG state) followed by raw heap bytes. portal-resume maps the heap back with MAP_FIXED at the original virtual address so every internal pointer stays valid with zero relocation in sub-millisecond time.
The collecting build (asm/lumbda-gc) has a multi-chunk free-list heap rather than a single contiguous bump slab, so its portal-save walks %r14 and emits portable S-expression (define <sym> (quote <val>)) forms instead — trading raw-dump capacity for universal cross-tier and cross-architecture portability.
6.5 Preserving PRNG State & Auditable Kernel Entropy
Scientific and stochastic simulations break across process checkpoints if PRNG state lives outside the portal. All Lumbda tiers implement the same deterministic PRNG — xoshiro256** (Blackman & Vigna, 2018) — sharing (random-seed! k), (random-int n), (random-state), and (random-state! lst) (plus floating-point (random) in Python, C, and Rust). Every portal format carries the 256-bit state:
JSON portal: "rng": {"algo": "xoshiro256**", "state": [w0_lo, w0_hi, ..., w3_lo, w3_hi]} (split into 32-bit halves for 48-bit NaN-box safety).
ASM binary portal: 4 × 64-bit state words packed in the LUMBDAB2 header.
S-expression portal: a single (random-state! '(w0_lo w0_hi ...)) form requiring zero parser changes.
Cross-tier RNG verification (tests/portal-rng-cross-test.sh) confirms bit-identical draws across every producer × consumer pair (for seed 42: 558742 543102 559009 124193 317476 ...).
For experiments requiring fresh entropy, (random-seed-from-os!) reads exactly 8 bytes from /dev/urandom (non-blocking, failing loudly on short reads with no silent weak fallback). Entropy enters once on Machine A; capturing (random-state) or saving a portal lets Machine B continue — or an auditor replay — the exact stochastic trajectory bit-for-bit:
;; Machine A — fresh run
(random-seed-from-os!)
(define run-id (random-state)) ; auditable seed snapshot
(run-simulation 1000000)
(portal-save "state.portal")
;; Machine B — resume bit-identically on another host or tier
(portal-resume "state.portal")
(run-simulation 1000000)
6.6 Cross-Process Benchmarks & Graceful Degradation
End-to-end two-process save + fresh-process load timings (50 iterations, make bench-portal):
Producer → Consumer Pair |
Time / Iteration |
Notes |
|---|---|---|
asm → asm (binary portal) |
1.5 ms |
~173× faster than Py → Py |
asm → asm (sexp) |
1.6 ms |
Process startup dominates |
C → asm (sexp) / asm → C (sexp) |
4.1 ms / 4.6 ms |
Cross-tier native handoff |
C → C (sexp) |
6.0 ms |
Native C startup + parse |
Python → C / Python → asm (sexp) |
133 ms / 145 ms |
Python startup dominates |
Python → Python (sexp) |
260 ms |
Two Python startups |
Malformed or mismatched portal inputs (empty files, missing files, truncated S-expressions, binary files passed to load, or truncated binary headers passed to portal-resume) are explicitly tested across tiers to return #f or raise structured errors rather than crashing.
6.7 Use Case: Migrating Primality Search
(define (prime? n)
(let loop ((i 2) (checks 0))
(cond
((> (* i i) n) #t)
((= (remainder n i) 0) #f)
(else
(when (= (remainder i 10000) 0)
(portal-checkpoint! "prime-state.portal"))
(loop (+ i 1) (+ checks 1))))))
(define result (prime? 1000000007))
Machine A checkpoints every 10,000 iterations; Machine B resumes from prime-state.portal without restarting or sharing any scheduler infrastructure.
7. The EML Universality Proof
Lumbda ships a machine-checked proof of the EML universality theorem (Odrzywołek, arXiv:2603.21852v2): a single binary operator eml(x, y) = exp(x) - ln(y) together with the constant 1 generates all elementary functions.
7.1 Operator & Four-Stage Derivation Chain
(define (eml x y) (- (exp x) (log y)))
;; Stage 1 — core (depth 1-3)
;; exp(x) = eml(x, 1)
;; e = eml(1, 1)
;; ln(x) = eml(1, eml(eml(1, x), 1))
;; Stage 2 — arithmetic from exp & ln
;; 0 = ln(1)
;; a - b = eml(ln(a), exp(b))
;; a * b = exp(ln(a) + ln(b))
;; 1/x = exp(-ln(x))
;; x^y = exp(y * ln(x))
;; sqrt(x) = exp(ln(x) / 2)
;; Stage 3 — complex plane via ln(-1) = i*pi
;; pi = imag(ln(-1))
;; i = exp(i*pi / 2)
;; Stage 4 — trigonometry via Euler's formula
;; sin(x) = (exp(ix) - exp(-ix)) / 2i
;; cos(x) = (exp(ix) + exp(-ix)) / 2
;; tan(x) = sin(x) / cos(x)
7.2 Verification Hierarchy & Friction Analysis
The five core algebraic identities (eml_is_exp, eml_is_e, eml_is_ln, eml_is_zero, eml_is_sub) over abstract exp/ln axioms (exp(ln(x)) = x, ln(exp(x)) = x, ln(1) = 0) are verified across six levels (best-of-3 on i5-8350U, make bench-proof):
Verification Approach |
Time |
Guarantee |
Friction |
|---|---|---|---|
Python numerical (proof/eml_proof.py) |
0.04 s |
1e-10 tolerance |
Low: evaluate & compare |
Lumbda numerical brute-force search |
59 s |
1e-10 tolerance |
High: O(N²) pairwise search |
Lumbda symbolic rewriter (asm) — cold |
46 ms |
Exact term rewriting |
150-line portable Scheme checker |
Lumbda symbolic rewriter (asm) — cached |
7 ms |
Artifact replay |
Read & verify cache header |
Lean 4 formal proof — cold rebuild |
722 ms |
Kernel-verified (0 sorry) |
lake build + kernel startup |
Lean 4 formal proof — cached |
5 ms |
Kernel-verified (0 sorry) |
Artifact replay |
Three lessons compound here:
Symbolic understanding beats brute-force search by ~1,280× (46 ms vs 59 s) — MOAD-0001 at the proof-methodology layer.
Cold end-to-end startup favors self-hosted verification by ~16× (46 ms asm, 65 ms C --fast, 87 ms C tree-walker vs 722 ms Lean 4 cold rebuild), because Lumbda directly executes the 150-line term rewriter without compiling and linking a build graph.
Symmetric honesty on TCB: Lean 4's kernel trusted computing base remains smaller and stronger for mission-critical formal proofs; Lumbda's self-hosted checker demonstrates that a language hosting mathematical claims can verify symbolic rewrites natively in under 50 ms with zero external dependencies.
8. Language Coverage & Common Lisp Compatibility
Lumbda implements a near-complete R7RS-small Scheme:
32+ special forms: define, set!, lambda / λ, if, cond, case, and, or, when, unless, begin, let, let*, letrec, letrec*, named-let, do, quasiquote, define-macro, define-syntax, syntax-rules (with ellipsis ...), let-syntax, letrec-syntax, apply, eval, values, call-with-values, call/cc, dynamic-wind, guard, parameterize, load, error, module, import, define-record-type.
100+ builtins: Exact/inexact arithmetic, bitwise ops, SRFI-1 list processing, mutable strings, characters, vectors, bytevectors, hash tables, file/string ports, xoshiro256** PRNG, TCP sockets, spawn-process-stdio, and stdlib.lsp (385 lines of utilities, macros, object system, and SRFI-2/8/64 test helpers).
8.1 Exact Integer Square Root (isqrt)
Floating-point sqrt drifts with FPU rounding mode and libm version — unacceptable in deterministic portal traces. (isqrt n) → floor(sqrt(n)) ships across all tiers with integer-in, integer-out semantics and raises on negative inputs. C, Rust, and x86-64 ASM implement O(log n) bit-by-bit digit recurrence with zero floating-point instructions and zero heap allocation (bi_isqrt in asm runs entirely in three integer registers %r8/%r9/%r10); Python delegates to CPython's exact integer square-root implementation for arbitrary-precision integers.
8.2 Common Lisp Compatibility: Zoë's Favorites
Scheme iterates via tail recursion; Common Lisp iterates via loop, setf, and long-lived interactive images. Guided by Zoë Trout's question — do we care for our programs, and how long are they alive for? — Lumbda ships both idiomatic Scheme ports (examples/ursa-scheme.lsp) and a pure-Scheme compatibility layer (cl-compat.lsp) that runs her iterative number-theory programs (wedgewack.org/ursa.lisp.txt: modular exponentiation, Miller-Rabin primality, Pollard rho, Lucas-Lehmer Mersenne testing, and random prime generation) unmodified in iterative shape across Python, C, and asm/lumbda-full.
cl-compat.lsp provides defun (with &optional), setf, flet, multiple-value-bind, t/nil, -p predicates, mod/ash/logbitp/nreverse, cl-when/cl-unless, and a cl-loop macro covering 14 clause shapes with sequential do*-style stepping and CL's two-phase look-ahead termination semantics. Because every shim expands purely to let*, named-let, cond, and tail calls, full TCO and portal determinism survive intact.
Porting real iterative CL workloads across all tiers also acted as a high-signal stress test, exposing and eliminating five subtle cross-tier defects (intermediate-scope skipping in C env_lookup, variadic apply register clobbering in asm, negative-exponent looping in asm expt, unrooted macro_env_head under GC_NAIVE, and missing cadar in the embedded asm prelude). Verified via make zoe-favorites-test and the live-fetch proof make prove-ursa-runs.
9. Networking, Static Serving & Heterogeneous Compute (bend)
9.1 File I/O Parity
All native tiers share the minimal portable I/O vocabulary required by S-expression portals and servers: load, open-output-file, close-port, port?, display, write, newline, write-file, and file->string. In x86-64 assembly, file descriptors pack directly into SPECIAL values ≥ 1000 (((PORT_SPECIAL_BASE + fd) << 3) | TAG_SPECIAL), needing zero heap allocation or extra tag bits.
9.2 Sockets: One HTTP Server Across Runtimes
Six primitives extend file ports to TCP: tcp-listen, tcp-accept, tcp-connect, tcp-recv, tcp-send, and tcp-close. Because a Linux socket is a file descriptor, it shares the exact port machinery above. The same 90-line examples/http-server.lsp runs unmodified across Python, C, and x86-64 assembly (make bench-web):
Server ← Client Pair (1 KB body) |
Requests / sec |
Notes |
|---|---|---|
Python server ← Python client |
2,403 req/s |
6.3× over curl fork/exec ceiling |
C server ← C client |
2,439 req/s |
6.4× over curl ceiling |
asm server ← asm client |
2,994 req/s |
Zero libc, raw Linux syscalls |
asm server ← C client |
2,500 req/s |
Cross-tier loopback |
Binary footprint comparison at commit 5cb8cd7 (log scale): from the 30 KB hand-written WAT browser module and 88–100 KB zero-libc x86-64 assembly binaries through 160 KB gzipped / 437 KB raw Rust wasm32, 514 KB C + JIT, and 1.1 MB zero-dependency native Rust, compared against busybox httpd (2.1 MB) and Python 3 (8.0 MB).
9.3 S-Expressions over Sockets: RPC, Remote REPL & Multi-Tier Chains
With read-from-string and eval available across tiers, Scheme source serves directly as an RPC envelope. Two portable server patterns emerge: a whitelisted RPC server (examples/rpc-server.lsp, dispatching safely by car without eval) and a remote REPL (examples/repl-server.lsp, persistent global state across connections). Because a 50-line transparent relay (examples/rpc-relay.lsp) forwards raw bytes without parsing, arbitrary multi-runtime chains compose directly (make bench-rpc-chain):
Multi-Runtime Chain (200 ping requests) |
Throughput |
Per-Hop Cost |
|---|---|---|
Py client → asm backend (1 hop) |
2,061 req/s |
baseline |
Py client → C relay → asm backend (2 hops) |
1,234 req/s |
+605 µs/req |
Py client → Py relay → C relay → asm (3 hops) |
766 req/s |
+705 µs/req |
asm client → Py relay → C relay → asm (3 hops) |
796 req/s |
— |
9.4 Portal over HTTP: State Transfer Between Machines
Combining the HTTP server with S-expression portals yields live cross-machine state transfer (examples/portal-http-server.lsp and examples/portal-http-client.lsp). The server exposes bindings at GET /portal; the client fetches the HTTP body and evaluates each line via (eval (read-from-string line)) in the global environment. All 9 combinations in the 3×3 Python/C/asm client × server matrix pass cleanly.
9.5 heap-snapshot: The O(1) Arena Escape Hatch
For bump-only assembly servers with strict per-request lifetimes, (heap-snapshot) captures %r15 and (heap-restore snap) rewinds it in one instruction (both are portable no-ops on GC-managed tiers). An HTTP server using this 2-line pattern holds flat 100 KB RSS across thousands of requests with zero collector overhead.
9.6 Zero-Copy Static File Serving & Adaptive Preload
To serve multi-megabyte static assets (such as this PDF whitepaper) on lumbda.com without bouncing payloads through the Scheme heap, asm/lumbda-gc adds a 90-line tcp-sendfile builtin invoking Linux SYS_SENDFILE (syscall 40) directly. Small assets (≤ 16 KB) serve from an in-memory response hash table; large assets stream kernel-to-socket via zero-copy DMA. Four-way race serving a 2.67 MiB PDF under concurrency 8 (make bench-www-race):
Server |
PDF req/s |
Throughput (MiB/s) |
Peak RSS |
|---|---|---|---|
lumbda-www uncached |
159 |
404 |
15.5 MB |
lumbda-www cached |
237 |
602 |
7.2 MB |
lumbda-www sendfile (asm-gc) |
474 |
1,208 |
4.2 MB |
Caddy file-server (Go reference) |
485 |
1,234 |
37.1 MB |
The zero-libc assembly server delivers within 2% of Caddy's throughput at 9× lower peak RSS. A companion variant (http-static-server-adaptive.lsp) persists per-URL hit counts to www.hits and preloads the hottest URLs on boot while letting the mark-sweep GC reclaim request transients.
9.7 bend: Cross-Tier GPU Dispatch
The fifth scope of feedback crosses the host/accelerator boundary without linking CUDA or libcudart into any Lumbda runtime. (bend! ...) inspects payload size and dispatches either locally or over TCP port 8320 to a Scheme-resident gpu-worker (running on Python, C, or asm) that spawns a self-contained leaf CUDA binary via the cross-tier (spawn-process-stdio path argv) primitive (Python subprocess.Popen, C fork + execve, asm raw pipe2 + fork + execve syscalls).
One (bend ...) form across host, wire, worker, and GPU: small payloads travel as portable S-expressions, large payloads switch to 4-byte-magic binary frames (BSHK, BCGB, BSRT, BSB3), and leaf CUDA binaries return byte-identical results over stdin/stdout.
Small payloads travel as readable S-expressions; above ~1,000 inputs the wire protocol switches to 4-byte-magic binary frames (e.g., BSHK for SHAKE-256 fan-out, BCGB for CGBN modular arithmetic, BSRT for radix sort, BSB3 for BLAKE3 hashing), cutting serialization overhead by 150× at 1M inputs. Workers expose a (health) op reporting free VRAM so multi-GPU fleets route automatically to the least-loaded device. Verified public forms on RTX 3090 (each output validated byte-identical against its host CPU reference):
GPU Form |
Measured Throughput (RTX 3090) |
vs CPU Reference |
Wire |
|---|---|---|---|
cuda-shake-fanout |
1 M × 16 B SHAKE-256 in ~12 ms |
12× hashlib |
BSHK |
cuda-bignum-cgbn |
1.28 Gops/s 256-bit mod-mul |
~256× GMP CPU |
BCGB |
cuda-radix-sort |
5.50 Gkeys/s @ 10 M u64 keys (CUB) |
~4× reference GPU |
BSRT |
cuda-blake3-tree |
32.5 GB/s @ 1 M × 64 B (1.97 ms kernel) |
single-GPU reference |
BSB3 |
10. MOAD Engineering Audit & Test Matrix
Lumbda audits every tier against the canonical Mother-of-all-Defects taxonomy (MOAD Cheat Sheet): MOAD-0001 (sedimentary O(N²) algorithms hidden in hot paths) and MOAD-0002 (implicit global state intertangle).
10.1 Verified Test Matrix (Commit 5cb8cd7)
Every tier and cross-tier contract is verified under make test-all, make rust-test, and make wasm-test:
Suite |
Result |
Scope Covered |
|---|---|---|
Python (tests.py) |
577 / 577 PASS |
Lexer, parser, tree-walker, flat-slot VM, call/cc, macros, rationals, portals |
C Unit + JIT (c/test.c + JIT cross-tier) |
93 / 93 C + 212 / 212 JIT PASS |
NaN-boxing, BigInt promotion, slot/upvalue VM, OP_SWITCH_LOCAL, x86-64 JIT parity |
Rust + wasm32 (rust/ + wasm/tests/) |
46 / 46 unit + 12 / 12 integration PASS |
Pure-std VM, BigInt, macros, embedded stdlib.lsp, Node/browser WASM parity |
x86-64 Assembly (asm/test.sh) |
549 / 549 PASS |
Bump, GC_NAIVE, and CL_FULL flavors; fixnum fast paths, self-TCO, meta-GC, sockets |
Shared & Cross-Tier Matrices |
All Green |
189 shared functional (tests/functional.lsp), 16/16 portal matrix, 9/9 RNG portal, bytevector parity, Zoë's CL suite |
10.2 MOAD-0001: Sedimentary O(N²) Defects Eliminated
Benchmarking and cross-tier scaling systematically exposed and eliminated O(N²) defects across the codebase:
ASM intern_symbol: Linear scan over all interned symbols replaced with a 1,024-bucket djb2 hash table (2.9× faster on 2,000-symbol stress tests), later paired in v2 with O(1) sym->global_val and 1-byte sf_id direct dispatch.
Python _define_record_type: list.index() field lookup replaced with an O(1) dictionary.
C bi_string_replace: Byte-by-byte strncmp scan (O(N·k)) replaced with strstr skip-ahead (O(N + matches·k)).
Python _tokenize_lines: Per-token src.count('\n', 0, pos) (O(N·M)) replaced with a single-pass line_starts index plus binary search (O(M + N log M)).
wire.lsp recv-exact: Repeated string concatenation (O(N²)) replaced with list accumulation plus single final concatenation (O(N)), unblocking linear scaling on megabyte bend payloads.
Engineering takeaway. Modern codebases — and code generated from statistical training distributions dominated by naive linear scans — routinely reintroduce O(N²) patterns whenever new subsystems land. Treating O(1) data structures (hash tables, flat lexical slots, indexed jump tables) as the baseline and auditing hot paths on every release prevents compounding latency across layers.
10.3 MOAD-0002: Documented Hot-Path Coupling
Where hot-path performance or host constraints require shared state, each tier documents the boundary explicitly: %r14/%r15/%r13 global registers in single-threaded assembly; thread-local g_error_ctx and setjmp state in C; module-level runtime hooks in Python. In contrast, the new Rust tier encapsulates all VM state inside a self-contained Vm struct (wrapped per-thread only at the wasm32 C-ABI boundary), demonstrating clean zero-global isolation.
11. Future Work
Full multi-shot call/cc parity in Rust & wasm32: Extending the Rust VM's explicit frame stack to snapshot and serialize FullCont continuations identically to Python and C.
Continuation-passing over HTTP & WebSockets: Moving live serialized continuations (not just bindings) across persistent bidirectional sockets so any network endpoint becomes a trampoline target.
GPU recursive trampolining & interaction combinators: Extending (bend ...) beyond leaf map/reduce kernels to multi-step GPU-resident lambda reductions.
DAG-of-hot-paths predictive preload: Extending http-static-server-adaptive.lsp from raw URL frequency to session-transition probabilities for large static trees (> 1,000 assets).
Copying / generational GC & concurrent accept pool in x86-64 ASM: Replacing stop-the-world mark-sweep with a compacting collector and adding SO_REUSEPORT multi-worker scaling without changing Scheme server code.
Full complex numeric tower: Native complex numbers across all four tiers for direct execution of Stage 3–4 of the EML derivation chain.
Acknowledgments
Zoë Trout — co-author of this work. Her foundational question — do we care for our programs, and how long are they alive for? — shaped both the RNG-preserving portal architecture (§6.5) and the Common Lisp compatibility layer (§8.2). A process, once alive, should be allowed to stay alive.
Citation
russell@unturf, TimeHexOn, fox, Zoë Trout. "Feedback Is All You Need (Second Edition)."
permacomputer.com, December 2026.
https://lumbda.com/lumbda-whitepaper.pdf
Source: https://git.unturf.com/engineering/unturf/lumbda
References
Guy L. Steele Jr. RABBIT: A Compiler for SCHEME. MIT Technical Memo 474, May 1978.
Nicolaas Govert de Bruijn. Lambda calculus notation with nameless dummies. Indagationes Mathematicae, 34(5):381–392, 1972.
David Blackman & Sebastiano Vigna. Scrambled Linear Pseudorandom Number Generators (xoshiro256**). ACM TOMS, 2021 (arXiv:1805.01407).
Andrzej Odrzywołek. All elementary functions from a single operator. arXiv:2603.21852v2, April 2026.
russell@unturf. Stress on Our Shared Heart. undefect.com, April 2026.
License
GNU Affero General Public License v3
AGPL-3.0-only
PERMACOMPUTER PREAMBLE - NO WARRANTY
This is free software for the public good of a permacomputer hosted at
permacomputer.com, an always-on computer by the people, for the people. One
which is durable, easy to repair, & distributed like tap water for machine
learning intelligence.
The permacomputer is community-owned infrastructure optimized around four values:
TRUTH - Source code must be open source & freely distributed
FREEDOM - Voluntary participation without corporate control
HARMONY - Systems operating with minimal waste that self-renew
LOVE - Individual rights protected while fostering cooperation
This software contributes to that vision by proving that feedback
(the computational primitive of continuations) composes into a universal
execution model, extending across four independent implementation tiers
(Python, C + JIT, standalone Rust + wasm32, and x86-64 assembly) through
Scheme source itself as the wire format.
Code is seeds to sprout on any abandoned technology.
Learn more: https://www.permacomputer.com
NO WARRANTY. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
Copyright (C) 2025-2026 TimeHexOn & fox & russell@unturf & Zoë Trout
https://www.timehexon.com
https://www.unturf.com/software
https://www.permacomputer.com
https://uncloseai.com
https://russell.ballestrini.net