Hazel reports · ^report(45) · hazel-jit · started 2026-11-06, updated 2026-11-08 19:50 MST · work in progress · for the meeting with Cyrus on Wednesday 2026-11-11 (^report(42), item 2)

hazel-jit: Livelit Views Compiled to JavaScript

How much faster can a livelit's view run as JavaScript compiled from its Hazel, instead of on Hazel's interpreter? Decided at the meeting with Cyrus on 2026-11-05, as the best case first: JS's numbers allowed to differ from Hazel's for now (^ticket(694)). This report follows the work as it goes, for the next meeting on Wednesday 2026-11-11 at 10:00 Mountain, where it is item 2 of the agenda, ^report(42).

What the milliseconds here measure (added 11-08): livelits' views and updates, and on the slides the clicked livelit's own change. That is a small part of what follows an edit. A change to a livelit's model is a change to the program, which then runs in Hazel's worker; what the run changes shows only after it. Timed so far on one slide, the Witch, in ^report(46): one step of a slider shows in the picture 5.3 to 8.8 s later (317 to 526 frames at 60 fps), compiled or not, in two runs of four edits each way. The picture's view is 3.0 ms of that compiled (0.04%) and 87 ms on the interpreter (1.1%). Nearly all the rest is the program's run, 1.2 to 2.6 s in the evaluator, and its answer coming back, 4.4 to 5.4 MB, made in the worker and decoded on the main thread (a small edit, where its time goes). The other slides' runs are not timed yet. (Matthew, 2026-11-08: the numbers here "must only be measuring a small fraction of the total work, since they are on the order of ms, not sec".) Since 07:05: most of those seconds, 70 to 72% on the neck edits, are the run's answer going from the worker to the page, shared and encoded in the worker and decoded on the page; the evaluator is 18 to 20% (the trip). ^report(46) also speculates on compiling the run itself, as this report compiles views, so that under ideal conditions it runs on the main thread and its answer never leaves JS (compiling the run). Since 17:22: the run itself is compiled now, and it is milliseconds too. hazel-jit compiles the Witch slide's whole program, and in Node it runs in 4.2 to 5.0 ms against the interpreter's 502 to 529 ms, 106 to 119 times faster, with the same values; a slider's step, compiled once with the new model a parameter and every view called, 2.3 to 2.5 ms against 684 ms (the whole run, compiled). Not yet in the app.

Outline#

  1. How much faster: a render of the Polygons slide's view, on the interpreter and compiled, its first renders and once warm.
  2. The whole run, compiled (^ticket(722), 11-08): the Witch slide's whole program, 2,222 lines with 53 livelit uses, compiled and run in Node: 4.2 to 5.0 ms against the interpreter's 502 to 529 ms; a slider's step, compiled once with its model a parameter, 2.3 to 2.5 ms against 684 ms; every value the program binds the same both ways. Not yet in the app.
  3. Where the time goes now: the trip back, the view's answer made again as Hazel terms, is most of a compiled render; the trip in is small.
  4. Three ideas for the way back (Matthew, 2026-11-07): cheaper ids, a view's answer never made Hazel, and the way back as a diff; all three work, and not coming back at all helps most.
  5. In a browser (^ticket(716), ^ticket(717)): on the six polygon slides in Firefox, compiled views draw exactly what the interpreter draws, before and after the same clicks, and a click shows sooner on every slide; the rest of the page's work is now most of an event. These times end at the clicked livelit's own change: on the Witch, what the program's run then changes shows 5.3 to 8.8 s after the edit (^report(46)).
  6. Beside JS written by hand (^ticket(699)): on ^report(43)'s Petri rule, hazel-jit's code takes 1.59 µs a call, the hand-written 0.90, the interpreter 358; ReScript's and Melange's beat both, and ^report(46) says why.
  7. How it works: the compiler, how Hazel's values look in JS, and the trip in and out.
  8. In the app: since 11-07, a view drawn straight from its compiled JS, and an update compiled, its new model back as a diff; the setting, and what happens when it cannot.
  9. Does it give the same answers: the tests, and checking that they can fail.
  10. What it does not do yet.
  11. For Wednesday's meeting: the agenda's questions about this work.
  12. What next, and how this was put together.

