Hazel reports · ^report(57) · hazel-jit · 2026-11-18, revised 2026-11-18 09:58 MST · work in progress · after reports 052, 054 and 056

What the Livelits PR Compiles

Matthew Hammer asked, on 2026-11-18, to what extent hazelgrove/hazel#2819 uses hazel-jit: for livelit views only, or for anything else. This is the answer, read from the pull request's code, with a section for each use, written for his conversation with Cyrus Omar today about what makes livelits responsive, and how it reaches dev; the team's next mergeathon is tomorrow, 2026-11-19.

Outline#

  1. In short: in the app, hazel-jit serves livelits only, four ways; outside it, a command, tests and a browser check.
  2. In the app: livelit views, livelit updates, the slide's whole run, and the worker's request held.
  3. Outside the app: the command line, a measuring page, the tests, the Firefox check.
  4. What #2819 does not have: everything since the morning of 2026-11-09, the step budget and the consistency check among it.
  5. What makes livelits responsive: the ten changes ^report(52) ranked, which of them are hazel-jit, and which #2819 holds.
  6. Reaching dev: ^report(52)'s nine increments, brought up to date; for tomorrow's mergeathon; and what to decide with Cyrus.

In short#

In the running app, #2819 uses hazel-jit only for livelits, but for more than their views: their updates, and each slide's whole run, which it compiles only to draw livelits sooner. The program's result, probes, tests and the stepper always come from the interpreter. Outside the app it adds a command, tests and a browser check. Read from the pull request's code at c419e01559 (2026-11-09), behind the Compiled views setting, which is on by default there.

  1. Livelit views. A livelit's view function is compiled and run on the page's own thread with the livelit's model, and its answer drawn straight into the page, never made into a Hazel value; handlers that take a payload run compiled too.
  2. Livelit updates. The definition's update function is compiled too: on an action, a new model comes back as a diff against the old one; any other answer goes to the interpreter.
  3. The slide's whole run. The slide's program is compiled once, each livelit's model a parameter; at a livelit's event the whole program runs as JavaScript with the new model, and every livelit is drawn from that run before the worker's run returns. Its answer is used only to draw livelits.
  4. The worker waits. When the compiled run has answered an event, the page holds its request to the interpreter for 400 ms, so a drag costs the worker one run, after its last step.

Outside the app: ./hazel jit FILE.hz to compile a file, check it against the interpreter, and count what it does not compile; a page that times values carried into JavaScript; the HazelJit tests; and the Firefox check that drives the slides and times them. Not in #2819: all the work since its head on the morning of 11-09, which is on the prototype branch (build 50, hazelgrove/hazel#2817).

In the app#

All four uses sit behind one setting, Compiled views (jit_views, on by default on #2819), and each falls back to what the page did before hazel-jit when it meets something it does not compile. The setting sets HazelJitValue.enabled; turned off, nothing is compiled, and every livelit is drawn through the interpreter's run, as on dev.

1. Livelit views, compiled#

A livelit's view, a Hazel function from its model to HTML, is compiled once per definition and called on the page's own thread whenever the livelit is drawn: 3.0 ms a render of the Witch's picture against 87 ms through the interpreter. (^report(46), in Firefox; ^report(52), ingredient A4.)

2. Livelit updates, compiled#

The definition's update, compiled, runs on the model and the action; when it answers Pure(new model), the new model comes back as a diff against the one it was given, so every part it did not change stays the very same Hazel value. Any other command goes to the interpreter. (^ticket(715), ^report(45)'s second step; HazelJitValue.call_update, called from LivelitProj.)

3. The slide's whole run, compiled#

This is what makes a slider's step show in about 20 ms: the slide's program, compiled once with each livelit use's model as a parameter, answers a livelit's event in 2 to 3 ms as JavaScript, and every livelit draws from that answer before the worker's run comes back. (^ticket(722), ^report(52)'s ingredients A2 and B3; HazelJitRun.)

4. The worker's request, held#

When the compiled run has just answered a livelit's event, the page holds the request it would send the worker for 400 ms, replacing it by any newer one, so a drag costs the worker one run, after its last step, not one a step. (^report(50)'s fourth step; WorkerClient.hold_if_answered, asking HazelJitRun.take_answered.)

Outside the app#

