A low-level runtime for Telomare
Where Telomare's interaction net runs today, what has been measured, the leads still open, and how cata can help.
doneThe net's loop is in C (N1, N2) and, on x86-64, in assembly printed from a table of the rules (N3): both are pushed, on branch bend.git ls-remote origin: bend at 795a3830, which holds 0b1f26bc (N3)
measuredA first runtime on many threads (N4) gains only where a run is wide; it is on a branch of delfos's, not pushed.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
openThe GPU (N5) is a plan: nothing has run on a GPU yet.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
Each claim is marked: measured (someone timed it; the source says when and where), claimed (a document says so), tested, proved, done (built, in a branch), decided (a decision taken, with its date), lead (proposed, not built), open. Keys: → or space for the next slide, ← back, Home and End, a for the whole deck on one page.
A total language whose compiler reports what a run costs
| Telomare's commitments | |
|---|---|
| C1 | The core grammar is as simple as possible. |
| C2 | Every program that compiles terminates: Turing-completeness is given up so that the compiler can bound a program's work before running it. |
| C3 | Resource use is a first-class output of compilation: the bounds are reported, and runs can be measured. |
| C4 | Eventually exactly one runtime, assumed to be interaction-combinator based. |
| C5 | Abort states invariants that are checked statically, and is erased from the runtime. |
claimedThe IO model is an iterated pure main: each turn of a session is a total function call, and the number of turns lives in the host loop.DESIGN.md §6
claimedThe single runtime is assumed to be the abstract algorithm of sharing-graph reduction, with EAL typability as its admission gate: unsound in general, sound for EAL-typable programs.DESIGN.md §7
Telomare in Bend 2, on branch bend
doneTelomare is rewritten in Bend 2: it prints what master's Haskell prints for a plain run, --meter, --fast and --certificate, and has master's REPL and language server; parse errors are master's word for word, but for a literal above 4294967295, which it refuses.README.md, "Status: moving to Bend", at 795a3830
| Mode | Runs on | Low-level code |
|---|---|---|
plain, --meter | bend/Reference.bend, the reference evaluator | none |
--fast | bend/Fast.bend, the unsized interpreter | none |
--ic | bend/IC.bend's interaction net | the loop in C (bend/effs/ic.c), on x86-64 in assembly |
measuredA whole run, with identical output: tic-tac-toe's test game took 73.7 s on haskell-final's --ic and 2.8 s in Bend (26×); a CaseTests program 289.9 s against 5.0 s (58×). Most of the difference is in EAL, whose analysis keeps its state in flat arrays of words.README.md, "Speed: Haskell to Bend", at 795a3830 (an i7-1160G7 laptop; times that predate master's check analysis and the erasure checker)
doneA .telc carries the IC runtime's verdict (artifact version 12), so --ic refuses a compiled program as it would refuse its source.1624a3c7, 2026-11-18 (in origin/bend)
What the interaction net is made of
- The core has no binders, so a compiled body is a static net template with one environment wire.
- Code is a pointer into a template table: copying code is copying a leaf.
- The environment is delivered through a tree of splitters: disjoint paths are routed, not copied.
- A stuck value is a value: erased if nobody demands it, an error only at readback.
- Guided copying and erasure follow EAL's capture layouts: one bulk operation, generic copiers at the frontier.
Source: DESIGN.md §7.
claimedThe port's net runs only the branch an if chooses: the tic-tac-toe test game takes 2.3 million interactions where master takes 4.0 million.README.md at 795a3830
A net as an array of words
- The net is one
Array<U32>, the same array in Bend and in C, so crossing the boundary copies nothing. - Each agent is eight words: its kind, three ports, two words of data (a Dup's label, a Ref's template, a stuck value's message), and two words that thread the stack of active pairs.
- A port is
agent*4 + slot:p = 41is agent 10, slot 1. Agent 0 is never used, so 0 ends the free list. - A second array, the template store, holds what never changes during a run: each closure's code as a template, the constants (equal data shared) and the plans that guide copying.
- Allocation is part of the meaning: the C allocates in exactly IC.bend's order, because the test compares whole nets word for word.
Source: low-level-runtime.html §2.
Pop a pair, skip it if stale, look up its rule, fire
while (x->err == 0 && x->sp != 0) {
u32 top = x->sp - 1;
u32 a = x->m[top * 8 + 6], b = x->m[top * 8 + 7];
u32 ka = x->m[a * 8], kb = x->m[b * 8];
if (ka == 0 || kb == 0 || x->m[a * 8 + 1] != b * 4 || x->m[b * 8 + 1] != a * 4) {
x->sp = top; // stale: one of them is gone or rewired
continue;
}
u8 r = nt_rule[ka][kb]; // n first, as IC.bend tries it
if (r == NT_NONE) { r = nt_rule[kb][ka]; /* n and m swap */ }
if (r == NT_NONE || r == NT_BEND) return; // Bend's to fire
if (r == NT_APPLY_REF && nt_limit(j.b)) return; // a --fast step: Bend counts it
x->sp = top;
nt_apply(x, r, n, i, m, j); // the rule
}- It stops at the first pair it will not fire; Bend (
Native.bend) fires that pair with IC.bend's own rule and calls the C again. - Back to Bend go the five rules that make a stuck value (the message is a Bend
String), an applied--faststep (its unroll count lives in Bend), and a pair with no rule (the error is built in Bend).
Source: low-level-runtime.html §3 (the loop slightly trimmed from nt_reduce).
Eight consumers, seven values, 57 pairs with a rule
rule.ofclaimedlow-level-runtime.html §4, at 795a3830 (origin/bend)| Rule | What it does | Fires |
|---|---|---|
| ERA_LEAF | Erase a leaf value: both agents go | 703,603 |
| ERA_PAIR | Erase a pair: an eraser for each half | 629,092 |
| DUP_PLANNED | Copy a pair: by its plan if it is a closure whose code has one | 390,924 |
| DUP_LEAF | Copy a leaf: two of it | 274,082 |
| SPLIT_PAIR | Split a pair: its halves to the two results | 189,246 |
| SETENV_PAIR | Apply a pair's function to its environment | 103,791 |
| APPLY_REF | A closure's code applied: instantiate its template | 96,803 |
The rules as data, the C printed from them
bend/Rules.bend:actgives each rule as data, in IC.bend's order. It is a total match on IC.bend'sRule, so a new rule fails to check until the table has it.bend/dev/genic.bendprintsic.c's dispatch (from IC.bend'srule.of) and the rules' bodies (from the table); a flake check fails if the file differs.- The rules turned out to be a small language: spend, delete, new agent, new label, read a constant's part, wire, a branch on labels and one on plans.
case IC.RSetEnvPair{}: case NT_SETENV_PAIR: {
Plain{Spend{} <> Del2{} <> [ nt_spend(x);
leaf("ap", IC.apply()), nt_del2(x, n, m);
Wire{pn("ap", 0), PJ1{}}, u32 ap = nt_alloc(x, NT_APPLY, 0, 0);
Wire{pn("ap", 1), PJ2{}}, nt_connect(x, ap * 4, j.p1);
Wire{pn("ap", 2), PI1{}}]} nt_connect(x, ap * 4 + 1, j.p2);
nt_connect(x, ap * 4 + 2, i.p1);
Rules.bend, the table return;
} ic.c, printeddoneOf ic.c's 651 lines on 2026-11-06, 281 were printed. The machine under the rules stays by hand: the net's words (alloc, delete, connect, grow), instantiation, guided copying and the loop. It removes the rule copies, not the machine copies.low-level-runtime.html §5, at 795a3830 (origin/bend)
measuredThe printed C took about 3% more cycles than the hand-written one: 339M against 328M on tic-tac-toe, under load; why is not known.low-level-runtime.html §7, at 795a3830 (origin/bend)
Almost all of it is testing, not proof
| Claim | Checked by | Kind |
|---|---|---|
| The table does what IC.bend's rules do | tests/rules.bend: the same net word for word, the same result and count | test |
| The C does what IC.bend does | tests/native.bend: the same comparison, against the C | test |
| The C's rules are the table's | printed from it; the ic-generated check | generated |
The C's dispatch is rule.of | printed from it; a one-off comparison with the old hand-written dispatch: 361 kind pairs, 0 differ | generated |
| The port prints what master prints | goldens (63), corpus (17 meters, 16 certificates), parse errors (960), LSP (3) | differential |
testedA gap this work found: 6 of the C's 21 rules had never fired in the word-for-word test. Both tests now have a group where every two kinds meet alone on a net, and all 21 fire; one crossed wire in the table fails the new groups and passes the sessions.low-level-runtime.html §6, at 795a3830 (origin/bend)
openNothing proves the C correct, and nothing proves the table equal to IC.bend: foreign code cannot pass Bend's proof gate.low-level-runtime.html §6, at 795a3830 (origin/bend)
What the loop in C gained
| Build | Interactions | Whole run | Instructions |
|---|---|---|---|
| Haskell master 1cfcb3de | 3,970,174 | 19.9 s | not measured |
Bend, pure IC.run | 2,293,968 | 0.39–0.45 s | 4.64 billion |
| Bend + C | 2,293,968 | 0.09–0.14 s | 0.95 billion |
measuredOf the roughly 200× against master, C gives about 4×. The rest is the flat-array net against master's IntMaps, and firing about 40% fewer interactions.low-level-runtime.html §7, at 795a3830 (origin/bend)
| Date | Step | Tic-tac-toe |
|---|---|---|
| 10-27 | N1: the loop in C | 1.54 s → 0.65 s |
| 11-05 | constant agents, ported from master | 4,895,725 → 2,293,968 interactions |
| 11-06 | N2: prepared programs in the .telc, small starting nets, nt_apply inlined | 346 ms → 92 ms |
After N2: the C is about 70% of a run
| Function | Share |
|---|---|
nt_reduce_run: the loop and the inlined rules | 28.3% |
nt_connect | 13.5% |
nt_dup_closure: guided copying | 12.9% |
term_drop: Bend's runtime | 10.0% |
nt_instantiate | 7.3% |
nt_alloc | 6.1% |
nt_dup_pair | 3.0% |
measuredWhat the gains cost: tic-tac-toe's .telc grew from 265 KB to 458 KB and simpleplus's from 62 KB to 155 KB, as they hold the prepared programs.low-level-runtime.html §7, at 795a3830 (origin/bend)
measuredCompile time is outside the runtime and the longest wait a user sees: tic-tac-toe takes the port 110–190 s, depending on load, and master 72 s.low-level-runtime.html §7, at 795a3830 (origin/bend) (2026-11-06)
The loop in x86-64 assembly, printed from the same table
genic.bendprints the loop, the dispatch and every rule the table describes into a top-level__asm__block inic.c; instantiation and guided copying are written by hand into their rules.- The net's state stays in registers for the whole loop, which C cannot do: every store into the net's words may alias the state's fields. Growing the net is still C.
TELOMARE_IC_LOOP=cruns the C loop; the native test runs both.
| tictactoe.telc --ic | cycles | instructions | wall |
|---|---|---|---|
| the assembly | 577 M | 2.00 G | 152 ms |
| N3's C loop | 737 M | 2.74 G | 188 ms |
| C, before N3 | 760 M | 2.71 G | 191 ms |
measuredOn a Ryzen 7 3700X under load: 874 M user cycles in C, 759 M in C with its helpers forced inline, 565 M in assembly; 243 → 167 ms wall.low-level-runtime.html §8, at 795a3830 (origin/bend) (2026-11-18)
testedGated on delfos: native and rules tests word for word on both loops, goldens 68 passed and 0 failed, parse errors 960 cases and 0 failures, corpus meters 17 and certificates 16 the same. nix flake check was not run.HANDOFF.md P8, "N3 on delfos", at 795a3830 (origin/bend; N3 itself is 0b1f26bc, 2026-11-20)
low-level-runtime.html's opening still says assembly, many cores and the GPU are "designed but not started": it was written on 2026-11-06, and only its §8 was updated for N3.
How parallel is a run?
Every stacked pair gets a generation, one past the pair whose rule made it. The deepest generation is the run's critical path, which no number of cores beats.
| Program | Interactions | Critical path | Most at once | Bound, 4 cores | 8 |
|---|---|---|---|---|---|
| tictactoe.telc, a turn (1 4 2 5 3) | 1.2–1.5 M | 22–23 k | ~1,200 | 3.9 | 7.5 |
| simpleplus.telc 3 4, main | 14,280 | 186 | 264 | 3.9 | 7.6 |
| fib21.telc | 9.5 M | 542 k | 36 | 3.7 | 6.5 |
| tree14.telc | 7.7 M | 393 k | 39 | 3.7 | 6.8 |
measuredThe guess that a run is mostly sequential was wrong: a tic-tac-toe turn is 55–65 interactions wide on average, and 98% of its interactions fire in rounds of 8 or more.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
measuredThe count depends on the order pairs fire in, where guided copying runs: tic-tac-toe's game counts 7,534,180 popping last-in first-out, 7,542,258 bottom first and 7,541,257–7,541,264 in random orders, and the displays stay the same.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
The net on many threads
TELOMARE_IC_THREADS=N, off unless set: the same net and the same table, the rules printed a second time over the threads' primitives.- Each thread has its own bag of pairs, free list, run of fresh agents, labels and share of the fuel; it takes the agents a rule writes, and an owner lets go of them between rules.
| Loop, ms | asm | C | 1 thread | 2 | 3 | 4 | 8 |
|---|---|---|---|---|---|---|---|
| tictactoe.telc (1 4 2 5 3) | 113.6 | 142.1 | 192.2 | 116.1 | 103.5 | 96.5 | 101.2 |
| fib21.telc | 146.9 | 185.1 | 233.5 | 333.4 | 363.5 | 409.6 | 505.0 |
| tree14.telc | 123.2 | 157.2 | 197.6 | 270.2 | 304.4 | 352.4 | 435.6 |
measuredOn tic-tac-toe 4 threads take 15% less than the assembly and a third less than C's loop; on fib21 and tree14, about 36–39 pairs wide, every thread count loses, and more threads lose more.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
measuredOn threads tic-tac-toe's game counts 7,532,353 to 7,533,850 interactions, against 7,534,180 on one loop; fib21 and tree14 count the one loop's.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
doneGated on delfos (4 h 52 min): every step passed but one golden case on 4 threads, whose .telc the case list never wrote; with the list fixed, it and four more passed. nix flake check was not run. Local, not pushed.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
The GPU: a plan, not a result
decidedDecided 2026-11-18: Vulkan compute first, tested on delfos's Intel GPU; CUDA later from the same rule table, and only on a rented NVIDIA GPU, approved each time.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
leadThe first back end would be a printer beside genic.bend that prints the compute shader from Rules.bend's table, as ic.c is printed, checked against IC.bend by the native test.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
claimeddelfos's GPU, probed read-only: an Intel Iris Xe with compute queues, shaderInt64 and 64-bit buffer atomics, 4 GiB storage buffers and 48 KiB of shared memory. Nothing ran on the GPU.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20 (probed 2026-11-18)
claimedolimpo's RX 580 has no CUDA, and ROCm no longer supports it; Vulkan through RADV runs on it with 64-bit integers, but no net has run on it.low-level-runtime.html §8, at 795a3830 (origin/bend) (checked 2026-10-27)
decidedTelomare's development paused before N5 (decided 2026-11-20): N5 is a lead, not a result.the maintainer's instruction, 2026-11-20
A C runtime under master's own --ic
measuredOn master's Haskell, the net's rules and loop in C (cbits/tel_ic.c) over flat arrays of words, with Telomare.IC.Native laying IC.hs's net out as words: tic-tac-toe's five-move session went from 19.1 s to 0.87 s, and from 3,970,174 interactions to 2,120,988, with the same output.3b7c8352, 2026-11-06, branch hhefesto/ic-c-runtime (pushed)
claimed--ic --meter still runs IC.hs there, so no golden changes; an if builds only the branch it chooses, so the C needs no parking queue.3b7c8352
openIt is not in master: it is pull request #160, open and marked WIP.gh pr list, Stand-In-Language/stand-in-language, 2026-11-23
What holds any runtime back today
claimedThe fuel cap: a turn stops at 10M interactions by default, about 0.3 s, so faster hardware saves little per turn on today's programs unless the cap rises.low-level-runtime.html §8, at 795a3830 (origin/bend)
measuredLong runs do not reach this code: they run on --fast, an interpreter in Bend with no C, 8.2 s for 9! where the 10-27 master build took 4.7 s. It is the one place the port is slower at run time.low-level-runtime.html §8, at 795a3830 (origin/bend)
measuredCompile time: simpleplus's --ic --meter took 767–781 s after the 98c963c2 merge, against 268–274 s before (delfos busy with the gate both times); perf puts 97% of the analysis in the runtime freeing values it copied.HANDOFF.md §3, "Worse: compile time", at 795a3830; §8 at 168955fd
openThe machine under the rules is still written by hand in each back end.low-level-runtime.html §5, at 795a3830 (origin/bend)
In the order they look to pay
leadN3: the dispatch's one indirect jump and the net's scattered words are most of what is left.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20, "Next, in order"
leadN4: links HVM2's way, an auxiliary wire as one cell each end fills by an atomic exchange, so a rule never writes a neighbor and adjacent pairs never conflict.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
leadN4: threads only when the stack is wide; the threaded loop in assembly; more cores (the Ryzen 7 3700X has 8, 16 threads).HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
openN4 needs design first where things are not local: guided copying walks a whole region in one rule, and the free list and label counter are global.low-level-runtime.html §8, at 795a3830 (origin/bend)
leadN5: print the compute shader from the rule table; a net suits a GPU best as many independent nets at once, one session per work-group.low-level-runtime.html §8, at 795a3830 (origin/bend); HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20
openDecisions still open: which interaction count a threaded run prints (its own, or --meter keeping a run on one loop), and whether N4 gets a second round before N5.HANDOFF.md P8, "N4, the first round", at 168955fd (delfos's branch bend-n4, not pushed); c9dcd1d4, 2026-11-20, §8
What a proof covers, and what only tests do
provedbend/PROOF.bend proves what makes sizing's erasures safe (erasure, counts_suffice, what_runs, certificate_opening, certificate_guarded, fuel_more), and nix flake check rechecks it with BendTT's kernel (--verdict).README.md, "What is proven", at 795a3830
testedThat the IC computes what bend/Sem.bend says: tested on whole sessions (bend/tests/sem.bend), not proven.README.md, "What is proven"
testedThat the C and the assembly do what IC.bend does: word-for-word tests, not proof.low-level-runtime.html §6, at 795a3830 (origin/bend); HANDOFF.md P8, "N3 on delfos", at 795a3830 (origin/bend; N3 itself is 0b1f26bc, 2026-11-20)
openTermination of the checked runs is EAL's promise, and nothing proves it; the laws are separate statements, not yet one theorem, and what_runs is proven in one direction only.README.md, "What is proven"
What exists: master's library through cata
cata writes Bend from Haskell by fixed rules, with no model in the loop. What its rules cannot take goes to a ledger with the reason; each def it keeps is held to GHC's own answers as example laws, and bend2hs (G) writes it back as Haskell to check the round trip G(F(h)) against h.
measuredMaster's own net module is among them: the 7 defs of Telomare.IC that have example laws answer as Haskell does on all 14 of those laws after the round trip, in that uncommitted run (at 8bfb514 GHC still refused those 14 lines).cata-ct (branch ct), uncommitted, tests/telomare/laws.zsh, 2026-11-23; 8bfb514's message
claimedThe bend branch's port (62k lines, written by hand and by agents) is never inside cata; where both have a def, cata's is the same shape with Nat for Int.cata PLAN.md, "Packages: telomare master" (2026-11-19)
Leads: following master, and checking the port against it
leadFollowing master: bend has five merge commits of master (10-27 twice, 11-05, 11-17, 11-19), each change then ported to Bend by hand and by agents. cata translates master's library by rules, so a merge could start from cata's output, with GHC's answers as the laws: a checkable spec for the hand-written port.git log --merges of bend (a68b9850, 3e72bc00, e8e03392, 414daa87, e5da36b1); HANDOFF.md §3; cata README.md
leadChecking the port: cata's square checker (tests/adjoint/run.zsh) holds a hand-written Bend b to a Haskell h, phi(F.h(x)) == W.b(phi(x)), for every input (15 of xmonad-bend's 17 StackSet squares by --verdict; Config 5 of 5) and at GHC's own answers. It could pair the bend branch's modules with master's the same way; that is not done.cata PLAN.md, "cata as a functor" §4; 4db79d0
measuredFaster loops for that work: cata's checks are cached by a Merkle digest of each file and its imports; telomare's package took 168 s with no cache and 104 s warm, every file the same.cata PLAN.md §1; 0fc4a33
measuredFewer copies: of the specialiser's 808 copies in telomare, at least 245 are another copy's program at another type, where one polymorphic def and one law would do.cata PLAN.md, "Naturality"; a81a25d
openThe machine under the rules (alloc, connect, instantiate, guided copying) is written by hand in each back end. Whether it can be described once and printed, as the rules are, is open; cata's way (fixed rules, a ledger, laws before code) is one way to try.low-level-runtime.html §5, at 795a3830 (origin/bend)
Branches and their state, 2026-11-23
| Where | Holds | State |
|---|---|---|
| telomare master (upstream) | Haskell; last merged into bend at 98c963c2 | now at 4e970407, one commit ahead |
bend, 795a3830 | the port, the C loop, the rule table, N3's assembly | pushed to hhefesto/stand-in-language; no pull request |
| bend-n4, 168955fd | N4: threads, the parallelism profile | delfos only, not pushed |
| hhefesto/ic-c-runtime, 3b7c8352 | a C runtime under master's Haskell --ic | pull request #160, open (WIP) |
| N5 | the GPU | not started |
| cata master, 8bfb514 | Haskell to Bend; telomare's round trip, 350 of 420 | pushed (hhefesto/cata) |
| cata-ct | the parser and rationals on G's side: 400 of 420 | uncommitted |
Made with bend-frp
The slides are data in Bend (Deck.bend); bend-frp runs the page, and the navigation is a small pure machine (Nav.bend).
provedIts laws: moving never changes the number of slides, next then back returns where you were, going to slide k from anywhere lands on k, the keys and addresses mean what this page says, and every claim, table and card names a source. bend PROOF.bend --verdict prints ALL PROOFS CHECK.telomare-site's LAWS.bend and PROOF.bend