Update, 2026-11-08 evening: the Witch's whole run, compiled, now runs in the app at a slider's step (^report(49)): in Firefox it answers in 10 to 12 ms (3 to 4 ms for the next event of a drag), all 53 livelits' views included, and in 2 of 4 steps the picture showed at the page's first redraw, 318 and 469 ms after the step, against 1.90 to 2.24 s with nothing compiled in the same run. On those steps the evaluator is out of the way; what is left is the page's own work (statics, the whole slide's view twice) and the program compiled again after each step. The program the page holds is not the one measured in Node below: a slide is elaborated without its livelits' views in the run, which hazel jit --views put in by probing every use (what the Node numbers assumed).

How much faster#

A render of the Polygons slide's view takes 13.7 ms on the interpreter and 0.34 ms compiled, about 40 times faster, counting the trip into JS and back, once Node has warmed up to it. The first 30 renders after compiling take 1.03 ms (their median), about 13 times faster: the first took 2.24 ms, and they fall to about 0.36 ms while Node optimizes the way back. The compiled code itself takes 0.043 ms of that, about 315 times faster than the interpreter. Smaller programs gain more, since there is no trip to take: the Petri net rule of ^report(43), answering four events, 7.19 ms against 0.011 ms (630 times), and a recursive sum of 1,000 numbers, 47.9 ms against 0.042 ms (1,152 times).

Update, 2026-11-06 19:00: the first version of this report said a render was about 16 times faster. Those renders were timed first and cold, the first 30 after compiling, and their times fell from 2.1 ms to 0.4 ms over the 30 runs as Node optimized the way back, so their median measured the warm-up more than a render. Each series is now timed after 10 untimed runs. Warm, a render was then about 34 times faster; the first renders, timed cold as before, are a row of their own (^ticket(694)).

Time per run, ms (a log scale: each step to the right is ten times as long)0.01 ms0.1 ms1 ms10 ms100 msA Polygons renderthe interpreter13.7 mscompiled, its first 30 renders1.03 mscompiled, with the trip in and out0.34 msthe compiled call alone0.043 msThe Petri net rule, four eventsthe interpreter7.19 mscompiled0.011 msA recursive sum of 1,000the interpreter47.9 mscompiled0.042 ms
Medians of 30 runs each, in Node 22, from a development build of trial/694-view-jit (4c0ed173f1), on one laptop. The compiled times count the compiled code only; the Polygons render is also shown with the model carried in and its answer carried back: its first 30 renders after compiling, and 30 more once warm (after 10 untimed).

