Hazel reports · ^report(50) · hazel-jit · 2026-11-08, revised 2026-11-10 09:41 MST · work in progress · for the meeting with Cyrus on Wednesday 2026-11-11 (^report(42))
Toward 60 fps: hazel-jit So Far
Can you drag a livelit's slider in Hazel and watch its picture follow at 60 frames a second, as it would on a page written in JavaScript? Not yet, but close: on the Witch slide, a drag now runs at 48.4 frames a second with the picture following, up from 9.8 earlier the same day. This report follows eight builds of one branch, each measured the same way, and says what is left. It puts ^report(45) to ^report(49) together, and asks you to try it. Matthew's goal, 2026-11-08: "I'd really like Hazel to have a floor of 60FPS for small edits (sliders changing), just like in JS (but well beyond there, obviously)."
Try it yourself. The latest build (build 8, below) runs in your own browser, with a frame-rate overlay at top right that shows the frames your browser draws: the Witch slide, compiled, and, to compare, the same with nothing compiled. Drag a slider (the neck, the arms) and watch the picture and the overlay. Every slide of the Livelit Playground is linked the same way in hazelgrove/hazel#2819, which hosts this build; the overlay goes on with ?hud in the address, and is also hazelgrove/hazel#2818, for dev.
The Witch slide is a Hazel program of 2,222 lines whose 53 livelits (33 sliders, choices, polygon editors and the picture) draw one figure of 133 shapes. A step of the neck slider changes 17 of the shapes; a step of the arms, 30. The picture is a livelit too: its view draws the figure the program computes from every slider. It began as a game Matthew's children, M and N, design (Messed Up Dress Up), ported to Hazel (^report(4)) so that its pieces are live code.
The drawing at left is the picture's own output, the same from Hazel's interpreter, from hazel-jit's JavaScript, and from three other compilers and JavaScript written by hand (^report(46)). Below, the same program with its choices changed, drawn by Hazel.
The Witch slide's picture with five settings of its livelits, drawn by Hazel (^report(4), 2026-10-11).
On build 8, the latest, a 3-second drag of the Witch's neck slider runs at 48.4 frames a second with views and the slide's run compiled, and the picture follows the slider at every frame. Its median frame is 17.1 ms, one display frame: 116 of its 146 frames (79%) fit in one 60 fps frame, and the other 30 take two to 4. So it is not yet a floor of 60 frames a second, but most of the way there.
With nothing compiled, the same drag runs at 57 frames a second, but only the slider moves: the picture waits for the worker to run the program after the release. A single step of a slider, as a click gives it, shows in the picture 176 to 290 ms after the click, against 1.12 to 1.56 s with nothing compiled. That is still 11 to 17 frames at 60 fps (why).
Build 8 (change C, 61f3f01a15), run 42566328043. Green: one display frame; amber: two; red: three or more. A frame of about 16 or 17 ms is the display's own pace, 60 a second; nothing can be quicker.
Build 8, compiled: halfway through a drag, the picture in view. The overlay reads 42 fps over the last second, the longest frame 66 ms; over the whole timed drag, 48.4 fps (run 42566328043).Build 8, nothing compiled: 58 fps, the longest frame 34 ms; but the picture does not follow the drag, it waits for the worker after the release.
The overlay is a few lines of JavaScript, on with ?hud in the address: the frames the browser drew in the last second, the longest of them, and two seconds of frame times as bars against a line at 16.7 ms, red above two frames. It times frames as the browser draws them, so a page busy for 300 ms shows as one 300 ms frame. It is how you can check any number here yourself (try it).
hazel-jit turns Hazel code into JavaScript that runs 29 to 1,140 times faster than Hazel's interpreter; the Witch's whole run, about 112 times faster. On build 8, the slide's whole run, compiled, takes 2.2 ms of a drag's frame. That is why the picture can follow a drag at all. It also means the run no longer stands between Hazel and 60 fps: the page's own work around it does (where the time goes now).
A view compiled is drawn straight from its JavaScript, never made a Hazel value again (^report(45)). In Firefox, compiled views draw what the interpreter draws: the check compares every livelit's drawing on every polygon slide both ways, and found 0 differences in builds 4 to 8.
Not a build of the app: each row is one piece of Hazel code run two ways. Medians in Node 22 on a laptop (^report(45)), and renders in Firefox in the app (^report(46)). A render's time is its view's work alone, as if the update were free. The ratio is of the middles of the ranges.
On one rule of a Petri net, hazel-jit's code takes 1.59 µs a call: 2.9 times ReScript's, 1.8 times JavaScript written by hand, and 225 times less than Hazel's interpreter. On the Witch's picture view, all five compilers are within 15% of one another, since most of the work is one builtin. ReScript's and Melange's ways of laying out values are the models for what hazel-jit makes next (^report(46)).
Not a build of the app: each answers the same 2,000 events and ends on the same marking (^report(46), how fast). js_of_ocaml's is a best case: it inlined the rule into the timing loop.
This report's own figures come from eight builds of one branch, trial/694-view-jit, each the build before it plus one change, and each measured the same way in Firefox on GitHub's machines on 2026-11-08. Over them, a slider's step went from 4.17 to 6.52 s to 176 to 290 ms, and a drag from 9.8 to 48.4 frames a second. Every build compiles livelit views (^report(45)); "nothing compiled" means the same build with Compiled views turned off. Each figure names its build by number.
build
what it adds to the build above it
a step, compiled
a drag, compiled
1 · the branch as it was dfa3fcdffe, run 42486001354, 11-08 06:39
Livelit views compiled (^report(45)). The picture waits for the worker's answer: the whole program run on the interpreter, its result sent back as 5 MB of terms.
4.17 to 6.52 s compiled views or not: the picture waited for the worker
not measured
2 · the answer trimmed 20a3067c18, run 42490487136, 11-08 07:34
Two changes to the worker's answer: no function-holding values in the samples' environments, and no trace (^report(46)).
1.85 to 2.38 s compiled views or not: the picture waited for the worker
not measured
3 · the answer unshared 4747a4120d, run 42492117212, 11-08 07:54
The worker's answers no longer shared (^report(46)).
1.33 to 1.71 s compiled views or not: the picture waited for the worker
not measured
4 · the run compiled 6d71c427bf, run 42551267058, 11-08 19:29
The slide's whole run compiled to JavaScript in the page, each livelit's model a parameter, and called at a livelit's event, so every livelit draws from its answers (^report(49)). A step back to a slider's starting value is still taken for an undo, and waits for the worker.
318 to 469 ms steps back: 1.66 to 1.69 s nothing compiled: 1.90 to 2.24 s
not measured
5 · steps back kept bb88edfd12, run 42556616487, 11-08 20:28
A step back keeps the run's answers (a51dc778dd, ^report(49)); and the frame-rate overlay, and the timed drag in the check, which change nothing else in the app.
208 to 400 ms nothing compiled: 1.14 to 1.51 s
9.8 fps nothing compiled: 6.1
6 · change A 9fca635226, run 42560502616, 11-08 21:12
A drag's input events go to the page as a request to draw again, not to the editor as an edit of the program.
223 to 416 ms nothing compiled: 1.56 to 1.96 s
22.5 fps nothing compiled: 15.2
7 · change B 38d4e4d0f8, run 42562102280, 42563736665, 42564711121, 11-08 21:29
Each livelit has its own version in the views' cache, so a frame draws again only the livelits whose answers changed, not all 53.
245 to 434 ms nothing compiled: 1.63 to 1.99 s
26.4 fps nothing compiled: 21.3 again: 34.3 and 26.2
8 · change C 61f3f01a15, run 42566328043, 11-08 22:16
The projectors' data and finished views kept from frame to frame while nothing they read has changed (bdecaec5d9, 61f3f01a15).
176 to 290 ms nothing compiled: 1.12 to 1.56 s
48.4 fps nothing compiled: 57
The builds come in three stages:
Builds 1 to 3: the worker's answer (^report(46)). The picture waited for the worker to run the whole program on the interpreter and send back its result, 5 MB of terms. Two changes and no sharing took a step from 4.17 to 6.52 s to 1.33 to 1.71 s.
Builds 4 and 5: the run compiled in the page (^report(49)). The slide's whole run is compiled once, with each livelit's model as a parameter, and called at the slider's event. Every livelit draws from its answers at the page's first redraw, without waiting for the worker: a step in 208 to 400 ms. Build 4 still took a step back to a slider's starting value for an undo, so those steps waited for the worker.
Builds 6 to 8: a drag's frames (this report). Change A: a drag's input events, which change nothing in the program's text, no longer go to the editor as edits of the program. Change B: a frame draws again only the livelits whose answers changed. Change C: the projectors' data and finished views are kept while nothing they read has changed.
One dot a step: the neck and arms sliders each stepped away from their starting value and back, with views compiled; for builds 1 to 3, those four steps both with views compiled and not, since the picture waited for the worker either way. The step is the slider's input event and its change event together, as a click on the slider gives them. One run a build, Firefox on GitHub's machines, a release build each time; the runs are in the table of builds.
The three changes took a compiled drag from 9.8 to 48.4 frames a second, its median frame from 99.6 to 17.1 ms. With nothing compiled, a drag went from 6.1 to 57; that drag does less, since only the slider moves. Single runs vary: build 7, measured three times without changing the app, gave 26.2, 26.4, 34.3 frames a second compiled. So a step's times for builds 5 to 7 are within that noise (changes A and B were for a drag's input events, not a step); build 8's steps were the quickest so far, but one run each is not enough to say by how much.
The same drag each time: one input event a frame as the slider sweeps from 0 to 60 and back, and one change event at the end, as a browser delivers a drag; every frame timed with requestAnimationFrame, as the overlay times it. One drag each way in each build's run. The open circles are build 7 measured twice more, the app unchanged: 34.3 fps compiled in run 42563736665 (the same app with the page's view timed part by part); 26.2 fps compiled in run 42564711121 (the same app with a first try at change C whose memo missed every frame). So one run can differ from the next by a third, and a single run's number is a reading, not a constant.
Build 5, compiled, before the changes: halfway through the same drag, the overlay reads 9 fps, the longest frame 283 ms (run 42556616487).Build 5, nothing compiled: 9 fps, the longest frame 217 ms, at the moment of this screenshot; over the whole drag, 6.1 fps.
On build 8, a drag's frame is the page's own view, 10.1 ms, the compiled run, 2.2 ms, and about 4 ms of the browser's own drawing. The view is rebuilt from the whole page's state at every frame, though a drag changes only a few livelits, and it is most of each frame.
Build 8, run 42566328043: the page's timeline (Util.BenchMarks) summed over the drag and divided by its 146 frames. The rest of the median frame is the browser's own work after the view, which the timeline does not time.
A step takes longer than a drag's frame because its change event is still an edit of the whole program. In a click, the input and change events come together. The input is handled as in a drag: the compiled run, then a redraw. The change goes to the editor: statics and syntax (32 ms), then the whole slide's view (91 ms), all before the browser can paint, at 176 ms. After the paint, the page compiles the program again (126 ms), and the worker still runs it; its answer, at 1.08 s, draws the same picture again.
Build 8, run 42566328043: the quickest of its four steps, from the page's own timeline and the worker's (Util.BenchMarks), each block a measured piece of work at the time it started; the worker's blocks are on its own thread, the rest on the page's. ^report(49) has the same figure for build 4's app.
The series has measured 196 separate costs in Hazel, from four design choices each applied everywhere: values held as terms, whole-program work on every edit, values moved as terms across boundaries, and an interpreter that pays for the editor at every step. Many are most of the work they were found in, and many make one another larger (^report(48)). Compiling the run (builds 4 and 5) took the fourth out of a slider's step; changes A to C (builds 6 to 8) took some of the second out of a drag. The second is most of what is left.
Not a build of the app: every cost the series has measured in Hazel, one rectangle each, grouped by the design choice it comes from and coloured by where it stands (^report(48)). Hover a rectangle for the cost.
Values as data: held without ids, holes or closures, the Witch's picture is 3 times smaller and its trip 2.5 to 4.3 times quicker; but building values as data saves the evaluator a couple of percent at most, so the run itself had to be compiled (^report(47)).
Not a build of the app: the picture's value, held two ways. As data: no ids, no sharing to find, numbers packed (^report(47)); the lighter bar is the slowest of the readings.
Each is a change to make, in the order that reaches 60 fps on the Witch; the middle column is the time it would take away, as measured on build 8 (or in the report named). On 11-09, in the order Matthew set (3, 4, 7, then 1 and 2), five were tried, as builds 9 to 12 in ^report(51); the status column says how each went. On build 12, a step shows in 19 to 24 ms and a drag's view is 6.1 ms a frame. What had been done before is the eight builds (the table); the last three, changes A to C, were this list's first item in the version of 11-08.
what to do next
what it would take away, as measured
status
1
Draw only the livelits a drag changes. Make the editors' and projectors' views incremental, so a frame no longer rebuilds the view of the whole page.
first part done 11-09: each editor's decorations and probes' views reused across a drag's frames, the view 6.1 ms a frame (build 12 of ^report(51))
2
Handle a slider's change event without an edit of the program, as change A did for its input events, or do the edit's work after the paint.
Most of a step: statics and syntax (32 ms) and the whole slide's view (91 ms), all before the paint at 176 ms.
done 11-09: the page draws first and makes the edit after the paint; a step shows in 19 to 24 ms (build 12 of ^report(51), ^ticket(721))
3
Compile the program once, not again after a step that changed only a livelit's model: the compiled program already takes the model as a parameter.
126 ms of the page's thread after each step.
done 11-09: kept at every step; 29 to 51 ms of comparing after the paint instead (builds 9 and 10 of ^report(51))
4
Leave the worker out when the compiled run has answered: don't run it, or don't draw again from its answer.
About a second of the worker's work a step (its answer at 1.08 s), and the page drawing every view again to the same picture.
partly done 11-09: the answers kept, the worker's request held; the page still draws a whole view per worker message (build 9 of ^report(51), ^ticket(720))
5
Check a step's time and a drag's frames in Firefox on every PR to dev, so they cannot slip back (^report(48)).
Nothing by itself; it keeps the rest.
the check runs on this branch only (jit.yml); build 8 is hosted for the team by hazelgrove/hazel#2819
6
Make hazel-jit's output more like ReScript's and Melange's: their layouts of records, constructors and lists, and fewer calls.
On the Petri rule, 1.59 µs a call against ReScript's 0.55 (^report(46)); on the Witch, the run is 2.2 ms of a frame, so little there.
not started
7
Send values as data where they cross, when the worker does run: its answer and probe samples without ids or sharing.
The picture 3 times smaller and its trip 2.5 to 4.3 times quicker, measured outside the app (^report(47)).
first slice tried 11-09, and off: the answer grew to 0.89 MB (build 11 of ^report(51), ^ticket(718))
A livelit's view compiled to JS runs 40 to 1,150 times faster than on the interpreter; in Firefox, compiled views draw what the interpreter draws; the Witch's whole run, compiled, 4.2 to 5.0 ms in Node.
BuckleScript, ReScript and Melange, beside hazel-jit
hazel-jit's code is about 2.9 times ReScript's and 1.8 times hand-written JS on the Petri rule; on the Witch's picture all five are within 15%; builds 1 to 3 here: a small edit took 5.3 to 8.8 s, and two changes brought it to 1.3 to 1.7 s.
As data, the Witch's picture is 3 times smaller and 2.5 to 4.3 times quicker to send; building values as data saves the evaluator a couple of percent at most, so the run itself has to be compiled.
Builds 4 and 5 here: the slide's whole run, compiled and run in the page at a slider's step, 8 to 21 ms; the picture at the page's first redraw, 286 to 386 ms, against 1.35 to 1.74 s.
The builds (the table) are release builds of trial/694-view-jit, each measured by scripts/jit_slides.py in Firefox on GitHub's machines (.github/workflows/jit.yml): every polygon slide loaded with Compiled views on and off, its events run, and every livelit's drawing compared; the Witch's four slider steps each way; and, from build 5 on, the drag. Builds 1 to 3 are ^report(46)'s runs, build 4 is ^report(49)'s, and builds 5 to 8 are this report's (their data).
The drag: the Witch loaded fresh with ?hud, compiled and not, the neck slider swept from 0 to 60 and back for 3 s, one input event a frame and a change at the end, every frame timed with requestAnimationFrame. Then the same drag again with the picture scrolled into view (the slider is 1,400 lines above it; the events reach it all the same) and a screenshot halfway, so that the screenshot cannot hold up a timed frame. One drag each way per run.
Not builds: the comparisons with the interpreter and with other compilers (^report(45), ^report(46)), values as data (^report(47)) and the ledger of costs (^report(48)) measure Hazel code or values outside the app; each of those figures says so.
The Witch's drawings: its picture as ^report(46)'s compilers drew it (046/witch/svg), and ^report(4)'s screenshot of five settings.
Revised 2026-11-09, on Matthew's word: "It's really confusing to follow what version of the system each figure is plotting. Let's revise the entire thing and reorganize it to be simpler to understand." The builds are numbered, each figure names its build, the comparison with the interpreter moved up, and ^report(49)'s step timeline is drawn again on build 8.
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 in 050/data/.