Hazel reports · ^report(54) · hazel-jit · 2026-11-16, revised 2026-11-24 20:58 MST · work in progress · after ^report(52)
Same Answers as the Interpreter
hazel-jit compiles a livelit's view, and a slide's whole run, from Hazel to JavaScript, so that a slider's step can show in the picture within a frame (^report(50) to ^report(52)). On Friday 2026-11-13 Matthew Hammer and Cyrus Omar met about its next steps. The main one: what the compiled code computes must be what Hazel's interpreter computes, and CI must check it. Here is the plan from that meeting, change by change, and where each change stands. It also covers what it would take to run any piece of a Hazel program this way, not only livelit views, and the direction chosen: a mixed mode, where the interpreter calls compiled functions. This report is revised as the work goes on.
Outline#
- The plan: the meeting's items, as tickets, and how far each has come.
- What hazel-jit is, for a reader new to it: what it compiles, where it runs, and what happens to what it does not compile.
- The same answers, checked in CI: every evaluator test program also runs compiled, and a difference fails the build.
- The same programs, timed: the evaluator's programs, each run in the interpreter and compiled, timed; and a larger program, the astrology oracle, 170 times as fast compiled.
- Exact integers: Int and Nat as the interpreter has them, past 253.
- Divide by zero and other invalid operations: the compiled run stops, and the interpreter's run answers.
- Overflow: SInt had three widths; now 32 bits everywhere, and overflow an error.
- What stays with the interpreter: holes, type holes, programs with type errors, and the stepper's functions, explained.
- The other limits, one at a time: what the compiler did not handle, ranked by how often the tests meet it, and what is done.
- A step budget: Cyrus's concern, that a compiled function that never ends would freeze the page.
- What it all costs: the Witch slide, build by build.
- Found along the way: an interpreter crash on modulo by zero, fixed on a PR, and a cost of undeclared result types.
- Beyond livelits: compiling any piece of a program, what today's design assumes, what is new in general, mixed mode, the direction chosen, step counts and probes as the interpreter's, and compiling ahead of time for older phones.
- Lists as JavaScript arrays, and holes: arrays measured against today’s cells and a hybrid of the two; holes in lists, terms with holes, the order to build them in, and where hazel-jit lives now.
- Records the page’s way: a record held as a page’s object crosses for nothing and builds about 12 times as fast; five decisions, for Matthew (
^ticket(847)); decision 1 chosen: A, records as objects, with field reads in place, takes 0.63 of today’s time as the games play; decisions 2 to 5 done as leaned. - A sequence beside List: a treap over array views inserts anywhere in about a microsecond at every size up to a million, and takes a page’s array for nothing; a walk costs about what cells cost (
^ticket(846)). - What a closure keeps: whether
devtrims a value’s environments to what the value uses (it does not), where that was tried, what trimming would take, and what the jit already does. - Questions for the team: seventeen open design questions, each with our lean, for the team's meeting of 2026-11-17, two of them met by the astrology oracle this morning.
- What next, with next steps for Matthew and others, and how this was put together.
The plan#
Of the meeting's seven changes, six are done on the hazel-jit branch and pass CI, overflow among them: SInt is 32 bits everywhere, each result checked. One is under way: the limits, where four of the evaluator's 313 programs still meet one, all four ill-typed tests left so on purpose, and probes are not begun. Each became a ticket on the work dashboard. Three more tickets came out of the work itself: a crash in the interpreter, now fixed on a PR to dev; a cost in how Hazel checks types at run time; and the oracles, slow on an older phone, now compiled ahead of time. A last ticket is the direction chosen after the meeting, mixed mode. What the team could decide is gathered in questions for the team.
trial/694-view-jit (hazelgrove/hazel#2817, the hazel-jit prototype); amber: in progress; grey: waiting on a decision or not begun; blue: on a PR to dev. Not a build of the app: a status chart.Matthew's summary of the meeting, as he wrote it on 2026-11-15:
- we want semantic consistency with Hazel the interpreter, and to ensure that with CI, and our design decisions.
- arb precision Ints and Nats --- we want to use bignum in the output if we can, or something comparable, not native JS numbers for Ints and Nats.
- when we hit an overflow for any times where that is possible -- we should check each time for non-arb precision numbers --- we should create an indet term / stuck term with that error -- look at existing interpreter cases for inspiration.
- similar for divide by zero
- for the output of hazel-jit, we should continue to avoid translating code with holes, and we should exclude "stepper functions" (don't know what that is myself, please explain later).
- probes, step budgets, and all other limitations we should work to overcome in the coming days.
And Cyrus's concern, which Matthew passed on separately the same day: "We need a way to limit compiled hazel functions that diverge --- we need a step limit. esp if we continue to optimize by including certain jit-compiled hazel functions into the main thread"
| Ticket | The change | Where it stands | |
|---|---|---|---|
^ticket(756) | Consistency with the interpreter, checked in CI | On build 49: every evaluator test program also runs compiled, and any difference fails CI; so do the slides' own programs (129: 15 compile, all agree); each program timed both ways. | done |
^ticket(757) | Int and Nat exact, as the interpreter's | On the branch: a JS number while it is a safe integer, a BigInt past that. Measured on the Witch. | done |
^ticket(758) | Overflow stops at a stuck term | On the branch: SInt is 32 bits everywhere, each result checked in the interpreter and hazel-jit (decided 11-16). The interpreter's half is on a PR to dev, hazelgrove/hazel#2828: CI green, its tests reaching 96% of the changed lines; waiting on review. | done |
^ticket(759) | Divide by zero stops at a stuck term | On the branch: the compiled run stops, and the interpreter makes the stuck term. | done |
^ticket(760) | Holes and the stepper stay with the interpreter | On the branch, with two rules the sweep found: no program with type errors, and no type hole. Left: a check in the browser. | done |
^ticket(761) | The other limits, one at a time | On the branch: 20 builtins, partial application, mutual recursion, undefined, tuple extension and labels, strings in graphemes, reverse application. On their own branch, CI green 11-17: an unlabeled entry, from_lvs, a module member that is an expression, a value in a recursive definition; four programs of 313 still meet a limit, all four ill-typed tests. Probes not begun. | in progress |
^ticket(763) | A step budget for compiled code | On the branch: 50 ms or 50M calls a run, then the interpreter. Left: a cheaper counter. | done |
^ticket(764) | Found: modulo by zero crashed the interpreter | Fixed on a PR to dev, hazelgrove/hazel#2825, waiting for review. | on a PR |
^ticket(762) | Found: an undeclared result type costs a step 5 to 7 times | Measured in Hazel's interpreter; the cause is where the ascriptions go. The fix is not begun. | waiting |
^ticket(765) | Found: the oracles were slow on an older phone; compiled ahead of time | The I Ching and the Tarot run compiled by default (hazeljs-oracles 0.0.13), each checked against hazeljs over thousands of answers: on the phone, ready in 0.8 s, not 3.7 s. Astrology too since 0.0.16 (11-18): a chart in about 1 ms, not 1.4 s, the same as hazeljs on 40 charts. Left: the compiler inside hazeljs. | done |
^ticket(766) | Chosen after the meeting: mixed mode | A first step is written, on its own branch, CI green 11-17: the interpreter runs the program and calls its functions with declared types, top-level and in modules, compiled, as builtins. The Petri net rule 22 times as fast, the I Ching's 4. | in progress |
^ticket(767) | Asked 11-13: the interpreter's step counts in compiled code, then probes | Designed: yes to both, with care for casts and a check in CI (below). The interpreter's counts for 57 small programs measured; the counter in compiled code not begun. | in progress |
All of the done changes are on trial/694-view-jit, the hazel-jit prototype branch (hazelgrove/hazel#2817), as build 50 since 2026-11-18. Build 49 (2026-11-17) merged that morning's branches (the last limits, mixed mode, the timing, the slides' check, the step calibration), with all of CI green on it (static checks, fast checks and full tests, CI run 44137711359) and the slides' browser check too (run 44137800916; the builds). Build 50 adds the slides' builtins, a fast-forward of their branch once all of its CI was green (CI run 44211080673); the prototype's own CI then passed on build 50 too (CI run 44319161267; the full tests in 94.5 minutes, close to their 100), and so did the slides' browser check (run 44319161252). Each was written on its own branch, passed CI there, and was brought together with the others; CI passed again on the whole, and so did the slides. None is on dev: ^report(53) explains why the prototype is to be redone by hand in small steps.
What hazel-jit is#
hazel-jit translates an elaborated Hazel program to the text of a JavaScript function, and the page runs that function on its own thread at a livelit's event, to draw the livelits before the interpreter's answer comes back. Hazel's interpreter, in a web worker, still runs every program, and its answer is still the program's result: the probes, the tests and the result panel come from it. So far hazel-jit has been a measurement of how fast compiled Hazel could be (a step of the Witch's slider in 2 to 3 ms, ^report(50)). The meeting's point is that it must also be correct, because whatever it draws, a user reads as what Hazel computed.
A form the compiler does not handle raises an error with its reason, and the page then waits for the interpreter's run, as it did before hazel-jit. So a limit costs speed, never correctness. A compiled run that stops part way (an invalid operation, undefined, or the step budget) is handled the same way. These fallbacks are what keep hazel-jit's answers the same as the interpreter's: where the two would differ, hazel-jit gives no answer and the interpreter's is shown.
The same answers, checked in CI#
Every one of the evaluator's 313 test programs now also goes through hazel-jit in CI. 260 compile, and each gives the interpreter's answer, apart from 27 known ill-typed tests, and those the page never compiles. A new difference fails the build. (^ticket(756).)
0e56bdbd0a), the fast checks' sweep (CI run 44137711359). Each of the evaluator's test programs also goes to hazel-jit: compiled and run in JavaScript, its answer compared with the interpreter's. "Not a value": the interpreter stops at a failed run-time type check in an ill-typed test (4 : String, ...), which compiled code, its types erased, would run past; the page never compiles such a program (^ticket(760)). By rule: holes, type holes, and the tests' unbound names. A limit: a form hazel-jit does not compile yet (^ticket(761)).The check is a sweep in the evaluator's tests: each test hands its program to hazel-jit, runs the JavaScript, and compares the value with the interpreter's: numbers exactly (floats within a relative 10-9), lists, tuples, labels and constructors by structure, and a function only as being a function. A compiled run that stopped at an invalid operation agrees with an interpreter result stuck at the same error (below). The 27 ill-typed tests are listed by name, and anything else that parts from the interpreter fails its test. The end of each run prints a report in CI's log: how many were compiled, how many agreed, and why the rest were not compiled.
The first sweep, on 2026-11-15 (the full tests), had 316 programs: 237 compiled, 207 agreed, 30 ill-typed, and none differed. It found the rule that programs with type errors stay with the interpreter (below). Merging the six branches found one more parting, with no static error: a value passed through a written type hole to a function that takes another type. That led to the rule that a type hole is a hole. The 49 programs not compiled by rule, and the 4 not compiled for a limit, are these:
| Not compiled because | Programs | Rule or limit |
|---|---|---|
| a hole (a label that is a hole among them) | 15 | rule |
| a type hole | 10 | rule |
| a free variable (the tests' own unbound names: y 13, s2 6, x 2, b2 2, a 1) | 24 | rule |
| a fixpoint over a pattern that is not a name or a tuple of names (fix _ : (), fix (_ : Bool), fix 0; ill-typed tests) | 3 | a limit (^ticket(761)) |
| a fixpoint over (), a tuple of no names, whose body is not a function (fix () -> []; an ill-typed test; corrected 11-18, once CI named it) | 1 | a limit (^ticket(761)) |
What is left: the slides' own programs, which the sweep does not see. They are checked only by the Firefox run on GitHub's machines, which compares the pictures, not the values.
The same programs, timed#
Run again and again, the 233 evaluator programs that compile and give the interpreter's value took the interpreter 32 ms a run in all, and compiled code 0.18 ms. The median program is 222 times as fast compiled (34 µs against 0.22 µs), and every one is faster, from 2.3 to 3,624 times; the 70 that take the interpreter 0.1 ms or more, a median 321 times. Run once, compiling included, as a page that compiles before its first run would, the median program is 1.2 times as fast, and 87 of the 233 are slower: programs of a few microseconds, where compiling is the cost. Matthew asked for these on 2026-11-17: the evaluator's test programs, timed in the interpreter and in hazel-jit.
0e56bdbd0a, CI run 44137711359, the fast checks, Node on GitHub's machines). Each program's interpreter runs repeated until they added to 20 ms (10 to 1000 times), and its compiled JS's until they added to 5 ms; each dot is a run's time, the total over the repeats. Below the line marked "as fast", compiled code was faster. Not a build of the app.How each was timed: in CI, in the same Node process as the tests, as the consistency check ran. Most of these programs take the interpreter well under a millisecond, too near the timer's grain for one run to say much, so each is run again and again (Matthew: "can we repeat the work 100 or 1000 times to get a multi ms number in the interpreter?"). The interpreter's runs repeat until they add to 20 ms, at least 10 times and at most 1000. The compiled JavaScript's repeat until they add to 5 ms, at most 100,000 times. The times are a run's, the total over the repeats. Both are warm then: the interpreter has seen the program before, and so has the JavaScript engine. The first runs are kept too, since a page meets those: the interpreter's as the test ran it, hazel-jit's compile to JavaScript's text, and the JavaScript parsed and run once.
| Program (the evaluator's test) | The interpreter, a run | Compiled JS, a run | As fast, times | First runs: the interpreter | hazel-jit's compile | The JS parsed and run |
|---|---|---|---|---|---|---|
[(index=true, `A`=60, `B`=30, `C`=0), (index=false, `A... | 5.43 ms ×10 | 19.6 µs ×255 | 277 | 15.5 ms | 0.36 ms | 3.13 ms |
[(1, 3), (2, 4)] == zip([1, 2], [3, 4]) | 3.59 ms ×148 | 0.99 µs ×5052 | 3,624 | 0.13 ms | 72.5 µs | 71.8 µs |
[1, 1, 3, 4, 5] == sort(fun (x, y) -> if x == y then Eq else ... | 1.89 ms ×20 | 4.7 µs ×1055 | 400 | 1.09 ms | 0.20 ms | 0.16 ms |
[5, 4, 3, 1, 1] == sort(fun (x, y) -> if x == y then Eq else ... | 1.71 ms ×18 | 3.3 µs ×1499 | 512 | 1.30 ms | 0.22 ms | 0.11 ms |
[1, 2, 3] == unique([1, 2, 2, 3, 1, 3]) | 0.99 ms ×30 | 1.8 µs ×2722 | 538 | 1.50 ms | 0.17 ms | 98.7 µs |
[1, 2] == sort(fun (x, y) -> if x == y then Eq else (if x < y... | 0.84 ms ×28 | 1.1 µs ×4537 | 763 | 1.10 ms | 0.34 ms | 42.2 µs |
[1, 2, 3] == sort(fun (x, y) -> if x == y then Eq else (if x ... | 0.71 ms ×35 | 5.3 µs ×1159 | 136 | 0.66 ms | 0.30 ms | 0.12 ms |
[(1, [1, 3]), (0, [2, 4])] == group_on_key([1, 2, 3, 4], fun ... | 0.53 ms ×51 | 1.0 µs ×4890 | 522 | 1.16 ms | 0.13 ms | 89.2 µs |
[5, 3] == type T=String in let map = typfun a ->typfun b -> f... | 0.44 ms ×65 | 0.85 µs ×7571 | 512 | 0.54 ms | 91.8 µs | 56.5 µs |
[2, 4] == filter([1, 2, 3, 4], fun x -> int_mod(x, 2) == 0) | 0.39 ms ×78 | 0.43 µs ×11640 | 907 | 0.34 ms | 93.1 µs | 0.18 ms |
[1, 3] == filteri([1, 2, 3, 4], fun (i, x) -> int_mod(i, 2) =... | 0.37 ms ×67 | 0.64 µs ×11816 | 571 | 1.63 ms | 0.14 ms | 60.9 µs |
[3, 2, 1] == reverse([1, 2, 3]) | 0.34 ms ×102 | 0.56 µs ×8953 | 617 | 0.28 ms | 0.13 ms | 48.2 µs |
The slides' own programs, timed the same way on build 49: of the 129 programs under hazel-programs, 21 have a static error and stay with the interpreter, as do those with a hole (27), a type hole (25) or a test (25); 10 call to_lvs and 4 int_plus, builtins hazel-jit lacks; the 15 that compile and give the interpreter's value took the interpreter 8.4 ms a run in all and compiled code 0.026 ms, the median program 269 times as fast.
| Program (hazel-programs/) | The interpreter, a run | Compiled JS, a run | As fast, times | First runs: the interpreter | The JS parsed and run |
|---|---|---|---|---|---|
docs/reference/polymorphism.hz | 2.16 ms ×12 | 0.88 µs ×5779 | 2,457 | 4.12 ms | 0.13 ms |
docs/livelits/either/either-typed.hz | 1.90 ms ×16 | 1.7 µs ×2947 | 1,121 | 1.78 ms | 0.41 ms |
docs/livelits/splices-mvp.hz | 1.27 ms ×27 | 5.6 µs ×887 | 225 | 0.85 ms | 0.62 ms |
docs/livelits/either/either-unknown.hz | 0.59 ms ×56 | 2.0 µs ×2512 | 296 | 0.43 ms | 92.1 µs |
docs/livelits/result-view.hz | 0.47 ms ×45 | 1.7 µs ×2875 | 269 | 0.54 ms | 0.11 ms |
docs/livelits/splices-in-text.hz | 0.44 ms ×61 | 1.2 µs ×4037 | 353 | 0.40 ms | 0.47 ms |
docs/livelits/splice-row.hz | 0.41 ms ×38 | 7.4 µs ×672 | 54 | 0.94 ms | 0.10 ms |
docs/livelits/hygiene/generated-binders.hz | 0.39 ms ×70 | 1.3 µs ×3713 | 292 | 0.42 ms | 82.5 µs |
docs/livelits/lockable-cell.hz | 0.27 ms ×56 | 1.3 µs ×3922 | 204 | 1.60 ms | 66.2 µs |
docs/livelits/hygiene/capture.hz | 0.25 ms ×92 | 0.82 µs ×6108 | 311 | 0.27 ms | 0.46 ms |
docs/livelits/hygiene/abs.hz | 0.19 ms ×10 | 1.6 µs ×4605 | 118 | 0.32 ms | 0.59 ms |
docs/livelits/advanced/javascript.hz | 22.9 µs ×346 | 0.05 µs ×100000 | 510 | 0.14 ms | 7.5 µs |
docs/livelits/expansion-errors/errors-about.hz | 5.5 µs ×1000 | 0.04 µs ×100000 | 127 | 66.8 µs | 7.6 µs |
docs/livelits/either/either-about.hz | 4.3 µs ×387 | 0.04 µs ×100000 | 99 | 60.6 µs | 11.6 µs |
docs/livelits/hygiene/about.hz | 3.2 µs ×1000 | 0.04 µs ×100000 | 73 | 57.1 µs | 6.1 µs |
These are the evaluator's own tests, which are small: most take the interpreter well under a millisecond. The Witch slide is the larger case (what it all costs, and ^report(50) to ^report(52)), and mixed mode's timings are larger programs again (the first step, built).
A larger program: the astrology oracle#
The astrology oracle's rules, eleven modules of floating-point code, compile whole and give the interpreter's answer, 170 times as fast: a reading in 2.6 ms compiled against 437 ms interpreted. The evaluator's programs above are small, most under a millisecond. This one is the Hazel of hazeljs-oracles' astrology page (its astrology/rules at fbfc59f, about 30 kB: the Sun, the Moon and the planets from Meeus's and Schlyter's series, the chart's angles, the aspects and the reading's words), joined as hazeljs joins it and asked for one reading, a birth and a day.
| Phase | Time | Runs |
|---|---|---|
| Parsed (FastParse, as hazeljs parses) | 592 ms | 1 |
| Elaborated | 196 ms | 1 |
| The interpreter's run, one reading | 437 ms | 1 |
| hazel-jit's compile, the whole program | 13 ms | 1 |
| The compiled JavaScript's run (79 kB of it) | 2.57 ms | 3 |
Build 49 with the test added (trial/768-astrology-timed, 81945a4d4c, CI run 44191280236, the fast checks, Node on GitHub's machines). One run each, so these are one sample, not a distribution: the compiled run's three runs are the first and two more, and the interpreter's run is its first. The two answers were compared value by value and agree. Mixed mode's measure of the same program is in the full tests, not yet back.
Getting these numbers took five CI runs, each past its time limit. The tests' own parser reads text by inserting it, as typing would, which is slow for a 30 kB program, so the test now parses with FastParse. Three readings, each run three times, plus mixed mode, were too much for the 20 minutes the quick tests had left. The fifth run wrote each phase to a file as it ended, which CI prints after the tests whatever happens. That file shows the test itself finishing in under 2 s, and the quick tests still going past their limit. Found 2026-11-18: with build 50 merged in, whose consistency check runs a program that already takes 20 ms only once more instead of ten times, the same branch's quick tests pass in 12.7 minutes (the fast checks, 14.7; CI run 44320263066), the astrology test giving the same answer, 144 times as fast compiled there. So build 49's timing rule was the cause, as guessed.
The astrology page now casts compiled by default (hazeljs-oracles 0.0.16, 2026-11-18, ^ticket(768); Matthew: "It seems like we should, if possible"), as the I Ching and the Tarot have since 0.0.13 (compiled ahead of time). A test on trial/768-astrology-aot (build 50 and the astrology tests) prints the rules compiled whole, their answer the function Reading.reading, and the oracles' tools/make-compiled.py wraps them, 101 kB with the runtime. In Node, over 40 charts, the app's own and then births, days and places drawn from 1900 to 2099: a chart that hazeljs builds and casts in a median 1,436 ms is cast compiled in 0.85 ms (0.36 ms warm), with the same words and every number within a relative 10-10. In the browser pane, a first cast took 13 ms, without loading hazeljs at all.
Exact integers#
Int and Nat are now exact in compiled code, as the interpreter's are: an integer is a JavaScript number while it is a safe integer (up to 253 − 1), and a BigInt past that. (^ticket(757).) The interpreter's Int and Nat are arbitrary-precision integers (Jane Street's Bigint), and hazel-jit had made them JavaScript numbers, which round past 253: 253 + 1 came out as 253.
Every integer operation normalizes its result back to a number when it fits, so two equal integers are always the same value, and === still compares them. Division rounds toward zero, as the interpreter's does, and stays exact where Math.trunc(a / b) would round. Where plain BigInt everywhere cost a 4.1 times slower fib(25), a 1.5 times slower list walk, and 9.6 times slower model updates, this mix costs 1.6 times, nothing measurable, and 3.7 times (Node, against plain numbers; not a build of the app). On the Witch slide it costs nothing measurable (below). SInt, Hazel's fixed-width integer, stays a JavaScript number: its width is the overflow question.
Divide by zero and other invalid operations#
Where the interpreter stops at an error (dividing by zero, a negative power, int_of_string of something not a number), the compiled run now stops too, and the page shows the interpreter's run, which holds the stuck term with its error. (^ticket(759).) Before, 7 / 0 compiled to Infinity.
The stuck term is the same as the interpreter's by construction, since it is the interpreter's. The alternative, making the stuck term in JavaScript and evaluating around it as the interpreter does, would be a much larger piece of work and is not needed for the answers to agree. Writing the tests for this found a crash in the interpreter itself, on modulo by zero (below).
Overflow#
Decided on 2026-11-16, Matthew Hammer: an SInt has 32 bits everywhere, and a result past them is an error, a stuck term, as a divide by zero is. Done in the interpreter and in hazel-jit, and on the hazel-jit branch since build 48, all of CI passing. (^ticket(758).) Until now SInt overflowed three different ways, depending on how Hazel ran. In the browser, Hazel runs under js_of_ocaml, where an OCaml int has 32 bits, and SInt wrapped silently. A native build of Hazel has OCaml's 63-bit int. hazel-jit had a JavaScript number (checked through hazeljs 0.0.6, which runs Hazel as the browser does):
| Program | The browser's interpreter (32 bits, wraps) | A native build (OCaml's 63-bit int) | hazel-jit (a JS number) |
|---|---|---|---|
use SInt in 2147483647 + 1 | -2147483648 | 2147483648 | 2147483648 |
use SInt in 65536 * 65536 | 0 | 4294967296 | 4294967296 |
use SInt in 1000000 * 1000000 | -727379968 | 1000000000000 | 1000000000000 |
use SInt in 2 ** 31 | -2147483648 | 2147483648 | 2147483648 |
Now each of these stops, in all three, at a new error, IntegerOverflow ("Error: Integer overflow (an SInt has 32 bits)"). Every SInt operation (sum, difference, product, power, negation, and the one quotient too big, the least SInt divided by −1) checks its result against [−231, 231 − 1]. The interpreter computes the result as a floating-point number first: exact for any two 32-bit operands' sum, and past 253 surely out of range. So the answer no longer depends on the width of the int the interpreter runs on. A value made into an SInt from an Int, a Nat or a Float that does not fit stops at the existing IntegerTooBig, natively too. hazel-jit makes the same checks and stops its run there, for the interpreter's. Seven tests check both agree, values at the edges of 32 bits included (3c9fb4d9ed). Changing the interpreter changes the language, so the interpreter's half is its own PR to dev, hazelgrove/hazel#2828, with tests of its own. Its CI is green; it waits on a review.
Int and Nat cannot overflow (above), and Float follows IEEE 754 in all three.
What stays with the interpreter#
By rule, not as a limit, hazel-jit leaves to the interpreter: any program with a hole (now including a type hole, ? in a type), any program with type errors, and anything the stepper shows. (^ticket(760).) Each is written down at the head of the compiler's source, HazelJit.re.
Holes. Empty holes, multiholes, dynamic error holes and invalid text were already not compiled: the interpreter evaluates around a hole, and its indeterminate result is the point of a hole. Type holes are new, from the merge's sweep. A value passed through ? to a function taking [Int] fails a run-time check when it is a list of floats, and the interpreter shows the failed check. Compiled code has no types to check, and a float and an int are both a JavaScript number, so it cannot tell. No slide writes a type hole. Type errors. The first sweep's 30 ill-typed tests (4 : String, 1 + (4 : String), ...) are programs where the interpreter stops at a failed run-time check. Now the page compiles no program with static errors. Checked on the six slides of the Firefox check, neither rule stopped any slide from compiling. The four slides with compiled runs kept them (a count of 28 against 30 reflects when a run was timed, not a program that stopped compiling):
| Slide | Livelits drawn from the compiled run, build 45 | With the type-error rule (45 + 760) | Build 47, with the type-hole rule | Build 48 |
|---|---|---|---|---|
| Full Body | 30 | 30 | 30 | 30 |
| Hands | 30 | 30 | 28 | 28 |
| Scenes | 36 | 36 | 36 | 36 |
| Witch | 30 | 28 | 30 | 30 |
The stepper's functions, which Matthew asked to have explained. Hazel's stepper shows a program's evaluation one step at a time. Four forms of expression tell it which steps to show: hide P in e (skip the steps matching pattern P), eval P in e (take them without stopping), pause P in e (stop at them), and debug P in e. These are "stepper functions" in the sense Cyrus meant. They only mean something to a run that takes steps, so hazel-jit does not compile them (the reason is "a stepper filter"). Beyond the filters, nothing the stepper shows is drawn from compiled code. The stepper evaluates by the interpreter's own steps, and a livelit inside a probe drawer's stepper, drawn over one of its samples, is now drawn by the interpreter, never from a compiled run's answer (in the code and its tests; not yet checked in a browser).
The other limits, one at a time#
Ranked by the first sweep, the limits most often met were missing builtins, partial application, recursion over more than one name, undefined, and other forms of term. The first three are on the hazel-jit branch, undefined passes CI on its own branch, the other forms pass CI too, and probes are not begun. (^ticket(761).)
- Builtins: 17 the runtime lacked, now as the interpreter has them: string_match, string_replace, string_search, string_join, string_escaped, string_capitalize, string_uncapitalize, omit_all_labels, the six compare builtins (int, sint, nat, float, bool and string), and invert_ord. Since then, string_sub and string_split too (with the string fix below); from_lvs is the one the sweep still finds.
- Partial application,
f(a, _): the function and the given arguments are evaluated first, in order, then a function of the missing ones. - Recursion over more than one name,
let (even, odd) = (fun ..., fun ...): each name assigned once, then the tuple of them. This gives the interpreter's answer whenever every part is a function, since a name is only read when a function runs. Any other part stays with the interpreter. undefined, on its own branch (trial/761-undefined,e62f0a855a): seven sweep programs, and more than that. The List builtins written in Hazel (List.head,List.tailand three others) useundefinedfor an empty list, so every program calling them was not compiled at all. A compiled run that reachesundefinednow stops, as for an invalid operation; one that does not reach it costs nothing. With it the fast checks pass, and all seven programs compile and agree: 250 of the 313 compiled, 223 agreed, none differ (CI run 43899240156). One worry did not come true. Hazel givesundefinedthe hole type, the same as a written?, so the type-hole rule above might have caught it, but in none of these programs does an ascription around it carry the hole. All of CI passes with it (static, fast and full tests).- Tuple extension and labels as values, the six programs the first sweep counted as "this kind of term":
(a=1, b=2) ... (c=3), and label literals handed toproject_labels,select_labelsandomit_labels. Each now compiles as the interpreter defines it, on a branch aboveundefined's (trial/761-labels,1087cdcace). All of CI passes, and with it the sweep compiles 256 of the 313 programs, all agreeing apart from the 27 known ill-typed tests. - Strings beyond ASCII, a parting the sweep could not see, because the evaluator's tests use only ASCII strings. Hazel counts a string's length and offsets in graphemes, the characters a reader sees. hazel-jit counted JavaScript's UTF-16 units, so
string_lengthof an emoji was 2 compiled and 1 in Hazel. Now it counts graphemes, as Hazel does, andstring_subandstring_splitare compiled too. This is on a branch above the label work (trial/761-strings,83f4dba237), with tests on an emoji, an accent written as a separate mark, and a flag, and all of CI passes. - Reverse application,
x |> f, which Hazel holds as an application written the other way round and steps alike: compiled asf(x)is. - Next: labels that are not names, an expression as a module member, the builtin from_lvs. The four fixpoints over a pattern like
_are ill-typed tests, whose interpreter answers are failed casts, so compiling them would only add partings. - Probes are the largest: a probe shows the values that passed through it, and compiled code records none. Today a probe always shows the interpreter's run, which is correct, and never faster. Recording samples from compiled code would mean deciding what a sample is when the code that made it has no steps.
- The sweep's last limits, on their own branch (
trial/761-last-limits,dd85975e96, fast checks green, CI run 44134100041): an explicitly unlabeled entry,(_=e), compiled as the entry itself;from_lvs; a module member that is an expression, evaluated and dropped as the elaborated module'slet _ = eis; and a recursive definition's part that is not a function, when it names none of the names. A tuple label that is a hole,(?=1, 2), counts as a hole now, which the rule keeps with the interpreter. Of the 313 programs, 260 compile, 233 give the interpreter's value, none differ, and 27 are the known ill-typed tests. Four still meet a limit, all ill-typed fixpoints over a pattern that is not a name (fix _ : (),fix (_ : Bool),fix 0andfix ()), left so on purpose. Corrected 2026-11-18: this said the fourth was a recursive definition a finer check could compile; CI, printing each program by name (^report(56)), shows it isfix () -> [], which the compiler counts as a tuple of no names. CI found one thing on the way:let (_=x) = (_=1) in xis(_=1)to the interpreter and1compiled, which the evaluator's own tests count as the same (they ignore explicit unlabelling), and so now does the sweep.
A step budget#
Every compiled function now counts its calls and every 16,384 calls reads the clock. A run past its budget (50 ms or 50 million calls) stops, and the interpreter's run answers. (^ticket(763).) Cyrus's concern is that compiled code runs on the page's own thread, so a Hazel function that never ends would freeze the page. The interpreter has a 20-second timer and a limit of 100 million transitions.
Endless recursion turned out to be the smaller risk: it overflows JavaScript's stack in about a millisecond, and that error is caught like any other. The real risk is a run that ends, but late (fib(45)), and the clock catches that. In Node the counter costs 11 to 26%, and 20 to 33% with the clock (not a build of the app). On the Witch it costs nothing measurable in one run (below), well inside a frame. A cheaper counter, at only the calls that can recur, is the next step.
What it all costs#
On the Witch slide, the changes together are not measurably slower than build 45: over a 3 s drag the page's view took 5.4 to 7.2 ms a frame from build 46 to build 50 (6.5 ms, about 154 fps, on build 50), against build 45's 5.8 (about 172 fps); hazel-jit's own run is 1.1 to 1.7 ms of it. One run each. The spread between single runs (5.4 to 7.3 ms) is as large as any difference, so the numbers show no cost and no gain. On all six slides of the check, build 49 drew the same pictures as the interpreter, with no errors (run 44137800916: 6 slides, 0 differences). Every build stays far inside the 16.7 ms of a 60 fps frame. The fps assumes that updating the state is free: it is what the view alone allows.
The builds are numbered as in ^report(50) to ^report(52). Builds 45 + 757, 45 + 763 and 45 + 760 are each build 45 with one change, measured on its own. Build 46 is the six merged; build 47 adds the type-hole rule; build 48 adds the rest of the limits done since, SInt at 32 bits, and labels named length; build 49 adds the last limits, mixed mode's first step, the timing, the slides' check and the step calibration; build 50 adds the slides' builtins, and is what trial/694-view-jit holds now.
| Build | Commit | Run | When | What it adds | View a frame (drag) | Compiled run a frame | Compiled run at a step | Drawn from the compiled run |
|---|---|---|---|---|---|---|---|---|
| 45 · the base | fc1103900d | 42888678269 | 11-10 | ^report(52)'s last build: the slide's whole run compiled, on trial/694-view-jit. | 5.8 ms (about 172 fps) | 1.3 ms | 4 to 8 ms | 30 |
| 45 + 757 · exact integers | b908b4ed2e | 43763443448 | 11-15 | Int and Nat exact (^ticket(757)), on build 45 and ^ticket(756)'s first step. | 6.6 ms (about 152 fps) | 1.7 ms | 4 to 9 ms | 30 |
| 45 + 763 · a step budget | b81b39f8d4 | 43763439842 | 11-15 | A counter in every compiled function, and a budget around each run (^ticket(763)), on build 45. | 7.3 ms (about 137 fps) | 1.5 ms | 5 to 10 ms | 30 |
| 45 + 760 · no type errors | 1b89af31c5 | 43765797166 | 11-15 | No program with type errors compiled (^ticket(760)), on build 45. | 7.0 ms (about 143 fps) | 1.5 ms | 3 to 6 ms | 28 |
| 46 · the six together | 59f28470c3 | 43792878754 | 11-15 | Tickets 756, 757, 759, 760, 761 and 763 merged on build 45. | 5.4 ms (about 185 fps) | 1.1 ms | 5 to 10 ms | 30 |
| 47 · a type hole is a hole | f4f969588b | 43898636577 | 11-16 | Build 46 and the type-hole rule (^ticket(760)). | 7.2 ms (about 139 fps) | 1.6 ms | 4 to 10 ms | 30 |
| 48 · the limits, SInt, label keys | 30a131a046 | 43949420309 | 11-16 | Build 47 and undefined, tuple extension and the label builtins, strings in graphemes, reverse application (761), SInt at 32 bits (758), and labels named length (765); trial/694-view-jit since 11-16. | 6.1 ms (about 164 fps) | 1.6 ms | 5 to 11 ms | 30 |
| 49 · this morning's branches | 0e56bdbd0a | 44137800916 | 11-17 | Build 48 and the last limits (761), mixed mode's first step (766), the timing and the slides' check (756), the step calibration (767); trial/694-view-jit since 11-17, all of CI green. | 6.8 ms (about 147 fps) | 1.5 ms | 4 to 12 ms | 30 |
| 50 · the slides' builtins | 55e4757a4b | 44319161252 | 11-18 | Build 49 and operators passed as functions, to_lvs, a projection through a list as the interpreter's, and the checks' trail (761, 756); trial/694-view-jit since 11-18. | 6.5 ms (about 154 fps) | 1.7 ms | 5 to 11 ms | 30 |
Found along the way#
Modulo by zero crashed Hazel's interpreter, on dev too; the fix is a PR to dev, hazelgrove/hazel#2825, waiting for review. (^ticket(764).) int_mod, sint_mod, nat_mod and float_mod answered a zero divisor with an error naming a builtin mod that does not exist, so evaluating it raised an exception instead of showing "Error: Divide by Zero". This dates from at least 2025-07-02. Renaming was not enough: the error's inside was then stepped again, and the error was lost. So the fix also makes a builtin's error final, as an operator's already is. CI passes with it.
A Hazel function that declares what it takes but not what it returns costs 5 to 7 times as much a step at run time, in the interpreter. (^ticket(762).) It was measured in a Tarot deck written in Hazel: a step of take cost 0.36 ms with only its argument types, and 0.07 ms with its whole type. Declaring every type made a deal 3.7 times faster. The cause is not unknown types, but where the ascriptions (the run-time type checks) land: on each case arm's result, in each copy of the body, rather than once around it. This is the interpreter's cost, not hazel-jit's, and it is the kind of check Matthew Keenan asked about in ^report(53). The next step is to count the checks per call.
Beyond livelits#
Most of hazel-jit's limits come from one assumption: it compiles a whole program that is closed, finished and well typed, and its answer is only a preview, with the interpreter's run as the real answer. Running any piece of a program in JavaScript breaks each part of that. The direction chosen is a mixed mode: the interpreter keeps running the program and calls compiled functions as it calls a builtin. Matthew Hammer asked on 2026-11-16 what it would take to apply hazel-jit to any fragment of elaborated Hazel, and which of its assumptions stand in the way. Of three ways to go, he chose the third: "I like the mixed mode idea a lot."
What today's design assumes#
- The program is closed. Its only free variables are builtins, and a closure carrying its own environment is not compiled. A slide's run starts from nothing, so this has not mattered. A piece from inside a program has free variables bound to the interpreter's values, closures among them: those must be converted on the way in, and an interpreter closure must either be compiled too or be called back from JavaScript.
- The compiled answer is a preview. The page draws from it, and the interpreter's answer, arriving later, is the program's result. If compiled code gives the result itself, every remaining difference is a wrong answer, and the consistency check becomes a gate.
- Falling back is all or nothing, and costs nothing extra, since the interpreter runs anyway. For a piece of a program, falling back means running it twice, partly in JavaScript and then in the interpreter. That is safe only because evaluation has no side effects.
- The answer's type is known. Converting an answer back needs its type: a Float 1.0 and an Int 1 are the same JavaScript number, and without a type a tuple's labels are guessed from its properties. A view's answer is always Html.
- The inputs are small. Views draw small models, so recursion stays shallow. JavaScript has no tail calls and a stack of thousands to tens of thousands of calls, depending on the browser, where the interpreter keeps its stack on the heap. A
List.mapover 100,000 elements works in the interpreter and overflows compiled; today that falls back, correct but slow. - Three shortcuts are for livelits only: a livelit's model is a parameter, so a slider step does not recompile; each view's answer is collected by its projector; and Html goes straight to the page's DOM without becoming Hazel terms. In general, every edit changes the code, so it is compiled again, and new code starts cold in the JavaScript engine. Compiling is quick (the Witch's largest livelit definition, 62,000 nodes: 6 ms to translate, 9 ms for the browser to parse), but what to cache by, and what to make a parameter, come back as questions.
- The program is finished. Holes, type holes and type errors go to the interpreter by rule (above). A program being edited usually has holes, so compiled code helps only its complete parts. That argues for compiling pieces rather than whole programs.
What is new in the general case#
- Divergence and long runs. The step budget bounds a freeze. But its units are calls and time, not the interpreter's steps, so compiled code may finish where the interpreter would time out, or the reverse. If the same answers include the same timeouts, the limit needs a definition in the language that both count the same way. A piece of a program that draws nothing belongs in the worker, where a long run freezes nothing.
- The boundary costs. Converting values in and out builds Hazel terms and makes new ids.
^report(45)found a livelit's render about 40 times slower with that trip in and out than compiled alone. Small pieces that cross often lose most of the gain, so pieces must be large, or values must stay in JavaScript between calls. - What the interpreter records: probes, the stepper's steps, traces, test results, and the ids that tie a value to the code that made it. Compiled code records none of them. A piece holding a probe or a test, or shown in the stepper, stays with the interpreter.
- Evaluating around holes, Hazel's central feature: a program with holes still runs, and its result holds the holes. Compiled code cannot; it stops.
- Run-time type checks. Where a value passes through the unknown type
?, the interpreter checks it as the program runs; compiled code has no types to check with. Values entering a compiled piece typed?would need checking on the way in. - Every builtin twice. Each of Hazel's builtins written in OCaml has a twin written by hand in JavaScript, and a general compiler meets them all. Looking for this report found one that differed:
string_length(above, now fixed). - Security. Compiled code runs through
new Functionwith the page's full access. For livelits, that is slides we wrote; for any piece of any program, including one opened from a shared link, a bug in how the compiler escapes text would let a program run its own script in the page. A page whose security policy forbidsevalcannot run it at all. - Two implementations to maintain. Every new language feature must either compile or fall back, and the consistency check must cover it.
Three ways to go#
- Whole closed programs, in the worker, with the interpreter as the fallback: close to what we have, without the livelit shortcuts, and unable to freeze the page.
- A fragment interface: compile a closed function whose free variables are typed parameters, convert its inputs once, and keep its values in JavaScript.
- Mixed mode, the one chosen: the interpreter calls compiled functions as it calls builtins, for functions that are complete, free of probes and worth compiling. The first two are steps toward it.
Mixed mode#
Mixed mode keeps the interpreter in charge of the program, so holes, probes and the stepper work as they do now, and gives its complete functions compiled speed. A first step is built (^ticket(766), below). The sketch it follows:
- What is compiled: a function whose body is complete (no hole, type hole or type error), holds no probe, test or stepper filter, and whose free variables are builtins or other compiled functions, with its whole type declared. The declared type converts the answer back.
^ticket(762)found that declaring it also makes the interpreter's own steps 5 to 7 times cheaper. - How it is called: a new kind of value beside a builtin. Applying it converts the argument to JavaScript once, runs the compiled function under the step budget, and converts the answer back by the declared type. It runs in the worker, where the interpreter runs, so a long call freezes no page.
- Falling back, one call at a time: on any stop (the budget, an invalid operation,
undefined, an argument that will not convert because it holds a hole), the interpreter applies the original Hazel function to the same argument. Evaluation has no side effects, so running a call twice is safe. A program with holes elsewhere still runs its complete functions compiled, and the interpreter evaluates around the holes. - Probes and the stepper: putting a probe in a function takes that function out of the compiled set at the next compile, and the rest stay compiled. The stepper either runs on the interpreter alone or shows a compiled call as one step, as it shows a builtin's.
- The boundary: compiled functions call one another directly in JavaScript, without crossing. A large value passed again and again (a list) can be converted once and remembered by the identity of the interpreter's value.
- Checking it: the consistency sweep runs each evaluator test a third way, mixed, and compares with the interpreter alone.
- Where it hooks in: the interpreter applies a builtin through one lookup by name (
Transition.re, inBuiltins.forms_init), and a builtin's answer is a term the interpreter goes on evaluating. So a compiled function can be a builtin made at run time, with no new kind of value. A compiled function bound by aletbecomes such a builtin. When the call finishes, the builtin returns the answer. When it stops, it returns the application of the original Hazel function to the same argument, and the interpreter evaluates that as it would have anyway. The call already shows in a probe's call stack and in the stepper as a builtin's does.
The first step, built on 2026-11-17
Mixed mode's first step is on its own branch, trial/766-mixed, beside the prototype: the interpreter runs the program, and calls each top-level function and module member with its whole type declared as compiled JavaScript. On 0e56bdbd0a (CI run 44137711359, green), the consistency check found 6 evaluator programs with a function to compile (7 functions), and all 6 gave the interpreter's answer; 29 other functions were left to the interpreter because their whole type is not declared, which bears on the question of which functions to compile. Measured on larger programs (below): a recursion compiled whole runs hundreds of times as fast; the Petri net rule 7 times (22 times on the branch's own run, where the interpreter took 463 ms rather than 121: these are single runs, and noisy); the I Ching 5 times, since only 13 of its functions compile so far (its readings call other modules' members, Lines.becomes, which the rewrite does not see yet); and a one-line function called 500 times from interpreted code is slower than not compiling it, each call's crossing costing more than its work.
- Which functions: a let at the top of the program, or a member of a module there, that binds a function whose whole type is declared (
let f : A -> B = fun ...), with no unknown in it. Each is compiled with the functions accepted before it that are in scope there, and the type aliases among them, so it can call them. One that names anything else, an earlier let that is not such a function, is left to the interpreter, and the reason kept. - How the interpreter reaches it: the program is rewritten before it runs. The interpreter still evaluates each such definition to its own closure, then hands the closure to a builtin made at run time, which keeps it and gives back a second builtin, the compiled function. The rest of the program sees that builtin under the function's name. The interpreter's one change is where it looks a builtin up: a table filled at run time, after its fixed one.
- A call: the argument is carried into JavaScript, the compiled function runs under a budget (50 million calls or 1 s), and the answer comes back by the declared result type. On any stop it falls back for that call alone: the interpreter applies its own closure to the same argument, as it would have anyway. An argument holding a hole, an invalid operation, the budget, or an answer that does not carry back each make a fall back.
- Checked: the consistency sweep runs every evaluator test a third way, mixed, against the interpreter alone, and reports how many agree. Hazel-jit's own tests check nine programs: recursion; a call to an earlier function; a hole elsewhere, the function still compiled; a hole in the argument and a division by zero, each falling back; lists and constructors; a whole Float; and a module's members.
- Not yet: no setting in the app, and no hook where the worker evaluates. The stepper shows a compiled call as one builtin step, and the rewritten definitions lose their probes.
| Program | The interpreter alone | Mixed | Rewrite and compile, once | Functions compiled | Calls compiled | Fell back |
|---|---|---|---|---|---|---|
| fib(16), all compiled | 72.6 ms | 0.1 ms | 0.5 ms | 1 | 1 | 0 |
the Petri net rule of ^report(43), whole types declared, 100 events from an interpreted loop | 120.8 ms | 16.8 ms | 5.5 ms | 12 | 112 | 0 |
| the I Ching of hazeljs-oracles, 200 readings from an interpreted loop | 1117.5 ms | 235.0 ms | 3.7 ms | 13 | 7800 | 0 |
| 500 calls of a one-line function (sq) from an interpreted loop | 22.4 ms | 27.9 ms | 0.2 ms | 1 | 500 | 0 |
Build 49 (0e56bdbd0a, CI run 44137711359, Node on GitHub's machines), each program once after a first run, not repeated as the evaluator's programs are; the same answer both ways checked. Not a build of the app.
Step counts and probes, as the interpreter's#
Compiled code can count exactly the steps the interpreter takes, in every program it compiles, with care in three places. With those counts it can make the interpreter's own probe samples, with two limits. Nothing found so far makes either impossible: the costs are a little run time, a tie to the interpreter's internals, and the work. This answers Matthew and Cyrus's two questions of 2026-11-13 (^ticket(767)). Not built yet.
What the interpreter counts. Its count goes up by one at every transition, whichever of its 36 kinds: those that interpret the program (a variable looked up, a let bound, a function applied, an operator, a case, a projection) and those that are bookkeeping (a closure wrapped, parentheses removed, a cast). It goes up one more after each pattern match. The count is the same with or without incremental reuse: a reused result adds the steps it took when it was first computed, so that probe samples stay where they were. Each probe sample is stamped with it: the span of steps from its start to its end.
The counts, measured. For 57 small programs, each a construct apart from the last, the interpreter's count is regular enough to read off (^ticket(767)'s calibration, CI run 44131334098). A literal is a step. An operator or a pair of parentheses adds one. A let adds three of its own: binding, its pattern, and completing the closure around its body. Each level of a simple recursion, if n == 0 then 0 else f(n - 1), adds exactly 16 (18, 34, 50, 66 for f(0) to f(3)). A declared Int -> Int adds one cast step to each call. Some counts need the interpreter's bookkeeping to explain: true && false takes 4 and false && true 3. The whole table:
The 57 programs and their counts
| Program | Steps |
|---|---|
1 | 1 |
1 + 2 | 3 |
1 + 2 + 3 | 5 |
(1) | 2 |
((1)) | 3 |
-1 | 2 |
!true | 2 |
true && false | 4 |
false && true | 3 |
1.0 +. 2.0 | 3 |
"a" ++ "b" | 3 |
let x = 1 in 2 | 5 |
let x = 1 in x | 5 |
let x = 1 in x + x | 7 |
let x = 1 in let y = 2 in x + y | 11 |
let (a, b) = (1, 2) in a | 7 |
fun x -> x | 1 |
(fun x -> x)(1) | 7 |
(fun x -> 1)(2) | 7 |
(fun (x, y) -> x + y)(1, 2) | 11 |
let f = fun x -> x in f(1) | 10 |
let f = fun x -> x in f(f(1)) | 15 |
((fun x -> fun y -> x + y)(1))(2) | 15 |
let f = fun n -> if n == 0 then 0 else f(n - 1) in f(0) | 18 |
let f = fun n -> if n == 0 then 0 else f(n - 1) in f(1) | 34 |
let f = fun n -> if n == 0 then 0 else f(n - 1) in f(2) | 50 |
let f = fun n -> if n == 0 then 0 else f(n - 1) in f(3) | 66 |
if true then 1 else 2 | 3 |
if 1 == 1 then 1 else 2 | 5 |
case 1 | 1 => 2 | _ => 3 end | 5 |
case 2 | 1 => 2 | _ => 3 end | 5 |
case 3 | 1 => 2 | 2 => 3 | _ => 4 end | 5 |
(1, 2) | 4 |
(1 + 1, 2) | 6 |
(a = 1, b = 2) | 6 |
(a = 1, b = 2).a | 8 |
[1, 2] | 3 |
[1 + 1, 2] | 5 |
1 :: [] | 4 |
1 :: 2 :: [] | 6 |
[1] @ [2] | 5 |
Some(1) | 3 |
case Some(1) | Some(x) => x | None => 0 end | 8 |
string_length("ab") | 4 |
string_length("ab") + 1 | 6 |
(1 : Int) | 3 |
let f : Int -> Int = fun x -> x in f(1) | 11 |
let f = fun x : Int -> x in f(1) | 10 |
let f : Int -> Int = fun x -> x in f(f(1)) | 17 |
let xs : [Int] = [1, 2, 3] in xs | 8 |
let f : [Int] -> Int = fun xs -> case xs | [] => 0 | x :: _ => x end in f([1, 2, 3]) | 19 |
type T = + A + B(Int) in B(1) | 3 |
type T = + A + B(Int) in case B(1) | A => 0 | B(n) => n end | 7 |
use SInt in 1 + 2 | 3 |
module M = { let x = 1 } in M.x | 9 |
let x = 1 in (x, x) | 8 |
let f = fun x -> fun y -> x in f(1)(2) | 15 |
Why compiled code can match it. hazel-jit translates the program construct by construct and runs it in the same order as the interpreter: arguments first, left to right. Most constructs take a fixed number of steps of their own, apart from their parts: an operator one; a let one, and one for its pattern; an application one, one for its pattern, and the closure's bookkeeping. So the compiler can add, wherever code runs straight through, the steps the interpreter takes there. That is one addition for each straight run of code, about what today's budget counter costs (^ticket(763)). Then the budget and the interpreter's step limit are one number, in one unit.
Where it needs care: the "if not, why not".
- Casts carried by functions. A function that has passed through a typed boundary carries the cast with it, and each call through it takes the cast's steps too. How many depends on where the function value has been, not on the code that calls it. Compiled code erases types, so its functions would carry the steps their casts cost, as a number on the JavaScript function.
- Casts pushed into code not yet run. A cast around a list or tuple literal is pushed into its parts, and each part then takes steps of its own. This is fixed by the code, so the compiler can follow it, but only by following the interpreter's cast rules exactly.
- The rules live in the interpreter's code, not in a specification. There are 36 kinds of step, the extra step after a pattern match, and steps that rebuild a term and evaluate it again under the same id. Some of this is bookkeeping that changes when the interpreter does: a cast through a whole value became one step, for speed, this autumn. So the counts can be held equal only by checking, as values are. The consistency sweep would compare each evaluator test's count with the interpreter's, and a difference would fail CI.
The programs hazel-jit does not compile at all (holes, stepper filters, tests) stay with the interpreter, counts and all. A question for the team: count every step, or only those that interpret the program? Probe samples' spans are in every step today, so to make the same samples compiled code would count them all.
Probes, given the counts. A sample records where (the expression), when (its span of steps), the value, the variables the probe refers to, and the call stack: for each call, the application, the function's name and where it was defined. Compiled code knows the expression at compile time, the steps with the counts above, and the value and variables as JavaScript values. For the call stack it would keep a stack of its own, a frame pushed and popped at each call, paid for only in a program with probes. The way to share the probe machinery rather than write it twice: compiled code emits the same events the interpreter emits as it runs (a span opened, a call entered, a span closed), at the same steps, and the interpreter's own code turns them into samples.
The two limits. First, a sample's value has to come back as a Hazel value, which needs its type at the probe: elaboration has it. A function value comes back only if hazel-jit made it, and not a recursive one. Second, converting each sample's value and variables is the costly part, so it should happen when the page shows a sample, not at every step. The stepper is another matter: counts say how many steps a compiled call took, but the stepper shows the terms in between, and compiled code has none, so it stays the interpreter's.
The way there. (1) The sweep prints each evaluator test's count from the interpreter beside one from compiled code under these rules: how many match exactly, and where they differ. (2) Casts carried by functions. (3) The budget in steps, as one with the interpreter's limit (^ticket(763)). (4) In mixed mode, a compiled call adds its steps to the interpreter's count, so a program's count is the same mixed or not. (5) Probes: the events from compiled code, checked against the probe tests' samples.
Compiled ahead of time, for older phones#
A third use, now a working prototype: compile a hazeljs app's Hazel when the site is built, and ship the JavaScript, so that an older phone loads neither Hazel's interpreter nor its build of the program, and every call runs compiled. On the older Android phone, the I Ching compiled this way is ready to cast at 0.8 s instead of 3.7 s, and a reading takes under a millisecond instead of 86 to 113 ms. It gives hazeljs's answer on all 8,102 checked, in 33 kB instead of 2.8 MB. Since the oracles' 0.0.13 both of them, the I Ching and the Tarot, run compiled by default: the Tarot's 6,400 deals checked are hazeljs's too, and a Celtic Cross takes 0.008 ms instead of 46, in Node. The idea is Matthew Hammer's, on 2026-11-16, after trying the two hazeljs oracles (an I Ching and a Tarot, whose rules are Hazel run by hazeljs in the page) on an older Android phone in Firefox: painfully slow to draw each card or line, and on each key press in the I Ching's question.
What a page like that costs, measured on a laptop:
- Hazel's library, hazel-lib.js: 2.8 MB of JavaScript (650 kB compressed), 174 ms to load in Node.
- Building the program (parsing, the statics, elaboration), once per page: 621 ms for the I Ching and 499 ms for the Tarot in Node, 0.4 to 0.9 s in the browser.
- Each call, interpreted: a cast 0.4 ms by coins and 1.2 ms by yarrow; a Tarot deal 7 ms for one card, 47 ms for a Celtic Cross, 105 ms for a year ahead.
- Hazel's editor in each listing of the rules: a whole Hazel app, 7.2 MB of JavaScript and about 49 MB of memory, 1.9 s to load empty. The I Ching's page opened five, the Tarot's four.
The editors went first. Since the oracles' 0.0.8, a listing stays text until its button opens the editor, and the I Ching's page, Hazel ready to cast, holds 28 MB. Since 0.0.9, each oracle measures a device's speed and gives a line to compare devices with. The phone's first line, from the I Ching (Firefox 160 on Android, eight cores): Hazel was ready 3.7 s after the page opened, its build of the program 2.9 s of that; a cast took 3 ms by coins and 9 ms by yarrow, a reading 113 ms, and drawing the reading 149 ms to the next frame, since the page asked Hazel for the reading at every redraw. A key press in the question took one frame, 17 ms, with no editor open. The same work in Node on the laptop: the build 600 ms, a cast 0.6 and 1.5 ms, a reading 20 ms, so the phone is about five times slower. In 0.0.10 the I Ching declares every function's whole type (a reading 13 ms on the laptop, the build 480 ms) and asks for the reading once for each set of lines. The phone's line from 0.0.11, still interpreted: the build 2.5 s, a reading 86 ms, and drawing the reading one frame, 17 ms, where it was 149.
Compiling ahead of time would take the rest. hazel-jit would run on the app's Hazel modules when the site is built, and the page would load the compiled JavaScript instead of the library: no build at load, and each call compiled. ^report(50) measured a Petri net rule at 7.19 ms interpreted against 0.011 ms compiled, in Node. Hazel's library and its editor would load only when someone edits the rules, and then the interpreter runs the edited program, as it does now.
The oracles' programs are what hazel-jit compiles best: closed, complete, every function's whole type declared, no probes. So this is the first path above, done before the page loads rather than in it. The prototype, the oracles' 0.0.11, has the four pieces it needs:
- A build step: a test on hazelgrove/hazel's branch
trial/765-iching-aotcompiles the I Ching's program as hazeljs joins it (the preamble, each module asmodule Name = { ... } in, the page's tail) and prints the JavaScript; the oracles'tools/make-compiled.pywraps it, with hazel-jit's runtime from the same commit, intoi-ching/compiled.js. For now the compiler runs in CI, as nothing else builds hazel-jit; inside hazeljs, it would be one call in the site's own build. - Values at the edge: hazel-jit's values in JavaScript are not hazeljs's (a constructor is
{c, v}rather than{tag, value}, a list is a chain of cells rather than an array), so the two exported functions get a small adapter, written from their declared types. - The same answers:
node/compare-compiled.mjsruns both, compiled and hazeljs: every set of six lines with every pattern of changing lines (4,096), the readings of fewer lines, and 4,000 casts by coins and by yarrow. None differs. Three agreement tests in hazel-jit's own CI check the same program against the interpreter. - Saying which engine answered: the page, opened with
?compiled(or by a link under ⚙️ Advanced), says "compiled Hazel" on each line and reading. Editing the rules loads hazeljs and runs them as before.
Compiling the I Ching found a bug in hazel-jit. A labeled tuple, and a module, is a JavaScript array with each label also a property, and the I Ching's Lines module has a member named length: setting an array's length to a function threw, so every compiled call failed. A label that an array already has a use for (length, __proto__) is now kept under another key, the same everywhere hazel-jit writes or reads one (trial/765-label-keys, 30a131a046).
The phone's speed lines, the same work interpreted and compiled (Firefox 160 on Android, one run each; a 0 is below the phone's timer, which Firefox rounds on purpose):
| On the older phone | 0.0.9, interpreted | 0.0.11, interpreted | 0.0.12, compiled |
|---|---|---|---|
| ready to cast | 3.7 s (Hazel at 0.8 s, then a 2.9 s build) | 3.7 s (Hazel at 1.0 to 1.2 s, then a 2.5 to 2.8 s build) | 0.8 s (no library, no build) |
| a cast by coins | 3 ms | 3 to 4 ms | 0 ms (worst 1) |
| a cast by yarrow | 9 ms | 10 to 11 ms | 0 ms (worst 8) |
| a reading | 113 ms | 86 to 93 ms | 0 ms (worst 2) |
| drawing the reading, to the next frame | 149 ms | 17 ms | 16 ms |
| a key press in the question | 17 ms | 17 ms | 16 ms |
The first two lines the phone sent with ?compiled came back interpreted, and the page did not say why: it fell back to hazeljs on any failure of the compiled file, silently. Since 0.0.12 it says so, in the status line and in the speed line, and with the address as ?compiled=1 the phone ran compiled, with no error.
Lists as JavaScript arrays, and holes#
At the edges, arrays make a page’s list cross into compiled code and back in the same few nanoseconds at every size, where cells cost time in the list’s length (62 ms for a million Ints) and today’s jit, through Hazel’s own values, about seventy times that (4.4 s). Inside compiled code, a hybrid (cells for ::, array segments for literals and a page’s arrays) costs about 8% ahead of time and 4% through the jit on ^report(63)’s seventeen games, all answers the same; plain arrays are the wrong shape inside, since Hazel code walks a list through x :: rest and an array copies its tail at every step. Matthew asked on 2026-11-23 to look at JavaScript arrays for lists, in compiled code and in the interpreter’s evaluated lists, with holes in them; and for hazel-jit to run terms with holes, not only finished programs.
054/drivers/lists-bench.mjs). The workloads are what compiled Hazel code does with a list: recursion through x :: rest, building with ::, the builtins, and a page’s array crossing in and out.Every workload at 10, 100 and 1,000 elements
| elements | workload | cells (today) | arrays | hybrid |
|---|---|---|---|---|
| 10 | sum by recursion over x :: rest | 0.041 µs | 0.308 µs | 0.159 µs |
| 10 | map, f(x) :: map(rest) | 0.076 µs | 0.394 µs | 0.181 µs |
| 10 | build with an accumulator, then reverse | 0.064 µs | 0.728 µs | 0.328 µs |
| 10 | length (a builtin) | 0.012 µs | 0.008 µs | 0.008 µs |
| 10 | nth, the middle (a builtin) | 0.008 µs | 0.008 µs | 0.008 µs |
| 10 | nth, the middle, by recursion | 0.029 µs | 0.114 µs | 0.056 µs |
| 10 | a page's array in and back out | 0.052 µs | 0.009 µs | 0.012 µs |
| 10 | a page's array in, mapped, back out | 0.116 µs | 0.416 µs | 0.233 µs |
| 100 | sum by recursion over x :: rest | 1.1 µs | 3.7 µs | 1.4 µs |
| 100 | map, f(x) :: map(rest) | 1.4 µs | 9.3 µs | 1.7 µs |
| 100 | build with an accumulator, then reverse | 2.2 µs | 17.2 µs | 2.6 µs |
| 100 | length (a builtin) | 0.147 µs | 0.008 µs | 0.008 µs |
| 100 | nth, the middle (a builtin) | 0.060 µs | 0.008 µs | 0.008 µs |
| 100 | nth, the middle, by recursion | 0.314 µs | 1.9 µs | 0.403 µs |
| 100 | a page's array in and back out | 0.569 µs | 0.009 µs | 0.012 µs |
| 100 | a page's array in, mapped, back out | 2.1 µs | 10.3 µs | 2.0 µs |
| 1,000 | sum by recursion over x :: rest | 13.6 µs | 273 µs | 15.7 µs |
| 1,000 | map, f(x) :: map(rest) | 15.3 µs | 756 µs | 19.3 µs |
| 1,000 | build with an accumulator, then reverse | 22.9 µs | 1,592 µs | 26.1 µs |
| 1,000 | length (a builtin) | 1.4 µs | 0.008 µs | 0.008 µs |
| 1,000 | nth, the middle (a builtin) | 0.655 µs | 0.008 µs | 0.008 µs |
| 1,000 | nth, the middle, by recursion | 3.4 µs | 222 µs | 4.4 µs |
| 1,000 | a page's array in and back out | 6.1 µs | 0.009 µs | 0.012 µs |
| 1,000 | a page's array in, mapped, back out | 22.3 µs | 758 µs | 21.0 µs |
Measured on the games#
On the seventeen games the hybrid, as prototyped, costs about 8% ahead of time and 4% through the jit (geometric means over 45 operations), from a little faster to half again as slow; every answer the same. Go’s search costs most, about half again (1.46 through the jit, 1.58 ahead of time); the astrology chart, made of long list literals, gains about a quarter, and a Mahjong step a little more. Every head and tail of a list now has one more test, a segment’s tail is a new small object where a cell’s tail is already there, and the two shapes meeting in the same hot loop cost the JavaScript engine more than one shape would. What the hybrid saves, constant-time length and nth and a page’s array passed in with no cells made, these games rarely use: their lists are short, and through the jit every value still crosses through Hazel’s own (^report(63)’s crossing), whatever its shape.
node/package-bench.mjs --no-interpreted (run 45258983579). Each game on its own runner, timed with two builds of the package’s hazel-lib.js one after the other: cells (hazeljs at 3f1d825455) and the hybrid (hazeljs-lists at 46b42696f6, the same with hazel-jit-lists merged). One run each, so a ratio within about a tenth of 1 is within what single runs vary.Every operation, both shapes
| operation | ahead of time, cells | ahead of time, hybrid | ratio | jit, cells | jit, hybrid | ratio |
|---|---|---|---|---|---|---|
| I Ching: a cast by coins | 0.117 µs | 0.115 µs | 0.98 | 5.1 µs | 5.4 µs | 1.05 |
| I Ching: a cast by yarrow | 0.439 µs | 0.428 µs | 0.97 | 5.3 µs | 5.7 µs | 1.07 |
| I Ching: a reading | 2.8 µs | 3.3 µs | 1.19 | 17.7 µs | 18.4 µs | 1.04 |
| Tarot: a deal, One | 0.288 µs | 0.284 µs | 0.99 | 8.3 µs | 8.8 µs | 1.06 |
| Tarot: a deal, CelticCross | 6.9 µs | 7.3 µs | 1.05 | 61.6 µs | 57.4 µs | 0.93 |
| Tarot: a deal, YearAhead | 10.2 µs | 12.1 µs | 1.18 | 82.3 µs | 87.6 µs | 1.06 |
| Astrology: a chart (interpreted: the whole program built each time) | 452 µs | 352 µs | 0.78 | 2,170 µs | 1,643 µs | 0.76 |
| Checkers: the moves | 8.3 µs | 9.5 µs | 1.15 | 18.0 µs | 19.7 µs | 1.09 |
| Checkers: Hazel's move, looking 1 ahead | 16.9 µs | 20.0 µs | 1.18 | 28.8 µs | 30.6 µs | 1.06 |
| Checkers: Hazel's move, looking 2 ahead | 31.2 µs | 36.8 µs | 1.18 | 43.4 µs | 46.2 µs | 1.07 |
| Checkers: Hazel's move, looking 3 ahead | 85.2 µs | 104 µs | 1.22 | 98.3 µs | 104 µs | 1.06 |
| Checkers: Hazel's move, looking 4 ahead | 238 µs | 282 µs | 1.19 | 257 µs | 270 µs | 1.05 |
| Go: a move played | 4.6 µs | 5.5 µs | 1.20 | 61.8 µs | 69.9 µs | 1.13 |
| Go: Hazel's choice of move | 121 µs | 191 µs | 1.58 | 154 µs | 225 µs | 1.46 |
| Go: the score | 145 µs | 198 µs | 1.36 | 198 µs | 272 µs | 1.37 |
| Minesweeper: 9 by 9: the mines laid | 25.7 µs | 29.0 µs | 1.13 | 291 µs | 286 µs | 0.98 |
| Minesweeper: 9 by 9: a cell opened | 9.1 µs | 9.7 µs | 1.07 | 385 µs | 383 µs | 0.99 |
| Minesweeper: 9 by 9: the hint (a sure move) | 34.6 µs | 38.1 µs | 1.10 | 204 µs | 178 µs | 0.87 |
| Minesweeper: 16 by 30: the mines laid | 152 µs | 174 µs | 1.14 | 1,778 µs | 2,351 µs | 1.32 |
| Minesweeper: 16 by 30: a cell opened | 39.1 µs | 39.8 µs | 1.02 | 3,571 µs | 3,626 µs | 1.02 |
| Minesweeper: 16 by 30: the hint (a sure move) | 186 µs | 210 µs | 1.13 | 1,355 µs | 1,116 µs | 0.82 |
| Mahjong: a hand dealt | 54.0 µs | 64.5 µs | 1.20 | 150 µs | 168 µs | 1.11 |
| Mahjong: a step | 3.2 µs | 1.8 µs | 0.57 | 114 µs | 121 µs | 1.06 |
| Mahjong: your options | 8.9 µs | 11.9 µs | 1.35 | 51.4 µs | 56.1 µs | 1.09 |
| Solitaire: a deal | 16.5 µs | 17.0 µs | 1.03 | 196 µs | 207 µs | 1.06 |
| Solitaire: every legal move | 11.2 µs | 13.3 µs | 1.19 | 121 µs | 117 µs | 0.97 |
| Solitaire: a move made | 5.4 µs | 5.3 µs | 0.99 | 264 µs | 270 µs | 1.02 |
| Mahjong solitaire: a deal | 7,959 µs | 9,310 µs | 1.17 | 9,681 µs | 10,872 µs | 1.12 |
| Mahjong solitaire: Hazel's choice of pair | 1.0 µs | 1.3 µs | 1.26 | 755 µs | 576 µs | 0.76 |
| Pinball: a step | 34.6 µs | 38.8 µs | 1.12 | 56.4 µs | 63.4 µs | 1.12 |
| Pinball: a board | 35.2 µs | 36.0 µs | 1.02 | 310 µs | 328 µs | 1.06 |
| Downhill: a step | 6.2 µs | 6.2 µs | 1.00 | 52.0 µs | 51.2 µs | 0.98 |
| Downhill: the robot's choice | 2.3 µs | 2.4 µs | 1.02 | 13.7 µs | 13.2 µs | 0.96 |
| Bricks: a step | 2.3 µs | 2.0 µs | 0.87 | 32.7 µs | 35.5 µs | 1.09 |
| Bricks: the robot's choice | 0.388 µs | 0.289 µs | 0.75 | 11.4 µs | 11.2 µs | 0.98 |
| Snake: a step | 3.9 µs | 4.1 µs | 1.06 | 49.8 µs | 52.0 µs | 1.04 |
| Snake: the robot's choice (42 long) | 161 µs | 175 µs | 1.09 | 141 µs | 156 µs | 1.10 |
| Light trails: a step | 7.0 µs | 7.6 µs | 1.08 | 48.2 µs | 52.7 µs | 1.09 |
| Light trails: the robot's choice, looking 150 | 1,205 µs | 1,220 µs | 1.01 | 1,100 µs | 1,226 µs | 1.11 |
| Star wave: a step | 17.4 µs | 19.2 µs | 1.10 | 97.4 µs | 101 µs | 1.03 |
| Star wave: the robot's choice | 27.6 µs | 31.6 µs | 1.14 | 46.7 µs | 49.3 µs | 1.05 |
| Butterfly garden: a step | 16.6 µs | 16.9 µs | 1.02 | 129 µs | 124 µs | 0.96 |
| Butterfly garden: the robot's choice | 47.7 µs | 53.3 µs | 1.12 | 83.4 µs | 88.0 µs | 1.06 |
| Gnome dig: a step | 26.2 µs | 29.7 µs | 1.13 | 177 µs | 178 µs | 1.00 |
| Gnome dig: the robot's choice | 681 µs | 749 µs | 1.10 | 596 µs | 665 µs | 1.12 |
A page’s list in and back out, at every size#
A list of Ints passed from a page into hazel-jit’s compiled code and back costs 4 ns as an array and 7 ns as a hybrid segment, at every size from 1 to 1,000,000; as cells it costs 6.2 µs at 1,000 and 62 ms at a million; through Hazel’s own values, as today’s jit does it, 1.2 ms and 4.4 s; through the interpreter, 4.5 ms and 8.9 s. A list of records costs the same, about 0.3 s at a million, as arrays, hybrid or cells, unless the records themselves are held the page’s way. Matthew asked for the round trip from the page’s thread into the compiled code and back, for each way of holding a list, at sizes up to a million, plotted against size, on log and on linear scales.
The function is hazel-jit’s own compiled identity, fun (xs : [Int]) -> xs, compiled by the package and called as a page calls it, on the same thread. For each way, the page’s array goes in as that way holds a list, and comes back as an array: as it is (arrays); copied once each way, in case the page changes its array later; as a segment of the same array (the hybrid), with no copy; converted to cells and back, as the games’ ahead-of-time converters do today; and through Hazel.jit and Hazel.run, which make Hazel’s own values on the way. For scale, one pass over the list in compiled code (a map adding 1, over cells) costs 10.6 µs at 1,000 Ints: cells’ crossing is more than half of a pass, today’s jit crossing more than a hundred passes, and an array’s none.
054/drivers/crossing-bench.mjs), with hazeljs 0.0.11 (hazel-lib.js from 98c482395d). Log-log: each step on either axis is ten times the one before.Records are the catch. Compiled code holds a labeled tuple, (x = 1, y = 2), as an array carrying its labels, and a page holds an object, {x: 1, y: 2}, so every record is converted on the way in and out, whatever shape the list has: about 0.3 s for a million, as arrays, the hybrid or cells. Only if compiled code held a record the way a page does would a list of records cross for nothing (the green line, 6 ns). A million records through Hazel’s own values ran the heap past its 2.5 GB, so those two lines stop at 100,000.
(x = Int, y = Int); the green line is a list of records the page’s shape crossing as it is, which compiled code does not do today.Every size and way
| list of | elements | arrays, no conversion | hybrid: cells + array segments | arrays, copied each way | arrays, each record converted | cells (today, ahead of time) | Hazel's values (today's jit) | the interpreter |
|---|---|---|---|---|---|---|---|---|
| Ints | 1 | 2 ns | 3 ns | 18 ns | – | 19 ns | 1.718 µs | 27.567 µs |
| Ints | 10 | 4 ns | 6 ns | 22 ns | – | 48 ns | 11.786 µs | 53.379 µs |
| Ints | 100 | 4 ns | 6 ns | 76 ns | – | 559 ns | 113.515 µs | 379.009 µs |
| Ints | 1,000 | 4 ns | 6 ns | 967 ns | – | 6.159 µs | 1.19 ms | 4.51 ms |
| Ints | 10,000 | 4 ns | 7 ns | 8.568 µs | – | 66.548 µs | 22.6 ms | 54.09 ms |
| Ints | 100,000 | 4 ns | 7 ns | 549.862 µs | – | 2.1 ms | 294.24 ms | 675.31 ms |
| Ints | 1,000,000 | 4 ns | 7 ns | 5.9 ms | – | 61.85 ms | 4.37485 s | 8.91575 s |
| records | 1 | 6 ns | 34 ns | 23 ns | 51 ns | 72 ns | 19.079 µs | 49.933 µs |
| records | 10 | 6 ns | 358 ns | 50 ns | 425 ns | 371 ns | 58.062 µs | 236.793 µs |
| records | 100 | 6 ns | 3.042 µs | 230 ns | 3.897 µs | 4.022 µs | 515.976 µs | 3.6 ms |
| records | 1,000 | 6 ns | 38.551 µs | 2.629 µs | 24.869 µs | 29.013 µs | 7.8 ms | 34.22 ms |
| records | 10,000 | 6 ns | 345.578 µs | 8.27 µs | 483.191 µs | 554.201 µs | 124.11 ms | 362.66 ms |
| records | 100,000 | 6 ns | 23.28 ms | 648.347 µs | 28.93 ms | 28.25 ms | 1.51722 s | 4.10159 s |
| records | 1,000,000 | 6 ns | 270.53 ms | 6.6 ms | 271.47 ms | 334.64 ms | – | – |
Three ways to hold a list#
- Cells, today.
nullfor the empty list,{h, t}forx :: xs. A pattern reads.hand.t, and::makes one cell. Length and nth walk the list, and a page’s array is converted cell by cell on the way in and out. - Arrays. A list is an immutable JavaScript array. Length and nth take constant time and a page’s array crosses as it is, but
x :: xscopiesxs, and so does a pattern’s tail. Hazel code mostly walks and builds lists a cell at a time, so the time grows with the square of the length. - Hybrid. A list is
null, a cell{h, t}, or a segment{a, i}: the elements of the arrayafrom indexion, shared and never changed. A list literal and a page’s array are segments, made with no copy;::makes a cell as today; a pattern on a segment readsa[i], and its tail is the segment fromi + 1. Every operation has one more test than with cells.
Holes in lists#
The interpreter already allows both kinds of hole in a list, and the hybrid has room for both. An element can be indeterminate, [1, ?, 3], and the list is still a list literal. A tail can be indeterminate too, 1 :: ?: an indeterminate cons, which the interpreter’s unboxing keeps apart from literals, since a pattern [a, b] might or might not match it. Plain arrays can hold the first kind and not the second. In the hybrid, an element is any value and a cell’s tail is any value, an indeterminate one included; a pattern that meets one is an indeterminate match. That needs compiled code to carry indeterminate values at all (below).
The interpreter’s evaluated lists#
In the interpreter, arrays would change a lot for little, as far as we can see now. An evaluated list is a list literal holding an OCaml list, which js_of_ocaml makes a chain of cells, the same shape as hazel-jit’s today. Arrays there would make :: and a pattern’s tail cost a copy, unless the interpreter had a hybrid of its own, and about ninety places in the evaluator alone match on list literals and conses (transitions, unboxing, the stepper’s contexts, substitution). The interpreter’s time goes to its rewriting steps more than to its lists’ shape. Where the shape matters is the crossing between the interpreter and compiled code (mixed mode, and the library), and there every element is converted anyway. So: measure that crossing once the compiled side has its hybrid, before changing the interpreter’s lists.
Terms with holes#
Two designs, the second built on the first: fall back to the interpreter for any call that meets a hole, as mixed mode does now; then carry holes through compiled code as indeterminate values that build the interpreter’s residual terms.
- Fall back for the call. Mixed mode, on the
hazel-jitbranch now: the interpreter runs the program around its holes and calls the complete functions compiled, and a call whose argument holds a hole, or that reaches an indeterminate value, is run again by the interpreter, for that call alone. It is correct and built, but a function with a hole in it is never compiled, and a call that meets a hole pays for a compiled try and an interpreted run. - Indeterminate values in compiled code. A hole compiles to a value,
$R.hole(id), that carries what is needed to rebuild its term. Each elimination form checks for one:a + ?gives an indeterminate sum; a case whose scrutinee is indeterminate, where some pattern might match, gives an indeterminate match holding its rules and the values its variables are bound to; applying an indeterminate function gives an indeterminate application. When the answer comes back to the interpreter, these become its residual terms, so the result is the one the interpreter would give. The cost is a check at every elimination form, as the step budget checks at every call, and code to build each residual form. This is what running terms with holes means in full.
Together or apart? Design them together and build them apart. The list’s shape decides where an indeterminate value can sit (an element, a tail), and a cell’s tail is already free to be any value, so holes do not need arrays. Arrays (as the hybrid’s segments) pay at the edges, where a page’s list crosses with no conversion at any size, and cost a little inside, about 8% on these games; how much a program gains is how much of its time is crossing, and for a page that hands Hazel large lists that is most of it. Records must cross for nothing too, or a list of them still costs its length. So the next steps: converters by declared type (the jit’s crossing down to the cells’ line, or to nothing for arrays), records held the page’s way, then indeterminate values; and a sequence type built for splicing, ^ticket(846), beside them.
Where hazel-jit lives#
Matthew, 2026-11-23: the jit should live in as few active PRs as possible, ideally two, both meant for dev: one tracking the jit alone, and its integration into the one npm package branch. The jit-only PR is hazelgrove/hazel#2859 (branch hazel-jit, from dev, on Jane Street Core): the compiler, its value boundary and mixed mode, with the agreement tests and the evaluator tests’ sweep. The package’s PR, #2857, merges that branch (since 3f1d825455) rather than carrying a copy. The livelits line keeps its own hazel-jit (#2817, and the build of #2819), with the livelit views, on the same compiler. Moving the jit to dev found two things the livelits line hides: dev keeps both entries of a tuple with a label given twice, which compiled code cannot (so such a tuple is left to the interpreter), and dev’s statics lower a module to lets whose patterns lose their type annotations, so mixed mode finds no declared type for a module’s members and runs them on the interpreter, for now.
Records the page’s way#
Held as a page holds it, an object by its labels, a record would cross into compiled code and back for nothing, and compiled code would build one about 12 times as fast and compare two by their type 3.4 times as fast; reading a field by its label costs the same. It takes five decisions, listed below. The first two are the design: which tuples become objects, and how code that does not know a value’s type tells a record from a list’s cell or a constructor; the third, how a pattern by position reads a record, the statics mostly settle already. This is ^ticket(847), from the crossing above, where a million records cost about 0.2 s to cross however the list is held, and Matthew asked, 2026-11-24, that publishing the package wait until these questions of representation are settled. Today compiled code holds (x = 1, y = 2) as the array [1, 2] with .x and .y added to it, and a page holds {x: 1, y: 2}; the converters make one from the other on every call.
| in compiled code | today: an array carrying its labels | the page’s object | how |
|---|---|---|---|
| make a record of four fields | 49.7 ns | 4.0 ns | an object literal, against the runtime’s tup adding each label to an array |
| a new record with one field changed | 52.5 ns | 5.0 ns | as a literal; 13.2 ns by spread, {...r, x} |
| read a field by its label | 1.1 ns | 0.9 ns | the same |
| read a field by its position | 1.2 ns | 68.4 ns | through Object.values; 1.0 ns with the label at that position from the type |
| compare two equal records | 25.6 ns | 84.7 ns | by their own keys; 7.6 ns by the type’s fields, a comparison made from the type |
| a million records into compiled code and back | 173 ms | nothing | 3.8 ms with each field’s type checked, no copy |
| a list of 1,000 cells built | 4.9 µs | 5.5 µs | cells made by a class, so a plain object is a record; 6.2 µs as literals {$h, $t}, 37 µs as literals with a prototype |
| the same list walked | 4.8 µs | 4.4 µs | 5.4 µs testing instanceof at each cell; 4.4 µs as {$h, $t} |
Not a build of the app: Node v22.23.2 on the laptop (13th Gen Intel(R) Core(TM) i7-1370P), JavaScript alone, written as hazel-jit’s runtime and compiled code do it today and as they would (054/drivers/records-bench.mjs); each the median of batches, and the list’s cells in five rounds, each round in a different order, the median of the rounds.
What it would change in the games#
Records are most of what crosses in some games and little in others: 97% of the nodes of a Minesweeper state (its 480 cells), 90% of Butterfly garden’s, 38% of Mahjong solitaire’s. The rest are lists, which still convert, cell by cell, until a list crosses as an array (^ticket(846), a sequence type beside List). ^report(63) timed what the crossing costs on each game’s own run: with nothing remembered, an expert Minesweeper tap took 0.31 ms through the jit, against 19 µs when the page hands back the jit’s own state. Most of that copy is the board’s records.
| a state of | records | constructors | arrays (lists, or tuples without labels) | records, of these nodes |
|---|---|---|---|---|
| Downhill | 1 | 0 | 0 | 100% |
| Minesweeper | 481 | 0 | 17 | 97% |
| Butterfly garden | 27 | 0 | 3 | 90% |
| Gnome dig | 11 | 0 | 4 | 73% |
| Checkers | 1 | 0 | 1 | 50% |
| Bricks | 1 | 0 | 1 | 50% |
| Snake | 1 | 0 | 1 | 50% |
| Light trails | 1 | 0 | 1 | 50% |
| Solitaire | 60 | 52 | 22 | 45% |
| Mahjong solitaire | 361 | 0 | 579 | 38% |
| Pinball | 1 | 0 | 2 | 33% |
| Star wave | 1 | 0 | 3 | 25% |
| Mahjong | 5 | 0 | 17 | 23% |
| Go | 1 | 0 | 10 | 9% |
Each game’s state as a page holds it, made by its compiled rules (hazeljs-examples 66cbf53), its nodes counted by kind (054/drivers/game-shapes.mjs). A page cannot tell a list from a tuple without labels: both are arrays.
Five decisions#
All five are decided. Matthew chose A for the first (below) and took our leans on the other four (2026-11-24: “Yes, take the leans”), and each is done on the trial branch, as its last sentence says.
- Which tuples become objects? A tuple whose every entry is labeled becomes an object, its keys in its type’s order. A tuple with no labels stays an array. A tuple with some labels stays an array carrying them, as today, since an object puts a number key (a position) ahead of every label and would lose the order. When a tuple’s type is known, the statics already put its entries in the type’s order and add the labels it left out (
LabeledTuple.rearrange, in the elaboration of a tuple against a product type). Our lean: so. Tried on 2026-11-24, at Matthew’s ask, with the two other ideas; Matthew chose A, with field reads in place: below. - Telling a record from a cell or a constructor. Some of compiled code does not know a value’s type and looks at its shape: the runtime’s projection (which also takes a column from a list of rows), its equality, the label builtins, and the value boundary’s untyped way. Today a cell is
{h, t}and a constructor{c, v}, and the runtime tests one key,"h" in vfor a cell and"c" in vfor a constructor, so a record with a fieldh(a height) orc(a column) would be taken for one. Options: (a) cells and constructors made by classes, told apart withinstanceof: about 0.7 ns more for each cell built, and a walk costs the same; (b) their fields named$h,$t,$cand$v, still plain literals: no record has a key beginning with$, since such a label is already kept under"$" ++ label; (c) no shape test at all: equality, projection and the label builtins made from the type, as the converters are. Equality made from the type took 7.6 ns, against 25.6 ns today. Either (a) or (b) changes the games’ ahead-of-time files, whose converters, written by hand, build{h, t}and{c, v}, unless those files take generated converters (^report(63), What next). Our lean: (c) wherever the type is at hand, and (b) for the rest. Done, as leaned: compiled code’s cells are now{$h, $t}and its constructors{$c, $v}, so one key tells them from a record wherever the type is not at hand: the runtime’s projection, equality and label builtins, and the value boundary’s untyped reading and its diff. Where the type is at hand, the converters and the boundary go by it, as before. A record(h = 1, t = 2)or(c = "Lt"), which was taken for a cell or a constructor, now gives the interpreter’s answers, in tests. The games ran as fast as before (the table below is this build). What a page sees does not change; a page that keeps compiled code, as hazeljs-examples’compiled.jsfiles do, needs its hand-written converters changed when it is next compiled. - A pattern by position against a record. Mostly settled already: when the matched type is labeled, the statics add its labels to a pattern by position (
MatchedTyp.prod), so compiled code readslet (a, b) = rasr["x"]andr["y"], checked on the package’s compiled output for a declared function, acaseand an undeclared literal. Only an unknown or unlabeled matched type leaves the pattern by position, and there compiled code readsr[0], which an object does not have. Checking this found a disagreement today:let f = fun r -> let (a, b) = r in a - b in f((x = 5, y = 2))is stuck in the interpreter, which bindsato the labeled entryx = 5, while the jit answers 3 (^ticket(851)). Options for that case: (a) compiled code checks that the entry at the position has no label, and a run that meets one goes to the interpreter, as hazel-jit’s rule for anything indeterminate has it; with records as objects the check isArray.isArray; (b) a fallback throughObject.values, 68.4 ns a read against 1.2 ns, which would repeat today’s disagreement. Our lean: (a), which fixes^ticket(851)either way. Settled: (a), by^ticket(851)for arrays and the trial’s check for records. - What a page may do with an object. If compiled code keeps the page’s own object, a page that changes it afterwards changes a Hazel value, and Hazel’s values never change. The converters’ memory already assumes the page will not (“the rule for a page”, in the converters’ comment in
HazelLibCore.re), and the same goes for a record the page gets back. Options: (a) state the rule, as React does for its state: what a page gives Hazel, or gets from it, it does not change; (b) freeze what crosses (Object.freeze), at least in a development build; (c) copy at the edge, which gives back most of the crossing’s cost. Our lean: (a), with (b) in development. Done, as leaned: the rule is stated in the library (what a page gives a compiled function, or gets back, it does not change afterwards), andHazel.development(true)freezes both, all the way down, so a page that breaks the rule fails where it does; off, it costs one check a call. Its test found that a function of a tuple called with the entries spread,f(1, xs), went the old way on every call, because its declared parameter’s parentheses hid the tuple; fixed, and the test calls both ways. - Checking at the edge. A page may hand over
{x: 1.5}where the type says Int. Today’s converters check each field, and a call whose value does not fit goes the old way. One pass of checks and no copy cost 3.8 ms for a million records; trusting the page costs nothing. Our lean: check, as now. Kept: checking, as now.
Decision 1: A, with field reads in place#
Matthew chose A on 2026-11-24 (“A, add direct reads”): a tuple whose every entry is labeled is a plain JavaScript object, and a field read g.x compiles to the property itself. As the games play, A now takes 0.63 of today’s time (the geometric mean over 14 games), and 0.62 of it when every argument is a fresh copy. The best are Mahjong solitaire 0.27×, Pinball 0.29×, Minesweeper 0.46×. Every answer is the same as today’s. Three ideas were tried first, at Matthew’s ask (“for decision 1 -- try the first 3 best ideas (or 2 best) --- and report back”): A; B, any tuple with a label an object; and C, today’s arrays carrying their labels. B is A on every game. A alone was about even with today, for the reasons below, and the two changes here mend them.
| a call, on the game’s own run, as the page plays | C, today | C, reads in place (simulated) | A, reads in place | A over C | A over C with reads | A over C, every argument a fresh copy |
|---|---|---|---|---|---|---|
| Mahjong solitaire | 64.9 µs | 50.9 µs | 17.8 µs | 0.27× | 0.35× | 0.75× |
| Pinball | 51.8 µs | 22.5 µs | 15.0 µs | 0.29× | 0.67× | 0.28× |
| Minesweeper | 23.7 µs | 13.7 µs | 10.8 µs | 0.46× | 0.79× | 0.19× |
| Butterfly garden | 5.8 µs | 6.0 µs | 2.8 µs | 0.49× | 0.47× | 0.33× |
| Solitaire | 13.3 µs | 8.1 µs | 7.1 µs | 0.54× | 0.88× | 1.01× |
| Downhill | 9.6 µs | 7.9 µs | 5.7 µs | 0.59× | 0.71× | 0.57× |
| Mahjong | 20.0 µs | 14.4 µs | 12.5 µs | 0.62× | 0.87× | 0.61× |
| Bricks | 4.2 µs | 4.2 µs | 2.7 µs | 0.63× | 0.64× | 0.63× |
| Gnome dig | 36.6 µs | 38.6 µs | 27.4 µs | 0.75× | 0.71× | 0.76× |
| Go | 28.7 µs | 22.2 µs | 22.4 µs | 0.78× | 1.01× | 0.95× |
| Checkers | 24.8 µs | 20.7 µs | 20.2 µs | 0.82× | 0.98× | 0.89× |
| Star wave | 11.6 µs | 12.9 µs | 10.8 µs | 0.93× | 0.84× | 0.87× |
| Snake | 3.0 µs | 3.1 µs | 2.8 µs | 0.95× | 0.91× | 0.90× |
| Light trails | 8.0 µs | 7.7 µs | 13.0 µs | 1.62× | 1.67× | 0.87× |
| all 14 (geometric mean) | 0.63× | 0.77× | 0.62× |
Three builds, each game on its own GitHub runner, one after another (hazeljs-examples bench/847-direct, run 45532448010; 054/drivers/package-bench-847-direct.yml, with 054/drivers/package-bench-847.mjs, --runs --aot-as-is --no-interp). A: hazelgrove/hazel trial/847-records-objects at f311f4e408 (with decisions 2 and 4), CI green. C: hazeljs 0.0.12 (ec2a330996). C, reads in place: 0.0.12 with its compiled code’s field reads rewritten as A’s compiler writes them (054/drivers/direct-sim.mjs); only reads of a variable are rewritten, so it gives C a little less than the compiler would. Each game’s run is recorded once and replayed, every call given the state the last answered; a call’s time is the run’s calls summed over their number. The jit took 0.48 of the games’ own ahead-of-time files’ time with A, and 0.76 with C.
- Field reads in place. Before,
g.xcompiled to a call,$R.dot(g, "x"), which read the field by a key it was given: one place in the runtime reading every label of every program, a read the engine cannot cache, and for an object it also askedhasOwnProperty. Nowg.xcompiles tog["x"]behind a check thatgis an object holdingxand not a list’s cell, and the engine caches that read by the record’s shape. Anything else still goes to$R.dot, so the answer is the same: a list of rows (a table’s column), the empty list, or something the interpreter would be stuck on. Today’s arrays gain from this too: C with the same reads takes 0.81 of C’s time, and A takes 0.77 of that, so holding records as objects is worth that much on its own. - Equality kept small. Go was still slower with A after the reads: 1.11 times C with reads, on GitHub. Hazel’s
==on Ints compiles to the runtime’seq, and Go’s membership tests compare Ints all the time. A had added a record’s case toeq, which made it too big for the engine to inline where it is called. With the objects’ cases moved into a second function,eqo, Go’s run on the laptop went from 1.15 times today’s to 0.96. - The other fix, not made. The first trial suggested a second change: plain records under a list that comes back unchanged would skip their checks. Profiled on Minesweeper with the reads in place, those checks are 0.6% of the time. The converters’ links on the way out are 8.5%. So it was not worth making.
- Where A is still slower: Light trails 1.62×. We read that as noise. Light trails’ run is 22 frames, about 0.2 ms in all, and the games’ own ahead-of-time file, the same code in all three runs on the runner, took from 0.18 ms to 0.28 ms. On the laptop, with the reads simulated on both (an earlier A, with the smaller equality), A and C took the same time on it: 0.124 and 0.128 ms, then 0.158 and 0.160 ms, in two runs.
The three ideas, before the reads#
As a page plays, A alone was about even with today (1.01 of its time over 14 games), 0.86 of it when no memo helps, and a page’s list of new records crossed 6.8 to 24 times as fast; every answer the same. B, any labeled tuple an object, is A on every game: none of them makes a tuple with some entries labeled and others not.
- B against A: nothing to tell them apart. Counted in the games’ runs (the ahead-of-time runtime’s
tupcounting each labeled tuple it makes), the fourteen games make about 565,000 labeled tuples and not one with only some entries labeled; Hazel’s own tests have one, in hazel-jit’s “an extension replacing a label”,(a=1, 3, c=4). B would need keys for the unlabeled entries ($1) and reads by position that find them, for a case nothing uses, so it was not built. - A, built. hazelgrove/hazel
trial/847-records-objects(off #2857, ec2a330996; all CI green at 2aa0b9b451): compiled code writes such a tuple as an object literal; the runtime’stup, projection, labels, extension, equality and the label builtins read and make records; a pattern by position that meets one stops for the interpreter (as^ticket(851)has it for arrays); the value boundary writes a record as an object and reads one back (by its type, or by its shape: a list’s cell is exactlyhandt, a constructorcand perhapsv); the converters pass a record of plain values (numbers, booleans, strings) through as the page’s own object, checked, with no copy and no memo, and make a new object of any other. The games found one thing the tests had not: a program’s functions come back in its tail, now a record, and only an array’s were given their converters, so every game’s step ran on the interpreter; fixed, with a test.
| a call, on the game’s own run | C, as the page plays | A | A over C | C, every argument a fresh copy | A | A over C |
|---|---|---|---|---|---|---|
| Mahjong solitaire | 64.3 µs | 42.6 µs | 0.66× | 403 µs | 333 µs | 0.83× |
| Bricks | 5.2 µs | 4.5 µs | 0.87× | 7.0 µs | 5.6 µs | 0.80× |
| Mahjong | 21.3 µs | 18.7 µs | 0.87× | 47.9 µs | 31.5 µs | 0.66× |
| Butterfly garden | 5.8 µs | 5.1 µs | 0.88× | 15.5 µs | 7.3 µs | 0.47× |
| Downhill | 8.7 µs | 8.0 µs | 0.91× | 9.1 µs | 7.9 µs | 0.87× |
| Snake | 3.7 µs | 3.6 µs | 0.96× | 2.7 µs | 2.7 µs | 1.03× |
| Gnome dig | 40.7 µs | 39.4 µs | 0.97× | 56.1 µs | 48.4 µs | 0.86× |
| Checkers | 21.8 µs | 21.8 µs | 1.00× | 17.5 µs | 19.9 µs | 1.14× |
| Star wave | 15.6 µs | 16.1 µs | 1.03× | 19.2 µs | 17.4 µs | 0.91× |
| Light trails | 5.7 µs | 6.5 µs | 1.13× | 5.5 µs | 5.6 µs | 1.01× |
| Go | 20.0 µs | 24.1 µs | 1.21× | 20.6 µs | 25.2 µs | 1.23× |
| Solitaire | 8.6 µs | 10.6 µs | 1.24× | 41.5 µs | 48.4 µs | 1.17× |
| Pinball | 32.1 µs | 41.1 µs | 1.28× | 29.5 µs | 41.3 µs | 1.40× |
| Minesweeper | 17.3 µs | 23.8 µs | 1.38× | 147 µs | 50.4 µs | 0.34× |
A at 2aa0b9b451, before the reads, and C (hazeljs 0.0.12), each game on its own GitHub runner, C’s run then A’s on the same machine (hazeljs-examples bench/847-a-vs-c, run 45498058581; the driver 054/drivers/package-bench-847.mjs, --runs --aot-as-is --no-interp): each game’s run recorded once and replayed, every call given the state the last answered; a call’s time is the run’s calls summed over their number. Both against the games’ own ahead-of-time files as the reference for the answers: the jit took 0.75 of their time with A and 0.75 with C.
- Where A wins: Mahjong solitaire 0.66×, Bricks 0.87×, Mahjong 0.87× as the page plays; with every argument a fresh copy, Minesweeper 0.34×, Butterfly garden 0.47×, Mahjong 0.66×: a record of plain values crosses with one pass of checks, where C converts it into an array and back.
- Where A lost: Minesweeper 1.38×, Pinball 1.28×, Solitaire 1.24×, Go 1.21×. Two costs were suspected. Every projection,
g.x, was a call to the runtime’sdot, which for an object also askedhasOwnProperty, where an array went straight tot[k]; Pinball’s physics projects all the time. And a record of plain values handed back was checked field by field each call, where C’s memo found it in one lookup; Minesweeper’s board is 480 such records. The first was the cost, and reads in place mend it (above); the second turned out small.
| records in the list | C, new records | A, new records | A as fast | C, the same list again | A, again |
|---|---|---|---|---|---|
| 1 | 1.3 µs | 0.8 µs | 1.6× | 0.3 µs | 0.3 µs |
| 10 | 6.5 µs | 1.7 µs | 3.9× | 0.3 µs | 0.3 µs |
| 100 | 39.5 µs | 5.9 µs | 6.6× | 0.3 µs | 0.2 µs |
| 1,000 | 0.22 ms | 9.4 µs | 23.6× | 0.2 µs | 0.2 µs |
| 10,000 | 2.40 ms | 99.8 µs | 24.1× | 0.2 µs | 0.2 µs |
| 100,000 | 45 ms | 1.84 ms | 24.3× | 0.2 µs | 0.2 µs |
| 1,000,000 | 458 ms | 67 ms | 6.8× | 0.3 µs | 0.2 µs |
Not a build of the app: the laptop, Node v22.23.2, a page’s list of records (x = Int, y = Int) into Hazel.jit’s compiled identity and out (054/drivers/records-cross.mjs), hazeljs 0.0.12 for C and the trial’s library for A, one process each; new records made off the clock for each call, or the same list handed back. At a million, A’s 67 ms (C’s 458 ms) is mostly the list itself, still converted cell by cell until a list crosses as an array (^ticket(846)). Summing a field over the list in compiled code took the same time either way.
The interpreter does not change. Its record stays a labeled tuple of terms; only the value boundary (HazelJitValue, both ways) and the converters learn the new shapes. Merged on Matthew’s word (2026-11-24, “Yes, merge it”): the jit’s side is on hazel-jit (#2859, 9ec865976d), and the package’s on hazeljs (#2857, 20febee548), which merges hazel-jit; the package branch’s tree is the trial’s. Next: a package whose compiled output changes shape (records as objects, cells and constructors keyed with $), with its CHANGELOG saying what a page that keeps compiled code must change, and the npm publish this ticket held.
A sequence beside List#
A sequence held as a treap over views of JavaScript arrays inserts one element anywhere in 706 ns to 1.6 µs, from 1,000 elements to 1,000,000, appends one in at most 273 ns, and takes a page’s array in and out for nothing; an array copied on every edit takes 15.0 ms to insert one at a million, and cells 35.3 ms. Its costs: reading one element by position takes up to 469 ns, where an array takes tens of nanoseconds, and walking a million after twenty thousand edits takes 3.1 ms, about as long as cells (3.2 ms) and five times an array (593.0 µs). This is ^ticket(846), which Matthew asked for on 2026-11-23: “explore a new builtin sequence type, as complement to List --- Sequence or Seq, for short maybe?”, held as a balanced tree with arrays at its leaves. What matters most to him is a balance that needs no rebalancing, the levels fixing the shape so that an edit never rotates; the caching a content-determined shape allows matters less, so a level may come from any well-spread source.
How it is held. A leaf is a view of an array that is never changed: the array and a start and an end, so that splitting a leaf is two views of the same array and copies nothing. A page’s array is one leaf over it. Between two leaves is a gap with a priority, drawn here from a counter’s hash, and the tree is the one the priorities determine, the highest at the root, as in fumola’s level tree (Pugh and Teitelbaum’s), where a gap’s level comes from its symbol. An insert splits the tree at the position and joins the three parts; a join puts the higher priority on top and never rotates. A leaf of fewer than 32 elements that meets another sequence goes into the leaf at its edge when the two fit in 32: a copy of at most 32 elements, and no new gap, so the shape stays the priorities’. Every edit gives a new sequence and leaves the old one whole, as a Hazel value must, and so do the other three ways here.
| held as | insert one, anywhere | append one | read one, anywhere | walk them all | a page’s array in and out |
|---|---|---|---|---|---|
| 1,000 elements | |||||
| a treap over array views (82 leaves, depth 14) | 706 ns | 163 ns | 85 ns | 1.8 µs | 16 ns |
| an array, copied | 2.9 µs | 1.4 µs | 26 ns | 656 ns | 4 ns |
| cells, today | 4.0 µs | 8.5 µs | 782 ns | 1.7 µs | 10.3 µs |
| the hybrid | 7.7 µs | 26.0 µs | 793 ns | 2.1 µs | 15 ns |
| Immutable.js’s List | 39.0 µs | 121 ns | 41 ns | 25.3 µs | 49.6 µs |
list, funkia’s | 4.9 µs | 41 ns | 48 ns | 7.2 µs | 21.4 µs |
| 10,000 elements | |||||
| a treap over array views (830 leaves, depth 27) | 884 ns | 211 ns | 126 ns | 20.9 µs | 20 ns |
| an array, copied | 25.2 µs | 11.6 µs | 28 ns | 5.4 µs | 17 ns |
| cells, today | 45.9 µs | 100.2 µs | 13.6 µs | 23.4 µs | 75.6 µs |
| the hybrid | 64.7 µs | 192.5 µs | 22.6 µs | 43.2 µs | 23 ns |
| Immutable.js’s List | 419.8 µs | 126 ns | 40 ns | 212.1 µs | 534.4 µs |
list, funkia’s | 3.4 µs | 47 ns | 56 ns | 70.8 µs | 258.0 µs |
| 100,000 elements | |||||
| a treap over array views (8,410 leaves, depth 30) | 1.3 µs | 227 ns | 262 ns | 385.4 µs | 19 ns |
| an array, copied | 1.1 ms | 748.3 µs | 29 ns | 65.4 µs | 16 ns |
| cells, today | 1.0 ms | 2.8 ms | 100.5 µs | 222.9 µs | 3.0 ms |
| the hybrid (one segment) | 1.1 ms | 3.0 ms | 29 ns | 65.3 µs | 17 ns |
| Immutable.js’s List | 5.3 ms | 121 ns | 54 ns | 2.9 ms | 8.1 ms |
list, funkia’s | 4.1 µs | 87 ns | 83 ns | 685.7 µs | 2.9 ms |
| 1,000,000 elements | |||||
| a treap over array views (31,564 leaves, depth 37) | 1.6 µs | 273 ns | 469 ns | 3.1 ms | 20 ns |
| an array, copied | 15.0 ms | 8.9 ms | 45 ns | 593.0 µs | 17 ns |
| cells, today | 35.3 ms | 74.8 ms | 1.3 ms | 3.2 ms | 72.5 ms |
| the hybrid (one segment) | 34.4 ms | 107.1 ms | 55 ns | 684.3 µs | 18 ns |
| Immutable.js’s List | 52.0 ms | 183 ns | 95 ns | 24.2 ms | 77.7 ms |
list, funkia’s | 5.6 µs | 82 ns | 161 ns | 6.3 ms | 39.4 ms |
Not a build of the app: Node v22.23.2 on the laptop, JavaScript alone (054/drivers/seq-bench.mjs), each the median of batches. Before timing, every way made the same 2,000 random edits to one sequence and came out the same. The treap, and the hybrid up to 10,000, were timed after a tenth of their size in inserts at random places (at most 20,000), so the treap has many leaves; an array and cells have one shape however they are made. At a million the treap had 31,564 leaves and depth 37.
- JavaScript’s own candidates. JavaScript has no persistent sequence built in; the known libraries are Immutable.js’s List (a trie of 32-element arrays) and
@funkia/list(a relaxed radix-balanced tree), installed from npm with Matthew’s OK. Immutable.js’s List (5.0.3) appends as fast as the treap (183 ns at a million) and reads by position faster (95 ns), but its insert copies, as an array’s does: 39.0 µs at 1,000 and 52.0 ms at a million; a walk takes 24.2 ms, and a page’s array in and out 77.7 ms, since it copies the array into its trie.@funkia/list0.1.0, the newest release under that name (2018), threw inside its own concat, which an insert is built from (it has no insert of its own): after 88 edits: Cannot read properties of undefined (reading 'array'). Its maintained releases are published asliston npm, a different package, installed with Matthew’s OK too.list(2.0.19) passed the same 2,000 edits, and is the strongest of the three: an insert anywhere in 3.4 µs to 5.6 µs at every size (the treap’s grows as slowly, at a third to a seventh of that), an append in 82 ns and a read by position in 161 ns at a million (both faster than the treap’s), a walk in 6.3 ms (twice the treap’s). What it lacks is the crossing: a page’s array is copied into its tree and out again, 39.4 ms at a million, where the treap takes the array itself as a leaf. - How a Seq would enter Hazel. A builtin type beside List with its own operations (length, nth, splice, append, and conversions to and from List); in compiled code, the treap and its runtime; at the page’s edge, an array as one leaf, no conversion, under the same rule as records: a page does not change an array it gave Hazel. The interpreter would hold it as a builtin value too. These are questions for the team, after the records’ decisions, since the two share the rule at the edge.
What a closure keeps#
Nothing on dev trims an environment. A function value keeps the whole environment it was made in, used or not. A function needs only its free variables, and the statics already know them for every expression, so trimming is possible. dev’s empty holes keep no environment at all, so today they are no exception to it. Compiled code already trims: a compiled function holds only what it captures, and crosses back to the interpreter holding only that.
Matthew asked, 2026-11-23: "is there any aspect of dev that trims Hazel values' environments to only contain relevant values? For empty holes, the whole env is required, perhaps -- but for other terms, esp closed terms, the env can be dropped. We experimented with this as a performance PR, IIRC, but I don't recall the exact context of that work."
An example#
Take let big = [1, 2, …, 10000] in let inc = fun x -> x + 1 in inc. The value of inc is a closure: the function, with the environment it was made in, and that environment binds big. inc never reads big, but its value holds it. Holding it costs nothing when the closure is made. An environment is a chain of bindings, shared, so a closure points at the chain and copies nothing. The cost comes later, from whatever walks a value: finishing a result, sending it from the worker to the page, or converting it for a page.
What dev does#
- A function keeps the whole environment. The interpreter’s rule for a function (
Transition.re) wraps it asClosure(env, fun …)with the current environment, whole. A recursive function’s fixpoint keeps it whole too (FixF(p, body, Some(env))). So do the indeterminate forms that need their environment later, such as anifwhose condition is a hole, or a free variable. - An empty hole keeps none. The rule for an empty hole leaves its closure out; the line that would add it is commented out, marked “uncomment for hole closures”. So on
deva hole is not shown with its environment, and nothing fills a hole and resumes from it. - Incremental evaluation reads only the free variables. hazelgrove/hazel#2222, “Incremental evaluation”, reuses a term’s last value when its free variables’ values have not changed, and it looks up only those: the term’s co-context, from the statics (
IncrEval.restrict_to_co_ctx). That is the trimmed environment, used to decide a reuse. Values do not keep it. - Finishing a result writes the environment into the body.
Substitution.in_expreplaces each variable with its value, so a finished value mentions only what it uses. It gets there by copying, though: each function a function calls is copied in, at every level.
Where it was tried#
The change you remember is most likely Andrew’s. It drops environments from a result, rather than trimming them, and it is on the modular editors line, not on dev.
- Andrew, 2026-08-28: “Result pipeline: cap giant values (env prune + display budget)” (commit cea1f2ef29, on hazelgrove/hazel#2469, “Modular editors”, and so on #2635). On a 1,000-line program whose value is a module, the worker’s message carried closure environments of 18 MB, and decoding it stalled the page for seconds. The worker now sends the result with every closure’s environment replaced by an empty one. It replaces each environment before walking into it, so it never visits the shared, program-sized one. The result display never shows an environment, and the stepper evaluates again from the elaborated term, so nothing shown changes.
- Andrew, open: “Show stuck results without inlining callees at every level” (#2684). A result’s functions are written out once, and the functions they call stay as names. On a stuck program of about 100 lines, the result goes from 67,000 terms to 6,300, from 3.8 MB to 0.42 MB, and from 515 ms to 61 ms.
- Ours, open and not for
devas it is: “A function the library hands back keeps its closure” (#2808). The library had finished every result, so a function handed to a page carried its environment written into its body: a list of 4,096 numbers became a literal, evaluated again at every call. Kept as a closure, a call takes 0.025 ms instead of 5.31 ms. It keeps the environment whole and unwalked; it does not trim it. - Two closed PRs moved where an environment is kept, without changing what it holds: “cleanup: remove closure environment from FixF terms” (#2015) and “Don’t reuse a cached value that carries no environment” (#2463).
Trimming, as Matthew describes it#
- A function keeps its free variables, and a closed function keeps nothing. The statics already compute every expression’s free variables (its co-context,
Info.co_ctx). The elaborator could record them on each function, and the rule for a function would keep just those bindings. A recursive function also keeps its own name, which its fixpoint binds. - An indeterminate form keeps the free variables of what it has not yet evaluated. An
ifon a hole needs only its two branches’ free variables. - A hole needs everything in scope, if hole closures come back. A filling may use any variable in scope at the hole, so a hole closure needs the hole’s whole typing context, which is the whole lexical scope. A function whose body holds a hole would then keep its whole environment. On
devtoday this does not arise, since holes keep no environment. - What it costs, and where it pays. Each closure made gets a small environment of its own instead of a pointer to the shared one. That is a cost at every call of a function that returns a function, a curried function among them. Environments would also stop being shared, so two closures could no longer be seen to have the same environment by its identity. It pays wherever a value is walked: finishing a result, the worker’s message, the library’s crossing to a page, and a Hazel-only value the package holds whole (below).
What the jit does already#
Compiled code keeps only captures, and the crossing keeps it that way. A compiled Hazel function is a JavaScript function tagged with the Hazel names it captures and their values, in order ($R.fn(f, k, [values])). Back in the interpreter it becomes a closure whose environment holds those captures alone (HazelJitValue.of_js), with a recursive function’s own name bound again by a fixpoint. Going in, the compiler refuses a closure that carries an environment of its own (“a closure with its own environment”), so mixed mode never converts one. For the npm package, this matters to the next change on #2857: a value with no JavaScript form, such as a hole, a mark or an interpreter’s closure, crosses to a page held whole. Held, it is never walked, so a whole environment inside it costs memory, not time. Trimmed environments would make those held values small too.
Questions for the team#
Seventeen questions are open, for the team's meeting of 2026-11-17: two PRs to review, seven on mixed mode, three on what compiled code must match, three on how it lands, and two that an app met this morning. Each has our lean and what the answer decides. None blocks today's work; the answers on mixed mode decide its first step.
Answered at Matthew and Cyrus's meeting of 2026-11-13 (Matthew, 2026-11-17): "we want to mimic the step counts in the compiled code, if possible. can we make it match the interpreter in each case? if not, why not?" and "if we can mimic the step counts in the compiled code, can we support probes? if not, why not?" That settles three of the questions below, on the stepper, probes and the step budget. Our answer to theirs: yes and yes, with the care and limits in step counts and probes, as the interpreter's.
On PRs to dev#
- SInt at 32 bits, and overflow an error (hazelgrove/hazel#2828): agreed? Our lean: Yes, as the meeting asked. Wrapping at 32 bits everywhere would be cheaper in compiled code, but silent. It decides: Whether #2828 merges. It changes the language: a program that relied on wrapping now stops at an error.
- Who reviews the fix for modulo by zero (hazelgrove/hazel#2825)? Our lean: Anyone who knows the evaluator; it is small. It decides: Whether the interpreter still crashes on
int_mod(7, 0).
Mixed mode#
- Which functions get compiled? Our lean: Let-bound functions with their whole type declared (
let f : A -> B = fun ...), complete, with no probe. The elaborated type of any function would reach more, but it can hold unknowns, and the answer is converted back by that type. It decides: How much of a program runs compiled, and whether Hazel should nudge people to declare types;^ticket(762)says that pays in the interpreter too. - What does the stepper show for a compiled call? Partly answered 11-13: a compiled call counts the steps it would have taken. Our lean, still: mixed mode off while the stepper is open, since the stepper shows terms and compiled code has none. It decides: Whether stepping a program ever skips steps.
- Probes in compiled code: what is a probe's sample when the code that made it has no steps? Answered 11-13: compiled code counts the interpreter's steps, and with them makes the interpreter's samples (below). Until then, the plan is that a probe takes its function out of the compiled set; today mixed mode, which runs only in the tests, compiles such a function anyway, and its probes record nothing. It decides: The design of probes, the last of
^ticket(761)'s limits. - Main thread or worker? Our lean: Mixed mode in the worker only, where the interpreter runs; the main thread keeps only livelit views, as now, under the step budget, which answers Cyrus's concern. It decides: Whether a long compiled call can ever freeze the page.
- Falling back runs a call again from the start. Is that safe for good? Our lean: Yes while evaluation has no effects. Is any effect planned (a livelit updating its model, randomness, input and output)? It decides: Whether one-call-at-a-time fallback stays correct.
- A program with a type error elsewhere: compile its sound functions? Our lean: Yes, per function: a value that does not fit the declared type is caught where it crosses, and that call falls back. Today a single error anywhere keeps the whole program interpreted. It decides: How often a program being edited, so often with an error somewhere, runs compiled.
- One step budget or two? Answered 11-13: one, in the interpreter's steps, which compiled code will count exactly. Compiled code today has its own, 50 ms or 50 million calls a run. It decides: What a budget means to a user, and what the stepper and probes count.
What compiled code must match#
- String length in graphemes: intended? Our lean: Keep it. Compiled code now counts as the interpreter does, with a fast path for ASCII. It decides: The meaning of
string_lengthandstring_subfor text beyond ASCII. - Labeled tuples as JavaScript arrays carrying their labels: fine? Our lean: Fine inside compiled code. Labels named
length,__proto__or starting with$are stored under$+ label. hazeljs gives a labeled tuple to JavaScript as an object, so the boundary converts. It decides: The shape of values between Hazel and JavaScript, in hazeljs and in mixed mode. - The evaluator's ill-typed tests (27 stop at a failed run-time check; 4 fixpoints over
_and the like): keep them on a known list? Our lean: Keep them: they test the interpreter's casts, which compiled code never needs, since it compiles no program with type errors. It decides: Whether the consistency sweep keeps a list of known exceptions.
Landing and scope#
- How does hazel-jit reach dev? Our lean: In small PRs, as
^report(53)proposes: the two fixes above; then the compiler with the consistency sweep in CI and no user-facing change; then mixed mode behind a setting; then livelit views on the main thread. It decides: The order of review, and when anyone outside the prototype branch sees compiled code. - Should hazeljs ship the compiler? Our lean: No: a tool at a site's build time, with only the runtime (about 17 kB) shipped to pages. hazeljs's library is already 2.8 MB. It decides: How an app like the oracles gets compiled code without CI's help.
- Undeclared result types cost a step 5 to 7 times (
^ticket(762)): fix in elaboration? Our lean: Yes: put the result's ascription once around the body, where the typed form has it. It changes where the interpreter inserts its run-time checks, so it needs an owner who knows elaboration. It decides: Whether every Hazel program, not only compiled ones, gets the speed.
Met by an app#
The astrology oracle (hazeljs-oracles 0.0.15, ^ticket(768)) is eleven modules of numeric code, the Sun, Moon and planets from Meeus's and Schlyter's series, run by hazeljs. Writing it met two problems in the interpreter's side of Hazel, filed this morning.
- An answer that is a function grows past gigabytes (hazelgrove/hazel#2832): fix
Evaluator.finish? Our lean: Yes.finishsubstitutes the environment into the answer, so a function that reaches earlier modules copies their closures into it, nested; leave a closure in the answer as a closure, and substitute only for display. Compiled code never meets it: a compiled function is a JavaScript function. It decides: Whether a hazeljs page can take functions from a program of many modules. The astrology page cannot today, so it builds the whole program again for each chart, about 1.3 s. - Float literals print with six decimals (hazelgrove/hazel#2831): print them so they read back? Our lean: Yes, the shortest form that reads back as the same number. Today a literal with more decimals sends its module to the recovering parser, whose cost grows much faster than the module. Compiled code already prints floats exactly, and evaluation compares them by value, so the interpreter and compiled code agree on them; only parsing and the terms' own equality (six decimals) are affected. It decides: Whether numeric programs can write constants as they are; the astrology rules write long ones as ratios.
What next#
hazel-jit has its own PR for dev now, merged into the package’s branch; the hybrid lists, measured on the games, do not pay; next, converters by declared type, then holes as indeterminate values (above). In order:
- The jit-only PR, hazelgrove/hazel#2859 (
hazel-jit), green in CI, and #2857 taking the jit from it rather than from its own copy. - Done 11-23: the hybrid lists, prototyped on
hazel-jit-listsand measured on the seventeen games: about 8% slower ahead of time and 4% through the jit (above). Cells stay. - Converters by declared type: a page’s values written straight into compiled code’s shapes and back, without Hazel’s own values between, for the jit’s calls and mixed mode’s;
^report(63)found this crossing to be most of the jit’s time on 34 of 45 operations. - Mixed mode’s types from the statics: each function’s type from the info map, not from its annotation, so a module’s members compile on
devand a function needs no annotation. - Records held the page’s way in compiled code (an object by its labels, not an array carrying them), so that a list of records, as arrays, crosses for nothing too: measured in JavaScript and laid out as five decisions (
^ticket(847)); then the trial branch, once they are answered. - Indeterminate values in compiled code (above): a design for each elimination form’s residual, then a prototype on the hybrid lists, checked against the interpreter by the evaluator tests’ sweep, whose programs with holes it would then compile.
- The crossing between the interpreter and compiled code measured, before any change to the interpreter’s own lists (above).
- Done 11-18, build 50: the slides' builtins (
trial/761-slide-builtins): an operator passed as a function, andto_lvs, so more of the slides' programs compile: 20 of the 129, against 15. Its full tests had gone past their 100 minutes twice (build 49's took 72; CI runs 44146528138 and 44165874889). With the consistency check's timing runs left to the quick tests, they finish in 77 minutes (CI run 44184122601). A trail CI now prints shows the slides' check taking 13 of them, 11 of those on twenty slides, 91 to 110 in the check's order, the livelit playground's among them, each run once each way. Build 49's timing rule ran each slide at least ten times, which likely explains why its quick tests ran long whenever a test was added, as the astrology test was (not yet checked). The run found a real difference: two b2t2 examples,t.get_acnewithta list of rows, which the interpreter projects through the list, each row's field, and hazel-jit compiled as a JavaScript property read, undefined on a list. Projection now goes through the list as the interpreter's does, with two tests, and all 20 compiled slides agree (CI run 44197056910). One evaluator test then parted,(true).a, which the interpreter leaves stuck: the compiled run now stops as indeterminate there, where it once readundefinedand carried on, and the check counts that as agreeing. All of CI then passed (CI run 44211080673; the full tests in 92 minutes, against 77 before, so they are close to their limit), and the branch became build 50. - The astrology oracle compiled whole (
trial/768-astrology-timed,^ticket(768)): measured, 170 times as fast as the interpreter for one reading, the same answer. Its quick tests' overrun was build 49's timing rule: merged with build 50, they pass (CI run 44320263066). And the page casts compiled by default since hazeljs-oracles 0.0.16 (above). Left: mixed mode's measure of it, in the full tests now running. - Mixed mode across modules: a module's member that calls another module's (
Lines.becomesin the I Ching's reading) compiled too, so the I Ching's rules compile whole. - Mixed mode's crossing cost: a call from interpreted code to a one-line compiled function costs more than the function (500 calls of
sq, 27 ms mixed against 22 interpreted). Convert a large value once and remember it, and leave very small functions to the interpreter. - Step counts in compiled code (
^ticket(767)): a counter from the measured costs, each evaluator program's count compared with the interpreter's in the sweep. - Probes in compiled code, on the step counts, after the team's answer.
- Reviews for hazelgrove/hazel#2828 (SInt) and hazelgrove/hazel#2825 (modulo by zero).
- A cheaper step counter (
^ticket(763)); the probe drawer's stepper checked in the browser (^ticket(760)); the run-time type checks of an undeclared result type counted (^ticket(762)); a build-time compiler for hazeljs apps (^ticket(765)).
Next steps for Matthew and others#
The steps above are the agent's. These need a person: answers and a landing plan from Matthew and Cyrus, two reviews from anyone who knows the evaluator, an owner for one change to elaboration, and a first project for John.
- Matthew:
- Answer the five decisions on records (
^ticket(847)), above all the first two: they settle the representation that publishing the package waits on. - Write down the answers the team's meeting of 2026-11-17 gave to the seventeen questions, as the answers of 2026-11-13 are written there. They decide mixed mode's first step.
- Decide how hazel-jit reaches dev (question 13):
^report(53)'s small PRs, the two fixes first, then the compiler with the consistency check in CI and nothing a user sees. It decides when anyone outside the prototype branch meets compiled code. - With Cyrus, settle the four questions of
^report(55)before John starts, first of all whether his project lives on the prototype branch.
- Answer the five decisions on records (
- Cyrus: the questions on mixed mode (3 to 9) and on landing (13 to 15), and whether the two problems the astrology oracle met (16 and 17: hazelgrove/hazel#2832, hazelgrove/hazel#2831) are worth fixing now, and by whom.
- Anyone who knows the evaluator: review hazelgrove/hazel#2828 (SInt at 32 bits, overflow an error) and hazelgrove/hazel#2825 (modulo by zero, which crashes the interpreter today). Both are small, and both are on dev's path for hazel-jit.
- Someone who knows elaboration:
^ticket(762), undeclared result types costing each step 5 to 7 times (question 15): the result's ascription put once around the body, which changes where the interpreter inserts its run-time checks. - John, on the Hazel team:
^report(55), a starter project: let a value with a hole cross into compiled code and out again unopened, instead of sending the whole call back to the interpreter. Or first, as a warm-up on dev, hazelgrove/hazel#2831, floats printed so they read back.
How this was put together#
The plan is Matthew Hammer's summary of the meeting, quoted as he wrote it, and the dashboard's tickets 756 to 764. The sweep's numbers are the report it prints in CI's log: build 47's fast checks (CI run 43887985051), and the first sweep's full tests (CI run 43754503317). The Witch's numbers come from the Firefox check on GitHub's machines (scripts/jit_slides.py, run by the jit.yml workflow of hazelgrove/hazel), one run per build, with the runs named in the builds table. The view a frame and the compiled run a frame are its page timeline over a 3 s drag of the neck slider. The compiled run at a step is its time before the first redraw at each of four slider steps. The Node figures are microbenchmarks on JavaScript written as hazel-jit writes it, not builds of the app. SInt's behaviour was checked through hazeljs 0.0.6. Everything the page shows is in data/numbers.json.
The data#
- The numbers, for programs too: every table in this report, and what its numbers measure, is also in this page as JSON, in its
<script type="application/json" id="report-data">element, so a reader or an agent that fetches the page alone has the dataset. The same, with any raw files that survive, is in054/data/.