These are Node's numbers, from a development build, on one laptop, medians of 30 runs in one test session; the runs vary (the Petri net rule's interpreter time ran from 4.8 to 9.2 ms over the day's test sessions), so read the ratios to within a factor of two. The interpreter's numbers do not include the call memo the app gives a view (^report(1)'s CallMemo), which saves calls repeated between renders; compiling the definition took 4.46 ms, once. Browser numbers, and a release build, come next.

ProgramInterpreter, msCompiled, msFaster
A Polygons render, its first 30 renders, with the trip in and out13.71.0313×
A Polygons render, warm, with the trip in and out13.70.3440×
A Polygons render, the compiled call alone13.70.043315×
The Polygons view's whole program (its definitions and the view applied)14.70.052284×
The Petri net rule, four events7.190.011630×
A recursive sum of 1,00047.90.0421,152×

The whole run, compiled#

In the app (2026-11-08 evening, ^report(49)): the numbers in this section are in Node, on the program elaborated with every livelit use probed. The page holds the slide's program without the livelits' views in it, so the compiled run first had no model to hand a new value to; it now folds the views in itself. In Firefox, at a slider's step, it answers in 10 to 12 ms (3 to 4 ms for the next event), all 53 views included (a step, run compiled).

hazel-jit compiles the Witch slide's whole program and runs it in 4.2 to 5.0 ms, against 502 to 529 ms on Hazel's interpreter: 106 to 119 times faster, inside a 60 fps frame's 16.7 ms, with the same values. Matthew, 2026-11-08: "Should we hazel-jit more of the evaluator?", and then "Compiled run first" (^ticket(722)). The program's run was most of a small edit on that slide (^report(47), experiment 2; ^report(46), compiling the run); this is the first measurement of it compiled. In Node on the laptop, not yet in the app.

Next, in the app (what next, step 10): on a slider's step, call the slide's compiled program with the new model, and draw each livelit whose answer changed straight from its JS, the route compiled views already take; then timed in Firefox on GitHub's machines. Probes and the editor's highlights stay with the interpreter, run after. The data: 045/data/run-witch.json; the code at 0926a80c74 on trial/694-view-jit.

Where the time goes now#

The trip back is 79% of a compiled render: 0.27 ms of 0.34. The trip in takes 0.037 ms (11%) and the compiled view 0.043 ms (13%), so the way back costs about 7 times the way in, and about 6 times the view itself. Each step was timed alone, warm, and the three add up to 0.35 ms, about the whole render's time.

One Polygons render, compiled: 0.34 ms in all, its three steps each timed alonethe model into JS (to_js): 0.037 ms (11%)the compiled view: 0.043 ms (13%)the answer back as Hazel (of_js): 0.27 ms (79%)dashed: the whole render, timed in one go
The same session as above, medians of 30 runs each: the trip in on the slide's model, the call on that model already in JS, and the trip back on that call's answer. Percentages are of the whole render's median.

Why the way back costs more: there is more of it. The compiled view needs its model as JS values, so the model is converted on the way in; and the app draws a Hazel value, so the view's whole answer, its command and every node of its Html tree, is made again as a Hazel term on the way out. The slide's model is 115 nodes (cons cells, tuples, constructors and the numbers and strings in them); the answer is 861, about 7.5 times as many, with 7 event handlers, none of them capturing a value. Per node, the way back costs a little more: 0.31 µs a node, against 0.32 µs a node in.

Making ids is now 16% of the way back; yesterday it was almost half. Each Hazel term carries an id, and each term the way back makes gets a fresh one. The trip back makes 906 terms; 906 fresh ids now take 0.044 ms (0.05 µs each), and with no ids to make at all, every term given one shared id, the trip back would take 0.20 ms instead of 0.27. How, under cheaper ids.

Update, 2026-11-07 07:40: this paragraph said each fresh id was a random UUID. It is not: Id.mk was already a counter, with a random tail drawn once per session. What cost was building each id's 16 characters out of eight concatenations; that is what changed.

What else could make the way back cheaper: keep the answer in JS until it is drawn, so the part of the app that turns it into the page's elements reads JS values directly; convert lazily, only the parts that are read; or keep what did not change since the last render. The first and the last are tried below.

Three ideas for the way back#

All three work, and the one that helps most is not coming back at all. Matthew asked, on 2026-11-07: can the ids be cheaper; can a view's answer, which is only drawn, skip Hazel altogether; and can the answer come back as a diff against the last one? Cheaper ids are done, in Id.mk itself. A view's answer drawn straight from its JS makes the same page in about a third of the time, and a whole render, model to page, is then about 37 times faster than on the interpreter. A diff carries one changed point of 1,000 back 111 times faster than carrying the whole list. Both are in the app since 11-07 (^ticket(714), ^ticket(715)): a view's answer drawn from its JS, and an update compiled, its new model back as a diff, so an event that took about 80.7 ms (the definition evaluated, then its update) takes 0.050 ms. What is not there yet is a diff applied in time sublinear in a long list: that needs lists to be trees on both sides (^ticket(710)).

Cheaper ids: done#

Making 906 ids now takes 0.044 ms; made as before, in the same session, 0.29 ms (between 2.5 and 6 times as long over today's runs). An id is 16 bytes: a counter in the first eight, then eight random bytes drawn once per session. Under js_of_ocaml a string is a JS string, and Id.mk built each id by concatenating one-byte strings, eight concatenations an id. Bytes 1 to 15 are the same for 256 ids in a row, so now they are made once for each 256, and each id is one concatenation. The ids are the same as before, byte for byte. Nothing downstream of the way back reads the ids of a view's answer; the call memo already puts its keys in a form with no ids.

This is not hazel-jit's alone. The interpreter mints an id for every term it rebuilds and every binding it makes, hundreds of thousands a run, through the same Id.mk. The string-built ids came in with a commit of 2026-10-10 on #2635's line (7a5667e6f2), which dev does not have yet.

A view's answer, never made Hazel#

Yes: drawn straight from its JS, a view's answer makes the same virtual DOM in 0.30 ms, against 0.71 ms through Hazel. Through Hazel, the answer is carried back (0.27 ms), its command run down to its Html (0.0007 ms), and the Html drawn by HazelDOM into the virtual DOM (0.44 ms), which costs more than the trip back. A prototype, HazelJitDOM, reads the compiled view's JS answer and makes the virtual DOM nodes directly. Model to page, a render is then 0.38 ms, against 0.79 ms through Hazel and 14.1 ms on the interpreter.

One Polygons render, compiled, from its model to the page's virtual DOM (ms, to scale)through Hazelback as Hazel, run, drawn by HazelDOM: 0.710.79 msstraight from JSdrawn by HazelJitDOM: 0.300.38 msThe first two steps, the model into JS and the compiled view, are 0.037 and 0.043 ms on both. On the interpreter the same render is 14.1 ms.
Medians of 30 runs each, warm. Both routes make the same virtual DOM, compared as virtual-dom's own objects (event handlers compared only as functions).

The way back as a diff (^ticket(709))#

A diff of the last answer and the new one, applied to the last Hazel value, carries one changed point of 1,000 back in 0.052 ms, against 5.76 ms whole. The diff is computed in JS and stops wherever the two answers share an object: compiled code builds its answer functionally, so what it did not touch (a list's tail after the element it replaced, a field it did not set) is the same object as before. The patch keeps every part of the old Hazel value that did not change: in the test, 999 of the 1,000 elements are the old ones.

One point of n changed, carried back as Hazel: whole, or as a diff (ms, a log scale)0.001 ms0.01 ms0.1 ms1 ms10 ms100 ms10 pointswhole 0.036 msdiff + patch 0.0049 ms100 pointswhole 0.42 msdiff + patch 0.0087 ms1,000 pointswhole 5.76 msdiff + patch 0.052 ms10,000 pointswhole 58.3 msdiff + patch 0.11 ms
Medians of 15 runs each, after 5 untimed. The middle point replaced by compiled Hazel; the diff stops where the old and new lists share their tail.

An update's new model, back as a diff, in the app (^ticket(715)). On an event, a livelit's update now runs compiled, and when it answers Pure(new model), the new model comes back as a diff against the model it was given, read by the definition's Model type. The Polygons livelit's own update, on its slide's model, on twelve actions, gives the interpreter's model every time, and every shape it did not touch comes back as the old one. The bigger saving is what is no longer done: on every event the app evaluated the whole definition, 68.3 to 83.3 ms for the Polygons livelit, before applying its update (0.67 to 5.18 ms). Compiled, with the diff, an event's update takes 0.023 to 0.081 ms; a step of a drag, 80.7 ms before, 0.050 ms now. The update alone is 16 to 134 times faster. Medians of 30 runs each:

ActionAs the app ran it (the definition, then the update), msThe update alone, msCompiled, the model back as a diff, msShapes kept
Next72.81.110.0312 of 2
Prev76.30.890.0232 of 2
NewPolygon78.30.960.0282 of 3
NewPath68.30.880.0262 of 3
Toggle68.91.260.0811 of 2
Remove72.40.670.0281 of 1
SetName70.20.990.0231 of 2
SetFill71.70.970.0301 of 2
SetWidth76.21.170.0321 of 2
Down83.35.180.0391 of 2
MoveTo (holding a point)80.74.220.0501 of 2
Up (holding a point)74.80.900.0282 of 2

How often is it worth it? For a view, now, never: its answer need not come back at all. What must come back is what lives in the program: the model a livelit's update returns, and the answer of any compiled function the interpreter calls. On today's slides those are small: the Polygons model is 115 nodes, and carrying it in takes 0.037 ms. Carrying back costs about 0.3 µs a node for the Polygons view's answer, and about 5.76 µs a point for a list of labeled points with no type to read them by, so a whole list of 1,000 points is 5.76 ms of a 16.7 ms frame. A diff pays once a model holds hundreds of elements: a drawing with many points, a table, a long document.

The diff language is small. A diff is one of:

The common cases, each a quick test that patching gives what carrying back whole gives: one element changed in the middle; one put at the head; the head dropped; one put at the end; a list cut short; a list emptied; nothing changed; a constructor's argument changed; one labeled field set and the other kept; floats in a list. Putting one at the head, or dropping the head, is found without looking at the rest: the new list's tail is the old list, or the other way round.

Sublinear, not yet. The diff and the patch both walk a list from its head to the change. Each step is cheap (a few nanoseconds to compare two objects in JS, a few tens to keep an element in OCaml), so one change of 10,000 points costs 0.11 ms, but it grows with the change's position, not with the size of the change. Time in log n needs a long list to be a tree on both sides of the boundary: in the compiled code, instead of cons cells, and in Hazel's values, instead of a list literal's flat list. Adapton-style level trees, as in Fumola, give every list one shape however it was built, so a change touches one path. That is a change to how Hazel represents lists: ^ticket(710), for a talk first.

Two costs found on the way back, and fixed. A whole number came back through Printf and big-integer parsing, about 2 µs each; one that fits an int is now converted directly. And a tuple's labels were told from its indices by raising and catching an exception for each label. With both, a list of 1,000 labeled points carries back whole in 2.2 to 5.6 ms over today's runs, against 8.2 ms before.

In a browser#

On the six polygon slides in Firefox, from a release build, compiled views draw exactly what the interpreter draws, as loaded and after the same clicks, and every click's change shows sooner: 77 ms against 124 on Polygons, 319 against 368 on Full Body. A step of a drag on Polygons shows in 36 ms against 62. The gain is smaller than the livelit's own (an event's update from about 80 ms to 0.05): what is left is the rest of the page's work after an event, the program's text changed and analysed again and the editor drawn, which is now most of it (^ticket(716), ^ticket(717)).

These times end at the clicked livelit's own change (added 11-08). A click that changes a livelit's model changes the program, and the program then runs in Hazel's worker; what the run changes, on the Witch slide its picture, shows only after the run and its answer come back. Timed on the Witch in ^report(46), with a slider: the slider's own change came 0.3 to 0.4 s after the edit, and the picture's 5.3 to 8.8 s after it, compiled or not (a small edit). The milliseconds below are that first part; the seconds are not in them.

SlideLivelitsA click, compiled, msA click, on the interpreter, msLoaded fresh, compiled / on the interpreter, s
Polygons1771245.4 / 4.6
Polygon Viewer183734.5 / 4.5
Full Body4331936812.9 / 21.3
the Witch5330435419.2 / 22.2
Hands1716821314.9 / 14.5
Scenes1012214713.6 / 14.8

Beside JS written by hand#

On ^report(43)'s Petri net rule, hazel-jit's code takes about 1.8 times as long a call as the JS the example's author wrote, and 225 times less than Hazel's interpreter. The example's own rule files (its preamble, Common, Rules and Main), put together as hazeljs puts them, compile whole; the compiled on_event and the example's hand-written jsHandler answer the same 2,000 events and end on the same marking. In plain Node, the median call is 1.59 µs compiled and 0.90 µs by hand (the fastest calls 0.66 and 0.71 µs); the interpreter, as the app applies a handler (Evaluator.evaluate_open), 358 µs. ^report(43) measured about 3.4 ms a call through hazeljs, which carries the values across as well (^ticket(699)).

ReScript's and Melange's compilers do better than both, 0.55 and 0.46 µs a call on the same rule written in their languages, and the reasons are in what they write: a function's arguments as JS arguments, not an array; === on Ints; loops for tail calls; options unboxed. ^report(46), beside this one, puts the five compilers' code side by side, with what it suggests for hazel-jit's next version (^ticket(698)).

On the way: applying the same handler with Evaluator.evaluate, which closes its answer, took 63 ms a call, 175 times evaluate_open: closing copies what the closure closes over into the answer. The app applies handlers open; a library that calls Hazel functions should too.

How it works#

hazel-jit turns an elaborated Hazel term into the source text of a JS function, once, and the browser's own JavaScript engine runs it. HazelJit.compile_full, in src/language/dynamics/HazelJit.re, walks the term Hazel's elaborator makes (the same term the interpreter runs) and writes JS, which is made into a function with new Function.

A livelit's view with hazel-jit: compiled once, run on each modelonce per definitionthe definitionelaborated HazelHazelJit.compile_fullHazel to JS source texta JS functionnew Function, cachedand what the way back readsconstructor types, functionseach renderthe modela Hazel valueto_jsinto JS valuesview(model)the compiled callof_jsback, by the typesa ViewCmd, then HtmlViewCmdRunner, as todayAnything hazel-jit cannot compile, or carry back, runs on the interpreter as before; the console says why, once.
What runs where, in LivelitProj.eval_view since 4c0ed173f1.

Hazel's values in JS. Numbers are JS numbers (so Int overflow and rounding are JS's: the best case first); a list is cons cells ({h, t}, with null for the empty list), so :: takes constant time; a tuple is a JS array, each labeled component also a property by its label, so p.x is a property read; a constructor is {c: "Name", v: payload}; a function is a JS function of one argument; a module is a labeled value of its members, in order. A let or a case binds JS variables declared at the top of the enclosing function, each with a name of its own, so the code is expressions all the way down and no closure is made for a let. Types, ascriptions and parentheses are erased. Builtins written in OCaml have JS versions by name; builtins written in Hazel are compiled once, before the program's code.

What it does not compile, it says why, and that code runs on the interpreter: holes, tests, quotations and splices, projectors, partial application. A member of a module that does not compile (a livelit's expand, say) becomes a stub that says why if it is called, so the rest of the module still compiles.

The trip in and out (HazelJitValue.re). Into JS is direct: each Hazel value as above. Back is harder, in two ways. A JS number does not say whether it was an Int or a Float. So the compiler records each constructor's type as the elaborator gave it, and the type aliases the term defines, and the way back reads a number by the type expected where it sits: a constructor's argument at its argument's type, through aliases. A whole number with no type to go by comes back an Int. A function in the answer, an event handler like Attr.on_input(fun v -> SetName(v)), has to come back as a Hazel function the interpreter can apply when the event comes. So every compiled function carries the index of the Hazel function it was compiled from and the values it captured, and comes back as that Hazel function closed over those values (the compiler notes, for each function, which outer variables its body uses).

In the app#

Livelits' views and updates run compiled in the app, behind a setting that is on by default, and the interpreter runs whatever hazel-jit cannot. LivelitProj compiles each livelit definition once (kept by its term). A view is called compiled on the model, and its answer drawn straight from its JS (HazelJitDOM), at an event and before the program's run has a sample; the samples, the interpreter's own values, are drawn by HazelDOM as always (^ticket(714)). An event's update is called compiled too, and its new model comes back as a diff against the model it was given (^ticket(715)). When the compiled code answers, the definition is not evaluated by the interpreter at all.

Update, 2026-11-07 10:20: until 889271cfbb, a compiled view's answer was carried back as Hazel and drawn by HazelDOM, and every event evaluated the definition to run its update on the interpreter.

Yes, on every program tested, and the tests catch a broken compiler. test/Test_HazelJit.re has 52 tests, all passing at 4c0ed173f1 (37 at 7a7151443c): 24 small programs whose compiled results agree with the interpreter's (arithmetic, floats, recursion, tuples and labels, lists, constructors, options, strings, equality, closures, nested patterns, modules, builtins, and the Petri net rule); the Polygons slide's view, its whole Html tree equal to the interpreter's; values carried back as the interpreter's own (whole floats staying floats, a type alias, labels with no type, the Petri net's commands); a view and an event handler through the trip in and out, the handler then applied by the interpreter; and the Polygons view through it. Breaking the compiler on purpose fails them: compiling Int's + as - failed 5 of 18 programs; reading numbers without their types failed 3 tests; dropping the values a function captures failed the handler test. Since 11-07, also: a diff applied to the last value gives the new value carried back whole (ten cases); the Polygons view and a view of many forms, drawn straight from JS, are HazelDOM's drawings; and the Polygons update, compiled with its model back as a diff, gives the interpreter's model on twelve actions.

What it does not do yet#

For Wednesday's meeting#

This is item 2 of the agenda for Wednesday 2026-11-11 at 10:00 Mountain (^report(42), item 2), which asks: is the best-case framing right, numbers allowed to differ? Is compiling the view alone the right first cut? What would make a convincing comparison: which slides, and against what (the interpreter with its call memo, or Messed Up Dress Up's hand-written JS)? Item 3 asks how BuckleScript, ReScript and Melange bear on it (^ticket(698)).

Since then, ^report(46)'s small edit bears on the second question: on the Witch slide, an edit shows in the picture 5.3 to 8.8 s later, and compiling the picture's view saves 84 ms of it. The program's run and its answer are the rest.

What next#

  1. Draw a view's answer straight from its JS in the app: eval_view and the three places that draw a livelit's view, and the rest of HazelDOM's forms. Done, 11-07 (^ticket(714), 889271cfbb): the two places that evaluate a view (the live samples are the interpreter's), and every form; tried in a browser in step 4.
  2. Carry a livelit update's model back as a diff against the model it was given. Done, 11-07 (^ticket(715), 4c0ed173f1): the update compiled, its model back as a diff; an event's update 0.023 to 0.081 ms, against 68.3 to 83.3 ms.
  3. Talk through sublinear diffs, lists as trees on both sides (^ticket(710)).
  4. Try it in the app on the polygon slides, with the setting on and off, and check the drawings are the same. Done, 11-07 (^ticket(716)): in a browser, the same drawings on all six slides, before and after the same clicks.
  5. Time it in browsers on GitHub's machines, from a release build, on Polygons, Polygon Viewer, Full Body, the Witch, Hands and the woods. Done in Firefox, 11-07 (^ticket(717)): a click's change 77 against 124 ms on Polygons, 319 against 368 on Full Body; Chrome next. A whole edit, the program's run with it, timed on the Witch in ^report(46): 5.3 to 8.8 s; the other slides next.
  6. Compare the compiled Petri net rule with the hand-written one of ^report(43), the code side by side and the time per call (^ticket(699)). Done, 11-07 (28fc073ed5): beside JS written by hand, 1.59 µs a call against 0.90; the code side by side in ^report(46).
  7. Put a short note beside this one on how BuckleScript, ReScript and Melange compile the same small program (^ticket(698)). Done, 11-07: ^report(46), the Petri rule compiled by ReScript, Melange, js_of_ocaml and hazel-jit, and five changes it suggests for hazel-jit.
  8. Compile more than views: the program's run on a slide, so that under ideal conditions (no holes or errors, no probes shown, an edit to livelit models only, a run within a budget) it runs on the main thread and each livelit's model goes straight into its compiled view as a JS value. Speculated in ^report(46) (compiling the run), after it found the trip between the worker and the page, not the evaluator, to be most of a small edit; the cheaper cuts to that trip come first (what the answer holds). Begun 11-08 (^ticket(722)): the Witch slide's whole program compiles and runs in 4.2 to 5.0 ms in Node, the same values as the interpreter's 502 to 529 ms (the whole run, compiled); in the app next.

How this was put together#