Four tools, none of which a user of the app meets.

What #2819 does not have#

#2819's head is the prototype's build 12 and two commits, from the morning of 2026-11-09; everything since, 123 commits to build 50, is on the prototype branch only, including the step budget that answers Cyrus's concern about compiled code on the page's thread.

BuildCommitDateWhat it is
12d9d63c13af2026-11-09the prototype when #2819 was cut: a drag's frames reuse each editor's decorations and probes' views; #2819's head is this and two commits (samples as data turned off, a formatting pass)
3819ecb756942026-11-10^report(52)'s measurements: a step's picture 20 to 31 ms after the click, a drag 55.7 fps
490e56bdbd0a2026-11-17^report(54)'s: the meeting's changes merged, all of CI green
5055e4757a4b2026-11-18today's prototype, trial/694-view-jit (hazelgrove/hazel#2817): build 49 and the slides' builtins

The prototype's preview is build.hazel.org/trial/694-view-jit/; ^report(51) and ^report(55) point there instead of #2819.

What makes livelits responsive#

Two changes did most of it: the worker's answer sent without what the page does not read, which needs no compiler, and the slide's whole run compiled. Of the ten changes ^report(52) ranked, five are hazel-jit or ride on it, and five need no compiler at all; #2819 holds the five, and the answer's trimming, but none of the page work. ^report(52) measured each when it landed, on the Witch slide in Firefox, one run a build; the two groups measure different things and are not added.

#ChangeCompiler?Measured when it landed (^report(52))In #2819
What a user waits for: a step's picture, a drag's frame
A1Send the worker's answer without what the page does not readno compiler2.84 to 4.81 s off a step (builds 2, 3); the answer 590 KB to 198 KB (build 20)partly (builds 2 and 3, not 20)
A2Compile the slide's whole run, each livelit's model a parameterhazel-jit1.09 to 1.50 s off a step (builds 4, 5): a step's picture 1.33 to 1.71 s, then 208 to 236 msyes (builds 4 and 5; not 18 (the first step like the others))
A3Draw first; make the edit after the paintneeds the compiled run133 to 171 ms off a step (build 12): 152 to 195 ms, then 19 to 24yes (build 12)
A4Compile each livelit's viewhazel-jit84 ms off each render of the Witch's picture: 87 ms to 3.0yes (before build 1)
A5A drag redraws only what changedneeds the compiled run80 to 85 ms off each frame of a drag: 9.8 fps (build 5) to 57.6 (build 12)yes (builds 6, 7, 8 and 12)
The page's work after the picture, which can make the next frame late
B1Keep the livelits a change did not touchno compiler190 to 400 ms off the page's work after a step (builds 15 to 39)no (builds 15 to 39)
B2Build the outline on its own, and only what changedno compiler128 to 201 ms off a step (builds 13 to 41)no (builds 13 to 41)
B3Compile the run once; compare only what changedhazel-jit125 to 140 ms off a step: compiling again 126 to 141 ms (build 8), comparing 1 ms (build 17)partly (builds 9 and 10, not 17)
B4Save without a redraw, printing only what changedno compiler77 to 96 ms off a step (builds 16, 23)no (builds 16 and 23)
B5Draw the picture's probe row without rewriting its valueno compiler38 to 85 ms off each answer (builds 14, 26)no (builds 14 and 26)

Today, on build 50 (the Firefox check, run 44319161252), with compiled views on: a 3-second drag of the Witch's neck slider at 54.3 frames a second, the page's view 6.5 ms a frame (about 154 fps); a step's first redraw 27 to 30 ms after the click (89 ms for the slide's first step), hazel-jit's own run 5 to 11 ms of it. With compiled views off, the same drag runs at 42.0 frames a second, the view 15.4 ms a frame (about 65 fps), and its longest frame is 133 ms against 34.

Reaching dev#

User-defined livelits are not on dev yet, and #2819 is 1,680 commits ahead of dev, the whole livelits stack with hazel-jit on it; so hazel-jit's livelit uses reach dev after the livelits do, in ^report(52)'s increments, carrying the correctness work done since. Livelits going into dev was settled with Cyrus on 2026-11-05; how, in what pieces and in what order with hazelgrove/hazel#2469, is still open. dev has LivelitProj today, for the built-in livelits; the user-defined ones, whose views and runs hazel-jit compiles, come with hazelgrove/hazel#2597's stack.

OrderIncrementWhat it holdsNeeds firstWhere it is now
0The rulerThe Firefox check that drives the slides and times each step and drag, the page's timeline of marks, the worker's answer weighed by part. Nothing a user sees.nothingOn the prototype; on #2819 as it was on 11-09.
1The worker's answer, smallerIngredient A1: the worker and its messages only. Helps dev as much as livelits.nothingOn the prototype; #2819 has its first two parts.
2Page work every edit paysB2, B4, B5: the outline on its own, the autosave without a redraw, the probe row. Each its own small PR.the outline and autosave: livelits; the probe row: devOn the prototype only.
3Livelits keptB1: a livelit's view, shape and applied definition kept, keyed on what it reads; one cache a PR, each with a test that it gives the same view.livelitsOn the prototype only.
4The compilerhazel-jit itself, a module at a time, and now its correctness (^report(54)): exact Int and Nat, SInt at 32 bits, invalid operations stopping, the rules for holes, type holes and type errors, and the consistency check in CI. Nothing a user sees.nothingOn the prototype, build 50; its CI checks 313 evaluator programs and 129 slides both ways.
5Compiled viewsA4, with the step budget (^ticket(763)), since it runs compiled code on the page's thread.4, livelits#2819 has the views, without the budget; the prototype has both.
6The run compiled in the pageA2 and B3: the slide's run compiled once, called at a slider's event, kept while only models change.4, 5#2819 has it as of 11-09; the prototype has it whole.
7Draw first, edit after the paintA3.6In both.
8The drag fast pathA5: four changes, each its own PR.6In both.

^report(53) explains why the prototype is to be redone by hand rather than merged: its 120 commits came with few tests of their own, and some only fixed the one before. ^report(52)'s plan holds, with two updates. The compiler's increment now has its correctness work and the consistency check in CI to carry, which make it reviewable: every program it compiles is checked against the interpreter on every push. And the step budget should land with the first increment that runs compiled code on the page's thread, the views.

For tomorrow's mergeathon#

What could be opened or merged on 2026-11-19 without waiting on livelits.

  1. The two interpreter fixes, already open, CI green, waiting on a review: hazelgrove/hazel#2828 (SInt at 32 bits, overflow an error) and hazelgrove/hazel#2825 (modulo by zero crashed the interpreter).
  2. The ruler (increment 0): the Firefox check and the page's timeline of marks, which change nothing a user sees and let every later increment be measured.
  3. The worker's answer, smaller (increment 1, ingredient A1): the worker and its messages only, helping dev as much as livelits.
  4. The compiler, a module at a time (increment 4), with its tests and the consistency check in CI, and nothing a user sees: it can land before livelits, since it compiles any closed program and checks itself against the interpreter.
  5. #2819: closed, or marked as superseded, with a pointer to the preview and to these increments, so no one reviews a stale branch.

To decide with Cyrus#

  1. Which comes first for responsive livelits? Our lean: the page work that needs no compiler (A1, B1, B2, B4, B5) lands with or right after the livelits, as it helps every edit; then compiled views; then the compiled run. The run is what makes a step show in 20 ms; views alone make drags and redraws fast.
  2. Compiled views on dev: on by default, or behind a setting that starts off? Our lean: off at first, on once the consistency check and the step budget have run a while in CI.
  3. Is the step budget a condition for compiled code on the page's thread? Our lean: yes; it is Cyrus's concern of 11-13, and #2819 has none.
  4. What becomes of #2819? Our lean: close it in favor of the increments, keeping the preview build for trying.
  5. The compiler before livelits? Our lean: yes, as a library with its check in CI and nothing a user sees, so its review is not tied to the livelits' landing.

How this was put together#

Written on 2026-11-18 from #2819's code at c419e01559 (each file that calls into hazel-jit, read for what it calls: LivelitProj, HazelJitDOM, HazelJitRun, WorkerClient, ProjectorView, Settings, Cli, DataExperiment), its ancestry checked against each numbered build's commit, and from ^report(45) to ^report(56), whose measurements are quoted with their builds. Today's numbers are build 50's Firefox check (run 44319161252). Nothing new was measured for this report.

The data#