Hazel reports · ^report(42) · agenda work in progress · started 2026-11-06, updated 2026-11-10 14:15

Agenda: Matthew and Cyrus, Friday 2026-11-13, 10:00 Mountain

The topics Matthew brings to his meeting with Cyrus on Friday 2026-11-13 at 10:00 Mountain time (MST, Boulder; moved from Wednesday 11-11, the usual day and time), carrying over the work that continues from their meeting of 2026-11-05 (^report(37)), in two parts: performance (undo, and Hazel compiled to JS) and hazeljs for other JavaScript developers. A work in progress: updated as items move until the meeting, so each item says where it stands, as of when, and what it needs from the meeting.

The items, by section#

ItemStatus
1. Performance: undo, and Hazel compiled to JS
1Toward 60 fps: hazel-jit so far, and try ita click on a Witch slider shows in the picture in 19 to 24 ms, and a drag runs at 57.6 to 58.6 fps; build 45 (11-10) takes a step's statics to 12 to 18 ms, from 19 to 53
2Why Hazel is slow: a thousand cuts^report(48): the 196 costs the series measured, from 33 reports, by the four design choices they come from
3Fewer, deeper fixes: Matthew Keenan's reply to ^report(48)^report(53): his message, Matthew's replies, and our response to each point; six fixes would address the causes of 116 of the 196 costs
4Undo and redo in O(log n), in space and in time: how close are we, and why not yet?measured; the O(log n) design is open
5hazel-jit: livelit views compiled to JS, to see the best casecompiled code runs 13 to 1,140 times faster than the interpreter; a livelit's definition compiles in about a millisecond, a slide's whole run in 87 to 299 ms, once; ^report(51) says how to use it in a PR
6BuckleScript and ReScript (and Melange): to know, and to compare withcompared in ^report(46) on two programs: the Petri rule, and the Witch's picture view
2. hazeljs for other JavaScript developers
7A PR to dev: Hazel's README links to the experimental hazeljs packageopened: #2812, no review yet (11-07)
8A report for JS developers: scripting your app in Hazel, the way MUDU doesdrafted: ^report(43) live, ^report(44), and the example app live at 0.0.10

In short. As of 2026-11-10 14:15.

  1. Performance: a Witch slider's step shows in 19 to 24 ms, a drag at about 60 fps (^report(51)); Matthew Keenan asks for a few deeper fixes, and ^report(53) proposes six to agree on.
  2. hazeljs for others: a README PR on dev (#2812) points JS developers to the package, waiting for a review; ^report(43) shows how an app scripts its rules in Hazel, and its Petri net example is live at 0.0.10.

1. Performance: undo, and Hazel compiled to JS#

Two threads from the last meeting. Undo: what it costs as programs grow, and how close it can get to O(log n). And a new experiment decided there: compile livelits' view functions to JavaScript, to see how much faster Hazel code can get. Measured in Node on #2635 (livelits × modular editors) unless an item says otherwise.

1. Toward 60 fps: hazel-jit so far, and try it a click on a Witch slider shows in the picture in 19 to 24 ms, and a drag runs at 57.6 to 58.6 fps; build 45 (11-10) takes a step's statics to 12 to 18 ms, from 19 to 53 #1 #

Asked by Matthew, 2026-11-08 (the goal: a 60 fps floor for small edits) · ^ticket(722) · as of 2026-11-10 14:15

A slider's step on the Witch, from the step to the picture showing it, build by build (Firefox; a log scale)the picture from the worker's answerthe picture from the slide's run, compiled, in the page1 · the branch as it wasbuild 1: a step at 6402 ms (run 42486001354)build 1: a step at 5613 ms (run 42486001354)build 1: a step at 4169 ms (run 42486001354)build 1: a step at 5208 ms (run 42486001354)build 1: a step at 6520 ms (run 42486001354)build 1: a step at 6313 ms (run 42486001354)build 1: a step at 4925 ms (run 42486001354)build 1: a step at 5535 ms (run 42486001354)4.17 to 6.52 s2 · the answer trimmedbuild 2: a step at 2091 ms (run 42490487136)build 2: a step at 1910 ms (run 42490487136)build 2: a step at 1911 ms (run 42490487136)build 2: a step at 1851 ms (run 42490487136)build 2: a step at 2383 ms (run 42490487136)build 2: a step at 2001 ms (run 42490487136)build 2: a step at 2149 ms (run 42490487136)build 2: a step at 1979 ms (run 42490487136)1.85 to 2.38 s3 · the answer unsharedbuild 3: a step at 1484 ms (run 42492117212)build 3: a step at 1350 ms (run 42492117212)build 3: a step at 1424 ms (run 42492117212)build 3: a step at 1326 ms (run 42492117212)build 3: a step at 1714 ms (run 42492117212)build 3: a step at 1381 ms (run 42492117212)build 3: a step at 1495 ms (run 42492117212)build 3: a step at 1356 ms (run 42492117212)1.33 to 1.71 s4 · the run compiledbuild 4: a step at 469 ms (run 42551267058)build 4: a step at 1659 ms (run 42551267058)build 4: a step at 318 ms (run 42551267058)build 4: a step at 1694 ms (run 42551267058)318 ms to 1.69 s5 · steps back keptbuild 5: a step at 400 ms (run 42556616487)build 5: a step at 236 ms (run 42556616487)build 5: a step at 232 ms (run 42556616487)build 5: a step at 208 ms (run 42556616487)208 to 400 ms6 · change Abuild 6: a step at 416 ms (run 42560502616)build 6: a step at 257 ms (run 42560502616)build 6: a step at 271 ms (run 42560502616)build 6: a step at 223 ms (run 42560502616)223 to 416 ms7 · change Bbuild 7: a step at 434 ms (run 42562102280)build 7: a step at 284 ms (run 42562102280)build 7: a step at 283 ms (run 42562102280)build 7: a step at 245 ms (run 42562102280)245 to 434 ms8 · change Cbuild 8: a step at 290 ms (run 42566328043)build 8: a step at 182 ms (run 42566328043)build 8: a step at 176 ms (run 42566328043)build 8: a step at 222 ms (run 42566328043)176 to 290 ms16.7 ms: one 60 fps frame10 ms0.1 s1 s10 s
A slider's step on the Witch, build by build: eight builds of one branch, one dot a step, coloured by where the picture came from, from 4.2-6.5 s (build 1) to 176-290 ms (build 8) (^report(50)).
A 3-second drag of the Witch's neck slider, frames a second, build by build (Firefox)views and the run compiled: the picture follows the dragnothing compiled: only the slider moves; the picture waits for the release5 · steps back keptbuild 5, compiled: 9.8 fps, median frame 99.6 ms (run 42556616487)9.8 fps, median frame 99.6 msbuild 5, nothing compiled: 6.1 fps, median frame 116.6 ms (run 42556616487)6.1 fps, median frame 116.6 ms6 · change Abuild 6, compiled: 22.5 fps, median frame 49.3 ms (run 42560502616)22.5 fps, median frame 49.3 msbuild 6, nothing compiled: 15.2 fps, median frame 66.4 ms (run 42560502616)15.2 fps, median frame 66.4 ms7 · change Bbuild 7, compiled: 26.4 fps, median frame 33.3 ms (run 42562102280)build 7 again, the same app with the page's view timed part by part: 34.3 fps (run 42563736665, fa2614e1f6)build 7 again, the same app with a first try at change C whose memo missed every frame: 26.2 fps (run 42564711121, bdecaec5d9)26.4 fps, median frame 33.3 msbuild 7, nothing compiled: 21.3 fps, median frame 49.4 ms (run 42562102280)build 7 again, the same app with the page's view timed part by part: 25.5 fps (run 42563736665, fa2614e1f6)build 7 again, the same app with a first try at change C whose memo missed every frame: 26.2 fps (run 42564711121, bdecaec5d9)21.3 fps, median frame 49.4 ms8 · change Cbuild 8, compiled: 48.4 fps, median frame 17.1 ms (run 42566328043)48.4 fps, median frame 17.1 msbuild 8, nothing compiled: 57 fps, median frame 17.1 ms (run 42566328043)57 fps, median frame 17.1 ms60 fps0153045
A drag of the Witch's neck slider, frames a second, builds 5 to 8, compiled and not: 9.8 to 48.4 fps compiled (^report(50)).
Build 8: every frame of a 3-second drag of the Witch's neck slider, in Firefox, one tick a frame (a log scale)compiled: the picture follows146 frames in 3.0 s: 48.4 fps; median 17.1 ms, 90th percentile 33.3 ms, longest 66.4 ms; 116 of 146 in one 60 fps framenothing compiled: it waits171 frames in 3.0 s: 57 fps; median 17.1 ms, 90th percentile 17.1 ms, longest 66.4 ms; 165 of 171 in one 60 fps frame10 ms16.7100 ms1 s
Build 8, the latest: every frame of the drag, compiled (48.4 fps, the picture following) and not (57 fps, the picture waiting for the release) (^report(50)).
The same Hazel code on Hazel's interpreter (grey) and as hazel-jit's JavaScript (teal), each as its report measured it (a log scale)a recursive sum of 1,000 numbers (Node)a recursive sum of 1,000 numbers (Node): 47.9 to 47.9 msa recursive sum of 1,000 numbers (Node): 0.042 to 0.042 msabout 1,140 times (045)the Petri net rule, four events (Node)the Petri net rule, four events (Node): 7.19 to 7.19 msthe Petri net rule, four events (Node): 0.011 to 0.011 msabout 654 times (045)the Polygons view, a render with its trip (Node)the Polygons view, a render with its trip (Node): 13.7 to 13.7 msthe Polygons view, a render with its trip (Node): 0.34 to 0.34 msabout 40 times (045)the Witch's polygon editors' views (Firefox)the Witch's polygon editors' views (Firefox): 26 to 29 msthe Witch's polygon editors' views (Firefox): 0.29 to 0.45 msabout 76 times (046)the Witch's picture view (Firefox)the Witch's picture view (Firefox): 87 to 87 msthe Witch's picture view (Firefox): 3 to 3 msabout 29 times (046)the Witch's whole run (Node)the Witch's whole run (Node): 502 to 529 msthe Witch's whole run (Node): 4.2 to 5 msabout 112 times (045)16.7 ms10 µs0.1 ms1 ms10 ms0.1 s1 s
Not a build of the app: the same Hazel code on the interpreter and as hazel-jit's JavaScript, workload by workload, a log scale (^report(50), from ^report(45) and ^report(46)).

Where it stands: on the Witch slide, a step shows in 19 to 24 ms and a drag runs at about 60 frames a second (^report(51), the Hazel-JIT Status Report, for colleagues: twenty numbered builds of trial/694-view-jit, hazelgrove/hazel#2817, each measured in Firefox and named by every figure). A step took 4.17 to 6.52 s on build 1, nothing compiled in the run; 176 to 290 ms on build 8, the figures here (^report(50)); and 19 to 24 ms on build 12, which draws from the compiled run first and edits the program after the paint. A drag ran at 9.8 frames a second on build 5, 48.4 on build 8, 57.6 on build 12 (171 of its 173 frames within 16.7 ms) and 58.6 on build 15 (173 of 177).

What is left is the work after the paint. The edit of the program is still made after each step: 126 to 193 ms of statics, syntax, the view and the outline on build 20 (^ticket(721), a choice below). New, 11-10: build 45 patches the edited item's statics instead of analyzing it again: a step's statics take 12 to 18 ms, from 19 to 53 on build 43, and the edited item's part 3 to 6 ms, from 13 to 42 (one run each). It passed CI and is on the branch since 11-10, 12:46 (^report(52)). It is also the kind of special case Matthew Keenan warns about (below, in "Fewer, deeper fixes"); ^report(53) proposes keeping it as a measurement of what finer-grained statics would buy, and landing per-item statics on dev first. The worker runs the whole program again for the probes, and its answer comes 1.4 to 2.0 s after the step; the page then spends 80 to 193 ms on it. Builds 13 to 20 took the page's work after a step from 0.56 to 0.92 s down to 0.21 to 0.32 s: the outline out of the view, the livelits an edit does not touch kept, the autosave out of the update, the projectors an answer does not change kept, and the worker's answer 198 KB, from 590 (no final stream the page dropped, and its first-order values sent as data, ^ticket(718)).

Try it with the frame-rate overlay: the Witch, compiled (the branch's latest build); build 8, with every Livelit Playground slide linked, is hosted by hazelgrove/hazel#2819; the overlay alone for dev is hazelgrove/hazel#2818.

For the meeting: The edit after a step (^ticket(721)): build 45 shows a model-only patch saves 10 to 35 ms of statics a step. Keep it as that measurement and land per-item statics on dev first, as ^report(53) proposes, or take the patch further (syntax, outline) on the branch? Should the overlay go to dev now? Would the team try the build?

Best guess (the agent's, 11-10 14:15): Keep build 45 as the measurement, and do not extend the patch to syntax on the branch. Since build 12 the picture is drawn before the edit, so the 10 to 35 ms it saves is not what a person sees, and a drag already runs at about 58 fps. Per-item statics on dev would get most of it without a special case. One or two of the team would try the build, if the link opens one slide with the overlay on, as the link above does.

2. Why Hazel is slow: a thousand cuts ^report(48): the 196 costs the series measured, from 33 reports, by the four design choices they come from #2 #

Asked by Cyrus; Matthew's answer, 2026-11-08 · as of 2026-11-10 14:15

196 measured costs, from 33 reports: one rectangle each, grouped by what they come from, coloured by where they standThe first release after a load re-parsed the whole program (the wrong parse cache was filled): commit 245 ms instead of ~60 (001#pipeline; fixed)A module binding's definition analyzed a second time: 1.79 s of 4.2 s of statics (about 43%); CLI statics 6.7 s; on dev, about 0.13 s of 6 s on an 800-function module (024#cost (also 001#issues, 017#pr2651); fixed)A livelit definition analyzed twice (synthesis, then analysis): Shirt and Pants statics 4.3 s (001#issues; fixed)Statics re-ran 3x per edit (probe pins compared to the wrong keys): head-colour slider 20.6 s (001#issues; fixed)Statics rebuilt the spine root of every item below the edit: 149 of 179 roots re-added per release; statics 42 ms (Witch), 23 ms (Full Body) (013#change; fixed)Per-member module analysis lost on #2635 after a merge, so a module literal is analyzed whole: edits in mega-mod-1k wrapped in a module ~100 ms vs 7 ms (Andrew Blinn's commit message) (018#why; fixed)Completion suggestions computed after every typed digit (a pass over the program): 178 ms, 10% of the profile (036#fix-digits; fixed)Compiling a program for the library (parse, then statics): the game's rules 797 ms; first compile in the browser 340-520 ms; Hazel 514 ms where Fumola sets up in 4 ms (027) (025#prs (also 027#next, 030#built); mitigated)Edit, undo and redo each grow linearly with the program: at 6,400 definitions: edit 106 ms, undo 292, redo 184 (163/422/340 before two fixes), each followed by ~78 ms of statics; log-log slope 1.10-1.16 (036#scaling (also 038#time); mitigated)Every let-bound function takes statics' recursive path; passes multiply with nesting (up to 4^depth): 001: nested lets 400 s; 017: 5.3 s of statics at eight levels; b2t2 example-tables 73 ms (017#pr2603 (also 001#issues); open PR)#2597 re-runs statics on the whole program after every livelit commit: 3.5 s of a 5.8 s profiled release (CachedStatics.init); release 3.76 s on #2597 against ~0.35 s on #2635 (001#pipeline; open)The commit re-makes the syntax (livelit placeholder shapes, per-item parsing): 26 ms profiled per release (001#now; open)Statics analyzes some expressions several times per multiplier (recursive lets, shadowed builtins, unannotated labelled params): up to 12x per expression on B2T2 programs, 3^d for nested recursion (001); a recursive let 3x, nested recursive lets 27x (021) (001#issues (also 021#pr-2689); open)#2597 runs whole-program statics from scratch on every update during load: 15% of the main thread (007#why; open)#2597 runs whole-program statics on every slider change (no modular editing): 5.4 s of a 13.3 s profiled change; median 8.6 s against 1.2 s on #2635 (statics 38 ms there) (008#a; open)Opening slides: statics: 23 s of 213 s (about 11%) (020#timing; open)Opening slides on #2597 (no per-item statics): statics dominates: statics 143 s of 362 s of script (about 40%); figure slides 35-71 s (6-8 s on #2635); ConstructorMap.re 45 s (4.5 s on #2635) (020#timing; open)The first event after a reset compiles the rule program: 0.5-0.7 s (502, 692, 519 ms); Fumola's slowest pull 12-21 ms (032#table; open)After an edit, readiness grows with the program (whole-program analysis): 357.5/435.4/744 ms at 1x/2x/4x Common's size (~4 ms a line); analysis 260/302/428 ms; Fumola flat ~125 ms (032#scale; open)First load of the library and its first analysis: about a second ('analyzed and run in 1148 ms') (034#mudu; open)MakeTerm rebuilds the whole top-level term every step: 523 ms, 38% of the profile (527 ms, 29% before the fixes) (036#where (also 038#time); open)DefStatics walks the whole chain of definitions every step: 283 ms, 20% (289 ms, 16% before) (036#where (also 038#time); open)Building and rebuilding a small program: first build 338-366 ms; rebuild after an edit 138-154 ms whether a module changed or not; ~180 ms in the browser (043#cost; open)The page's work after a livelit event (the program's text changed and analysed again, the editor drawn), now most of an event: a click's change 77 ms compiled vs 124 on Polygons; 319 vs 368 ms on Full Body; 304 vs 354 on the Witch; a drag step 36 vs 62 ms, while the livelit's own update is ~0.05 ms (045#browser; open)The main thread's own work on an edit before the request goes (update, a page view, statics and the request's pieces): 0.31-0.41 s to the page's first change (19-24 frames); 0.18-0.27 s before the request in the timeline run (046#witch-edit (also 046#witch-edit-parts); open)Nested module bindings multiply statics passes (3^depth on dev, 2^depth with #2651, counted from code): depth-9 function chain 31.04 and 29.59 s with #2651; 3.8-3.9x per level; depth-12 fix chain 197.2 s (024#next; other)Analysis of a module grows superlinearly with its members: 100 short members ~110 ms, 400 members ~2.3 s (4x the members, ~21x the time) (034#release-found (also 039#package); other)Initial build of the editor for a large program: 173 ms at 400 definitions up to 2,637 ms at 6,400 (036#scaling; other)re-analysis per edit (28)The code editor re-checked every tile's sort on every commit: check 16 ms, code editor 26 ms profiled (3-5 ms on the clock); 25,852 tiles per commit on mega-4k (001#now; fixed)Measuring the page after each redraw forced synchronous layouts and document-wide style recalcs: after-display effect 24 ms profiled; main-thread work 246 ms per release (001#now; fixed)The problems panel walked the whole program for incomplete tiles on every redraw: panel 13 ms, walk 6 ms profiled (001#now; fixed)A view re-evaluated every call though only one input changed: face's first evaluation after a release 43 ms (median of 12) (001#pipeline; fixed)Every redraw evaluated every livelit's view, changed or not: Kids' Choice 0.8 s (001#issues; fixed)Cursor info rebuilt the program's source and compared it structurally on every redraw: ~40 ms profiled per release (001#issues; fixed)^picture's view box walked every point; points strings built point by point: view_box 134,320 steps (56%), coords 92,703 (39%) of 238,781 view steps (004#update; fixed)The context inspector prints every prelude type whole as tiles: 6,802 tokens drawn for a 4-line program; froze the browser on Scenes (020#gamma; fixed)The page rebuilds its whole view in JS on every redraw, and a release redrew six times: about 310 ms (profiled) of a 0.43 s release (001#pipeline; mitigated)^picture's view prints every point to SVG text in Hazel code; the worker computes points one at a time: ~1.7 s per change on the main thread and ~1.5 s in the worker (profiled) (002#hands; mitigated)The page drawing a woods picture it had not drawn before: 5.7-6.6 s (0.6-1.1 s for one drawn before) (004#timeline; mitigated)HazelDOM drawing a view's Hazel Html into virtual DOM: 0.44 ms, more than the trip back (0.27 ms); 0.71 ms through Hazel vs 0.30 ms straight from JS (045#direct; mitigated)#2597's view rebuild without #2469's caches and gates: 1.6 s profiled (~0.37 s on #2635): view samples rerun 0.57 s, uncached code view 0.41 s, incremental-eval overlay drawn though off 0.39 s, whole-program re-parse 0.2 s (001#pipeline; open)Livelit views evaluated in each redraw: 44 ms profiled per release (face evaluation 21, its Html to the page 8, probe sample views 7, rest 8) (001#now; open)The app's own update machinery (frame callbacks, recomputing its views): 25% of the page's main thread (005#update; open)#2597 rebuilds the code editor's view of the whole program on every update: 77% of the main thread during load (007#why; open)#2597 rebuilds the whole code view and prints the whole program to text on every change: code view 2.3 s, program to text 1.5 s (profiled) (008#a; open)Cells' livelit views drawn without the view memo: about 0.46 s per change profiled; updated 10-14: ~340 ms of profile, perhaps 0.1-0.2 s on the clock (008#b; open)Livelit views evaluated on the page inside the editor's update: about 450 ms of a Full Body change's ~1,010 ms of page JS (the update ~860 ms) (015#change; open)Opening slides: the page's view: 55 s of 213 s of script (about 26%) over 58 slides; 30-40% on most slides (020#timing; open)Opening slides: layout: 13 s of 213 s (about 6%) (020#timing; open)Layout's walk over the program (Measured.of_segment): 78 ms, 6% of the profile (036#where; open)With the sidebar shown, every edit rebuilds the outline: 44 ms after an edit of 51 ms at 3,200 definitions; 84 after 113 at 6,400 (038#sidebar; open)The whole slide's page view, drawn five times an edit: 24-506 ms (median 117) each draw; 0.5-0.9 s an edit; the picture's own view 3.0 ms of it (046#witch-edit-parts (also 047#goal); open)Html to virtual DOM, the vDOM diff and patch, browser layout: 1.1%, 0.9%, 1.4% of the woods main thread (005#update; other)the page's view and redraw (25)Reuse check compares cached expressions by structure, walking down to the edit once per enclosing let (quadratic along the lets): reuse_check ~283 ms of a ~410 ms worker release (profiled); on dev, 2,743 ms to re-evaluate after one edit in a 400-definition program (4,353 ms with hashing alone) (001#pipeline (also 017#pr2673); fixed)Reusing a cached result walked the whole reused code to copy cache entries: 16 ms of the worker's 47 ms evaluation (profiled) (001#now; fixed)A projector update copies the whole program, so identity-keyed caches (per-item parsing) see a new program: Kids' Choice release 1.5-1.7 s; dev 3.12 ms per update on a 2,000-let program (017#pr2671 (also 001#issues); fixed)A recursive let's own name leaked into its free variables, so nothing from the Drawing library on was reused: every woods change re-ran all 610,670 steps; ~3 s of a figure move (004#reuse; fixed)The view's call memo cost more than it saved (8 entries per function, every call a miss, each paying for its key): a third of the view; woods figure size 6.1-7.3 s with the memo against 2.4-2.9 s without (004#memo; fixed)An open cell re-elaborated with fresh ids; the reuse check traced lexemes once per enclosing let (quadratic): about 2 s per change (122 slow checks of ~6,400-node subterms); GUI-only view 3.5 s against 1.2 s whole (008#reuse; fixed)The page checks the whole program for reuse on every dragged value's preview: about 40% of the page's time over a Full Body drag (profiled) (015#bridge; mitigated)Incremental evaluation saves nothing on a slider edit: Full Body 499 vs 464 ms from scratch, Witch 754 vs 701, Scenes 1,416 vs 1,453 (corrected 2026-10-13 to one protocol; conclusion unchanged) (009#reuse; open)Reuse works only per top-level binding, so nothing inside the picture is reused: incremental run skips 8-14% of a from-scratch run's steps; 75-84% of its steps are in calls whose inputs did not change (steps, checks free) (010#work; open)Every slider edit re-evaluates the whole figure, even when the picture does not change: 85-95% of a from-scratch run (Full Body, Witch); 85-92% for the 22 edits that change no shape; 85.2-89.0% (012); a position-keyed update would cost 0.0-1.7% (steps) (011#sweep (also 012#trace); open)Per-step reuse check, run where no reuse is possible: 8.0% inclusive (025#in-hazel-s-library-and-evaluator; open)Each run's new picture shares nothing with the last, so finding unchanged parts costs a whole walk: the merge 0.23 ms, as much as the whole view (0.24 ms), where a kept view would redo the neck's 17 shapes in 0.043 ms (5x less) (046#witch-share; open)incremental reuse checks (12)The recovering parser is quadratic on an unclosed bracket: 21-81 ms for well-formed modules, up to 1.8 s with an unclosed bracket (034#mudu; mitigated)Loading text the fast parser rejects: the fallback types it one character at a time, re-molding each time (quadratic): 182 s over 128 inputs; 8 KB of prose 64 s; 001 (with #2614): corpus 1,242 s, Kids' Choice 227 s (017#pr2610 (also 001#issues); open PR)The recovering parser inserts and re-grouts per character: parsing the 72 programs ~220 s; parse-heavy test groups 267 s (017#pr2614; open PR)Opening slides: building terms: 45 s of 213 s (about 21%) (020#timing; open)Opening slides: parsing: 41 s of 213 s (about 19%); Dynamic Row or Column 12.5 s, parsing 45% of it (020#timing; open)parsing on load (5)The undo history kept a whole editor state per edit, uncapped by default: ~92 MB per edit (014; 89.0 MB in 038); 1,048 MB after 12 edits; capped at 2, ~290 MB (020) / 284 MB (038); of 390 MB kept over 4 edits: types and statics 119 MB, ValueHash 98, terms 64, decoded replies 46, layout 41; #26 (014#update (also 014#what, 020#undo, 036#question, 038#space); fixed)An undo or redo rebuilt the program's syntax twice (RealizeView counted as an edit): undo 141 ms at 3,200 definitions, 263 at 6,400; redo 96 ms; a redo spent ~1.8x an edit's time in CachedSyntax.mk (038#twice; fixed)Compaction's price: restoring a compacted undo entry rebuilds its derived data: #2597: every redo 6.0-6.5 s against 2.7-3.1 s as built (014); undo 5.8 s, redo 6.1 s against a 6.9 s edit (038). #2635: redo 3.6-4.2 s (median 3.9), undos 3.5-5.1 s (014) or 3.6 s, 1.2-3.9 (038), against a 1.2 s edit (014#update (also 038#price); mitigated)The outline is rebuilt from scratch on every undo (its memo misses the restored program): 036: 211 ms, 15% of the profile, '~26 ms of each undo and redo' at 3,200 definitions. Corrected in 038 (2026-11-03 07:52): ~39 ms per undo at 3,200 definitions, 32-40% of an undo from 1,600 up (116 ms, 40%, at 6,400), ne (038#outline (also 036#twice, 036#where); open)The newest undo entry, kept whole for a fast undo, grows with the program: 0.55 MB at 400 definitions, 1.9 MB at 1,600, 6.9 MB at 6,400 (~1.1 KB a definition) vs ~0.01 MB compacted (038#persize; open)undo and history (5)Whole-program work on every edit (75)Every request sent the worker the whole elaborated program and its statics table: 478 KB of Marshal per request; encoding ~52 ms on the main thread, decoding ~22 ms in the worker (profiled) (001#pipeline; fixed)Each worker result was sent whole; marshaling it took as long as evaluating: 393 KB result; marshaling 44 ms against evaluating 48 ms; page decoding 14 ms (profiled) (001#now; fixed)The builtin Html type written out in every ascription; Macro uses closed over all builtins: a slide's request 609 KB (001#issues; fixed)After merging #2469 into #2635, a livelit release posted its changed definition whole, unshared: ~492 KB per release against ~16 KB shared; releases 20-30% slower (median 280 ms against 251.5 before) (020#merge469; fixed)The worker's sharing pass hashes every value of its answer and finds almost nothing to share: 1.4-1.6 s a result (2.0-3.4 s on an arms edit with its stream); 0 references found on the arms edits, 242 on the neck; after two changes 154-255 ms to save 0.46 -> 0.42 MB, more than encoding and decoding (046#witch-trip (also 046#witch-cuts); fixed)Hashing and encoding the request on the main thread: Full Body hashing 3.88-4.21 ms, encoding 1.96-11.22 ms per release (encoding moved with the heap, not the work) (013#question; mitigated)(agenda only) A request to the worker without sharing: Full Body after one retyped number 1.95 MB in 260 ms whole vs 26.8 KB in 4 ms shared; Kids' Choice 494 vs 52 KB (037#2-how-much-sharing-is-lost-passing-data-to-and-f; mitigated)Encoding the worker's answer with Marshal: 1.1-1.2 s for the 5.4 MB result (~0.22 s a MB) (046#witch-trip; mitigated)Decoding the worker's answer on the main thread, one long task (Marshal back, references resolved, every new value hashed): 1.4-2.0 s for the 5.4 MB result (trip run); 1.9-3.1 s (timeline run), at least 116 frames frozen; 1.3-1.5 s for a 4.4 MB stream; ~0.32 s a MB (046#witch-edit-parts (also 046#witch-trip); mitigated)Elaborations keep every source node's whitespace and comments, which nothing reads: requests 12-49% larger (five programs; probes.hz 48.0 vs 24.5 KB); 031: about a third of each program sent before #2608, and ~13.5% of the marshaled size still survives with it (through Typ.normalize) (017#prs (also 001#issues, 031#pr-2608); open PR)ValueHash's memo: a hash for every object, in a WeakMap of about two million entries: 98 MB (25%) of what four edits kept on #2597; 9.8 of 37.5 MB on #2635; stopped heap snapshots finishing (014#snapshots; open)Decoded worker results lose object identity, so identity-keyed memos miss: 0 of 192 blocks (Kids' Choice) and 60 of 137 (Full Body) came back as the objects decoded before; costs little at this size (037) (038#precompact; open)(agenda only) The first send with sharing costs double: Full Body 624 ms shared vs 308 ms whole (037#2-how-much-sharing-is-lost-passing-data-to-and-f; open)The worker encoding its result for the page: about a third of the worker's share of a woods change; result ~1 MB (004#cost; other)ShareCodec's tables of values shared with the worker build up between resets: #2635 keeps 9 MB after one edit, 94 MB after ten, then 46 MB; cap 200,000 entries (014#update; other)serialization (15)The evaluator re-applied itself to the run's five constants at every call (a closure per node, js_of_ocaml's generic call path): 30% of face view evaluation (~60 ms) (001#issues; fixed)Whole numbers carried back through Printf and big-integer parsing; tuple labels found by raising and catching an exception per label: about 2 µs a number; a list of 1,000 labeled points 8.2 ms back (045#diff; fixed)Converting a JS argument into Hazel at every call (no handles): 64x64 map 80.3 ms; 48.9 ms a call for a rule that ignores the map (029); 4,096 cells 66.5 ms converted each call (040) (029#report-27 (also 029#fix-world-passed, 040#handles); mitigated)A JS argument becomes Hazel syntax with a fresh id per node, is evaluated back, and is type-checked: time: 4,096 cells typed 139.2 ms, untyped 107.5 ms; 64 cells typed 1.49 ms (040#time; mitigated)The same boundary conversion: memory: 1,024 cells typed 80.4 MB a call, untyped 71.2 MB (040#space; mitigated)The evaluator under js_of_ocaml rather than wasm_of_ocaml: about 4x slower on fixed-precision work (001#next; open)Opening slides: js_of_ocaml's runtime with no Hazel caller: 14 s of 213 s (about 7%) (020#timing; open)The call boundary's floor: every call converts the whole JS argument to Hazel syntax, re-evaluates it, and checks its type: identity rule 8.54 ms at 16x16, 19.3 ms at 24x24; 13.8 ms vs 0.44 ms with no cells (~3 µs per node); the same rule in JS 0.003 ms (025#call (also 030#speed, 034#mudu); open)js_of_ocaml's generic calls in the evaluator's steps: caml_call_gen 7.9% + caml_call1 3.7% of self time (025#call; open)The least a call across the boundary costs, with a tiny argument: about 1 ms at every size (Hazel 1.27, Fumola 1.35 ms at 64x64); 0.889 ms vs 0.003 ms in JS (025) (027#numbers; open)js_of_ocaml turns each id's 16 bytes into a JS string by hand: about three quarters of minting an id (of the 46% above) (029#ids; open)A call into a Hazel rule in the game: 3.5 ms median vs Fumola 1.6 ms; a lever pull 13.7 ms with Hazel, 10.7 with Fumola, 9.7 with JS (032#events (also 039#speed); open)A Hazel event-handler call through hazeljs vs the same handler in JS: about 3.3 ms a call (3.2-3.4; p90 ~4 ms) vs 0.7 µs in JS; 2,000 steps ~7 s; boundary/evaluation split not measured (045: the interpreter alone 358 µs on this rule) (043#cost; open)js_of_ocaml's to_js, carrying the picture into JS: 0.88 ms of the 3.4 ms frame vs 0.08 ms building the same objects in plain JS (11x; different processes, rough) (046#witch-share; open)OCaml's Printf under js_of_ocaml for number formatting: Witch view 1.01 ms via Printf.sprintf vs 0.19 ms via toFixed (5.3x) (046#witch; other)the JS boundary (15)Building the request's statics projection walked both statics maps whole (first blamed on hashing): 001: 17 ms profiled, first given as 15 ms of hashing; corrected 2026-10-14: hashing 1-4 ms. 013: 1.9-11.9 ms per release (Full Body 11.64-12.22 ms) (013#numbers (also 001#now); fixed)Collecting streamed results re-indexed the whole elaborated program after every commit: 44 ms profiled per release (001#issues; fixed)The worker's answer carries its whole incremental cache, and the page sends it straight back: answers 86-98% larger than needed; one livelits answer 332 KB (017#pr2606 (also 001#issues, 005#fixes); fixed)The page rebuilt an index of the whole elaboration for each new evaluation: 204 ms of a 949 ms page update (profiled) (008#index; fixed)(agenda only) The worker reassembled the program from its pieces on every request: 47 ms on Full Body even when nothing changed (0.1 ms sent whole), 8 ms on Kids' Choice (037#2-how-much-sharing-is-lost-passing-data-to-and-f; fixed)The observation trace shipped to the page, where nothing reads it: 1.40 MB of the 5.4 MB result (1.27 MB the environments of 5 span-close events) (046#witch-answer; fixed)Each item's spine root carries the whole program below it, so the request grows with how deep the edit is: 3.6 ms at item 26 of 167, 20.8 ms at item 134; 808 vs 5,768 nodes copied (~46 per item above the edit) (013#left; open)Moving the livelit views into the worker makes the final picture wait for the trip: final picture +0.28 s later in UX mode (8 of 10 rounds) (016#release; open)The eval worker's own bookkeeping: WorkerMetrics.re 4.3 s + WorkerServer.re 6.2 s, about 10 s over 58 slides (020#timing; open)(agenda only) A one-literal edit re-sends about 10% of a chain of lets: about 10% of the program; every let around the edit hashes anew (042#1-undo-and-redo-in-o-log-n-in-space-and-in-time; open)the worker trip (10)The worker yielded with setTimeout after every 5,000-step slice; chained timeouts clamp to ~4 ms: 5.8-6.2 s of a ~10 s woods change idle between 1,292 slices (3.9-4.4 s evaluating) (004#timeline; fixed)Stream messages swamped the page (a full update per message): page busy 45.5 s after opening a 1,000-item program; 46.7 s for 2,000 (005#fixes; fixed)#2597 runs a full page update for every stream message, and its worker posts after every slice: 2,520 messages at ~140 ms each; Scenes first picture 287.5 s (12.5 s on #2635), Witch 173.1 s; worker idle 98.7% (007#why; fixed)Every preview in a drag makes the page recalculate: freeze 4.02 s per 1.5 s drag (~91 ms per input) (016#table; mitigated)scheduling (4)Values moved across boundaries (44)Each id minted by copying a byte buffer to a string; polymorphic compare on ids, names, ints: face view evaluation ~61 ms median (~58.5 ms min) (001#issues; fixed)(agenda only) Two slides were never sent in pieces: livelit annotations reused the signature's ids, so the whole program was re-encoded every request: ~200 ms a request on Full Body, ~55 ms on Kids' Choice (037#2-how-much-sharing-is-lost-passing-data-to-and-f; fixed)(agenda only) Fresh ids for an item's body hole on every analysis made undo miss the worker's memo: undo/redo 40-55 ms; an undo posted 7 KB instead of ~130 bytes; Kids' Choice undo still 15.8 ms (037#2-how-much-sharing-is-lost-passing-data-to-and-f; fixed)Making ids for every term the way back makes: 906 ids took 0.29 ms, 'almost half' of the way back. Corrected 2026-11-07 07:40: Id.mk is a counter, not a random UUID; the cost was eight string concatenations per id (from 7a5667e6f2 on #2635's line, which dev lacks) (045#ids (also 045#boundary); fixed)Minting fresh ids: 46% of a list loop's profile (sumbuild(1000): 1,158 of 2,508 ms); 4% of a plain loop (029#ids; mitigated)The evaluator gives a fresh 16-byte id to every node it builds: 461,422 ids to build a 33,847-node woods picture (7,650 distinct); a slider edit mints 84,528 to 423,362 (009#evaluation; open)Fresh ids make worker messages bigger: results 11% larger (387,625 vs 347,920 slots); requests 1.99x (43,248 vs 21,728) (009#wire; open)Analyzing an item again renames what statics adds; the change spreads up the chain of lets: 667 of Full Body's 111,462 nodes renamed, changing 692 hashes; 6,055-18,637 ids a slider edit; the reuse check falls back to comparing structure (105 parts vs 46) (009#statics; open)Id.mk mints a UUID per node (Uuidm.v4's byte copy under js_of_ocaml): Id.mk ~20% of all time; of_js 10% of the floor; the top self-time entry is caml_subarray_to_jsbytes (025#call; open)Comparing ids (Id.compare) inside the walks: 134 ms, 10% of the profile (036#where; open)When ids change, the reuse check compares terms in full: incremental evaluation 7-15 times slower than fresh on Hands and Eyes (004#casts; other)ids on every term (11)The evaluator unrolled the recursive Html type (47 constructors) at every Html node: a sixth of the page's time in the woods; an uncached check another 5% (004#casts; fixed)Giving a value a type rebuilt it whole at every typed boundary, and the call memo re-keyed the copies: woods picture (15,500 nodes) copied; about a quarter of the view every redraw; memo keys copied the picture three times per change (006); 2,000 tuples passed 30 times 382 ms (dev microbenchmark) (004#update (also 006#update, 017#pr2679); fixed)#2681's type memo is asked at every part of every fresh argument (all misses), raising the floor: floor 8.54 -> 10.1 ms at 16x16 (+18%; +9% in the floor driver); per call 4,137 memo lookups (all misses), 2,580 writes, 6,734 type-hash lookups (025#floor; fixed)A list loop re-types its whole list every iteration (an ascription pushed through every element, a fresh term and id each): building and summing 3,000 numbers 4,591 ms vs Fumola's 24.7 ms (186x); mapinc 103x; 60% of sumbuild(1000)'s profile inside Ascriptions.re (029#re-type; fixed)Ascribing a constructor application compares two copies of the same sum type in full (the Html type, at every node of a view): Polygons click 15-17 s profiled, the ascription step 88% of it; dev benchmark 74.5 ms (017#pr2661 (also 001#issues); open PR)A recursive function with an annotated list parameter re-walks its whole argument at every call (quadratic): 205 ms at 400 elements (017#pr2681; open PR)An annotated recursive helper is re-checked over the rest of the list at every step (quadratic walk): shipped World rule 144 ms at 16x16 vs 18 ms unannotated; 678 vs 40.8 ms at 24x24; 58.6% of a deep find's profile in Ascriptions.transition_multiple (025#quadratic (also 034#mudu); open PR)The same ascription re-checks inside the woods picture's view: memo off vs whole memo 2,823 vs 2,416 ms (runner 1), 2,601 vs 2,214, 2,061 vs 1,749 ms (~14-16%) (025#woods; open PR)Pushing the parameter type through the whole argument record, a fresh Asc node and id per element: 16% of the floor of a 16x16 call (025#call; open)The parameter's type annotation is re-checked against the converted value on every call: a typed call about 2.8x an untyped one, even with direct conversion (040#time; open)type checks at run time (10)Every livelit use evaluated the whole livelit definition, then copied it unshared: Shoes and Hair analyze 4.3 s (001#issues; fixed)Finished livelit definitions and views: every helper copied into every closure, per event and per redraw: Kids' Choice release 4.6 s; Polygons click ~11 s (001#issues; fixed)A function Hazel's JS library returns has its environment substituted into its body, so a held list is re-evaluated at every call: h_ref 0.234, 1.14, 3.94 ms for held lists of 100, 1,000, 3,000 vs Fumola ~0.291 ms (029); 4,096 numbers held: 5.31 ms and 29.0 MB a call; World rule 90 ms a move at 64x64 (040) (029#re-walk (also 040#held); fixed)Applying a handler with Evaluator.evaluate, which closes its answer, copies what the closure closes over: 63 ms a call, 175x evaluate_open (358 µs) (045#hand; mitigated)Variable lookups, environment frames and ascriptions mint most of the evaluator's ids: variable lookups 38%, environment frames 20%, ascriptions ~30% of ids minted (009#ids; open)A value held in a closure is re-stepped when substituted into each call: walk to index 0 still O(L): 7.319 ms at L=1024, 1.443 ms at L=256; converting the map once into a closure 24.8 ms at 16x16 (025#t-steps; open)Environment lookups: 7.2% of a loop, 2.3% of sumbuild, 0.2% of h_ref (035#where; open)The picture written out afresh in each of four samples (substitution makes each copy new, so even the encoding cannot share them): probes 0.34-0.35 MB of the 0.42 MB answer after the changes (046#witch-cuts; open)environments (8)The splice's value carried back to Hazel and in again: 20 of the 21 ms of the Witch picture drawn from JS (046#witch-45 (also 045#direct); fixed)The evaluator visits values that are already final (values are expressions): a third of a loop's passes take no step (count(1000): 14,009 passes for 9,007 steps); h_ref(3,000) 3,008 passes for one reference (029#fix-fast-path; mitigated)The way back: a compiled view's answer made again as Hazel terms: 0.27 ms of a 0.34 ms compiled render (79%), against 0.037 ms in (11%); the answer has 861 nodes vs the model's 115 (045#boundary; mitigated)Carrying a changed value back into Hazel whole: a list of 1,000 labeled points 5.76 ms (5.76 µs a point; a third of a 16.7 ms frame) (045#diff; mitigated)Re-stepping the converted argument: of_js builds unevaluated syntax the evaluator steps back into the value it was: 56% of the 13.8 ms floor of a 16x16 call (025#call; open)Sending closed, first-order values as Hazel terms (ids on every node, a sharing table): the Witch's picture 142.2 KB, 24.0 ms to encode and decode as terms vs 48.0 KB, 6.09 ms as data (3.0x smaller, 3.9x quicker); all 108 samples 275.9 KB as terms vs 144.7 KB as data (047#exp1; open)Converting a value term to data after the fact: 110.0 ms for the picture (templated from data/hazel-exp1.json; 276.3 ms for all samples). Caveat: the text says the first, quadratic version took 110 ms and was fixed, yet the filled value is also 110.0, so the post-fix (047#exp1; other)values are terms (7)Auto-probe rebuilt the whole top level's skeleton every frame (memo keyed on a segment every edit replaces): 244 ms, 13% of the profile (036#fix-root; fixed)A probe's environment written out whole: the Drawing module in the sample of a probe whose value is a few bytes: result 5.4 MB for a 10 KB request (~536x); probe samples' environments 4.14 MB (77%); Drawing alone 3.8-3.9 MB (~70%), kept because an explicit probe keeps every name its expression uses and Sample.Env.elide substitutes (046#witch-answer (also 046#witch-cuts); fixed)The evaluator's live-feature stages (state merge, reuse check, probe sample, effects) run on every pass, even with no feature in use: 25.0% of a loop, 43.6% of h_ref(3,000); with the trampolines 37% of a loop and 66% of h_ref; the rule itself 7% (029#hazel-step (also 035#where); mitigated)Per-step state merge, run with no live feature in use: 8.1% inclusive (025#in-hazel-s-library-and-evaluator; open)Per-step probe sampling, run with no probes: 6.8% inclusive (025#in-hazel-s-library-and-evaluator; open)Samples' environment copies in retained memory (a code comment, not measured in the series): once about 80% of retained memory (047#why; other)probes and samples (6)Values held as terms (42)Evaluating a livelit's view on the page: about 50% of the page's main thread, about 69% counting the GC it causes (005#update; mitigated)Hazel walks the same list more slowly than Fumola: 64x64 passed 346 vs 145 ms (2.4x), held 254 vs 26.3 ms (9.7x) (027); 341 vs 148 ms (2.3x), 261 ms of it walking (~64 µs a cell), held 256 vs 28.7 ms (8.9x) (029) (027#numbers (also 029#report-27); mitigated)A livelit view on Hazel's interpreter (Polygons): a render 13.7 ms on the interpreter vs 0.34 ms compiled, warm, with the trip in and out (40x); the compiled call alone 0.043 ms (315x); Petri rule 7.19 vs 0.011 ms (630x); recursive sum of 1,000 47.9 vs 0.042 ms (1,152x) (045#speed; mitigated)A small rule on Hazel's interpreter vs compiled code: 358 µs a call (evaluate_open) vs hazel-jit 1.59 µs, hand-written JS 0.90, ReScript 0.55, Melange 0.46 µs (225x hazel-jit) (046#speed (also 045#hand); mitigated)The Witch picture's view on the interpreter: Hazel test: a frame 155 ms (6 fps) vs 3.4 ms compiled (45x), most of it the command evaluating the splice's value; Firefox: 87 ms (11 fps) vs 3.0 ms (29x); polygon editors 26-29 ms vs 0.29-0.45 ms. Corrected 11-07 13:28: (046#witch-frame (also 046#witch-firefox); mitigated)Evaluating the face's own view, the largest single cost left: ~70 ms per release (001#next; open)The evaluator's own work in the view (variable lookups, pattern matching, fresh ids): about 500 ms of the woods view (004#update; open)Opening slides: evaluation: 10 s of 213 s (about 5%) (020#timing; open)Each evaluation step costs about 3 µs: ~3 µs a step; a plain walk 25-80 µs per cell; countdown 128 steps 3.836 ms (3.162 ms after the PRs, -18%) (025#call; open)Each Hazel evaluator pass costs far more than a Fumola step: ~2.6 µs per Hazel pass vs ~0.13 µs per Fumola step, 'some 20 times as much' (029's body); the series index, 035 and 047 say 'about 15 times'. Net Fumola 10x faster on the loop, 6.5x on calls (029#steps (also 035, 047#experiments); open)Building the World map: three list walks at the per-pass cost: 1,539 ms at 64x64 (order check 662, count 286, build 927); 60-70 µs a cell; set-up 2,136 ms vs Fumola's 326 (~6.5x) (029#fix-game-map (also 030#setup); open)The program's run on the evaluator in the worker: 1.2-2.6 s of a 5.3-8.8 s small edit (18-20%, 1.1-1.3 s on the neck edits); after two changes 1.0-1.1 s (44-56%); with sharing dropped 0.81-0.92 s (50-64%), now the largest cost (046#witch-edit-parts (also 046#witch-trip, 046#witch-cuts, 047#goal); open)interpretation itself (12)ValueHash keeps hashes in a JS WeakMap side table that slows as it grows: identical woods evaluations 2.3, 5.5, 6.3 s in one session (17.2 s after two slides) as the heap grew 685 MB -> 1.2 GB; corrected 2026-10-13: the '23 times slower' was the table, not derived names (009#merkle; fixed)Garbage collection during view evaluation: 21% of the page's main thread (005#update; open)Garbage collection in the boundary floor and in a plain walk: 18% of the floor (with 'the rest'); 19.8% of self time in a held-list walk; 2.45/2.54/2.39 ms per identity call (025#floor; open)Garbage collection on every pass (a trampoline closure, a state record, a fresh term per result): 36% of a loop's profile (count(5000): 1,032 of 2,836 ms); 15.8% of sumbuild(1000); 13.7% of h_ref (029#hazel-step (also 035#where); open)Garbage collection and the rest, in the undo probe: 370 ms, 27% (375 ms, 21% before) (036#where; open)Whole-program memos (Statics.mk keeps 16 programs, MakeTerm 8 parses) fill up: about 19 MB per edit until they reach their bounds (014#caches; other)The same compiled view runs 6x slower inside Hazel's process (likely its heap and GC): 1.16 ms vs 0.19 ms in a benchmark process (046#witch-frame; other)allocation, GC (7)Eight fresh stage closures per node; pass-through stages add trampoline bounces: call-heavy benchmark 499 ms min, 607-644 ms median before; agenda 037: dev takes 206,834 steps on the PerfBudgets program against 96,438 on #2635 (001#next (also 037#3-why-2635-s-evaluator-takes-half-dev-s-steps-on); fixed)The trampoline in the evaluator's steps: trampoline run 3.5% + bind 2.6% of self time (025#call; open)Trampolines for stack safety (about five closures and continuations per pass): 11.7% of a loop, 22.4% of h_ref, 3.5% of sumbuild (035#where; open)The stack overflows on long let chains and large modules: Stack_overflow at 8x Common (184 lines) after an edit (032); ~150 module members overflow Node's default stack (034, 039); the undo probe at 6,400 definitions crashed 4 of 6 runs with an 8 MB stack (036) (032#scale (also 034#release-found, 036#method); open)trampolines (4)The picture is a flat list of shapes in absolute coordinates, so moving a part moves every point: one slider changes up to 113 of 133 shapes (a group tree: at most 14 nodes); arm-angle trace distance 20,206 vs 5,104 steps on the tree (011#representation (also 012#scratch); open)Walks over the picture's lists rerun down to the last changed shape: lists as named cells would take 10.1% off the update (to 1,509,299 steps over 63 edits); 0.6 points median, at most 5.1 (011#cells; open)Hazel has no map, so a rule walks a list to find a square: 254 ms at 64x64 held, 346 ms passed, against Fumola's held HashMap at 0.54 ms (471x and 641x) (027#numbers; open)A game rule scans a list each call (no map): 0.7 ms per pull with 10 links, 5.7 ms with 100, 65 ms with 1,000 (020#play; other)data layout (4)Paying for the editor ever (27)Jumping to a projector walked the caret token by token: ~190 ms per projector click (001#issues; fixed)Slide code found the head's frame per point instead of once: Eyes sliders 1.5-1.8 s (002#face; fixed)Autosave prints the whole program inside the change; with probes the print was quadratic in top-level items: about 600 ms a change (whole program) and about 1 s (GUI only); updated 2026-10-14 from 0.55 s (008#update; fixed)The app evaluated the whole livelit definition on every event before applying its update: 68.3-83.3 ms per event for the Polygons livelit (its update alone 0.67-5.18 ms); a drag step 80.7 ms (045#diff; fixed)Hands redraw grows with the finger count (not profiled): about 0.3 s per finger; 99 fingers 32.30 s against 5 ms in the game; 100 claws 8.19 s (003#cost; open)The library's size and load: hazel-lib.js 2.8 MB; page load ~525 vs 270 ms (Hazel vs JS); heap 67 vs 51 MB; 643 KB over the wire (034) (025#t-game (also 034); open)Hazel's tiles in the game: a whole Hazel app per script box, made one at a time: ~3.7 s for six boxes (3.0-4.5 s); the run ~4 s longer than with JS (17.4 vs 13.1 s) (032#table; open)hazel-jit's own output: an array per call of a tuple function, generic equality, no loops for tail calls, boxed options: 1.59 µs a call, 2.9x ReScript's 0.55 µs; 9% behind ReScript on the Witch view (046#speed (also 046#suggests); open)other (8)Other (8)fixed (on some branch): 59mitigated: 28a fix in an open PR: 8open: 88unknown, bounded or n/a: 13
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)).
A slider's step on the Witch slide, from the edit to the picture showing it, in Firefox: each change so far, and the goal (a log scale)before the changesbefore the changes: 4.2 to 6.5 s (run 42486001354)4.2 to 6.5 s, 250 to 391 times the goala module kept out of a probe's environment, the trace cleareda module kept out of a probe's environment, the trace cleared: 1.9 to 2.4 s (run 42490487136)1.9 to 2.4 s, 111 to 143 times the goalthe worker's answers unsharedthe worker's answers unshared: 1.3 to 1.7 s (run 42492117212)1.3 to 1.7 s, 80 to 103 times the goalthe run compiled in the page (report 049)the run compiled in the page (report 049): 0.3 to 0.5 s (run 42551267058)0.3 to 0.5 s, 19 to 28 times the goalthe goal: 60 fps16.7 ms a step0.01 s0.1 s1 s10 s
The Witch slide's small edit at each cut so far, against a 60 fps floor, on a log scale (^report(48)).

New, 11-08: Cyrus asked why Hazel is slow; Matthew says death by a thousand cuts, and ^report(48) is the substance behind it (^report(48)). The series has measured 196 separate costs in 33 reports; many are most of the workload they were found in, and many make one another larger, so removing the largest exposes the next. They come from four design choices, each applied everywhere: values held as terms (42 costs: ids on every node, environments substituted in, run-time type checks on values, probes writing values out); whole-program work on every edit (75); values moved as terms across boundaries (44); and an interpreter that pays for the editor at every step (27: per pass about 20 times a Fumola step). Most fixes are on the livelits and trial branches; of the PRs against dev the ledger names, two are merged and nine open. The Witch's small edit, change by change: 4.2 to 6.5 s, now 1.3 to 1.7 s, still 80 to 100 times a 60 fps floor. Matthew Keenan answered it on Slack on 11-09, the next item.

For the meeting: Which of the four families to change first? Is a 60 fps floor for small edits the right yardstick for Hazel?

Best guess (the agent's, 11-10 14:15): Whole-program work on every edit first: the largest family, 75 costs, taken up by per-item statics (next item). A 60 fps floor is the right yardstick for small edits such as a slider step, where the series has shown it can be met; not for opening a program or a large edit, where a few hundred milliseconds is fairer.

3. Fewer, deeper fixes: Matthew Keenan's reply to ^report(48) ^report(53): his message, Matthew's replies, and our response to each point; six fixes would address the causes of 116 of the 196 costs #3 #

Asked by Matthew Keenan, on Slack, 2026-11-09; Matthew's replies 11-09 and 11-10 · as of 2026-11-10 14:15

New, 11-10: Matthew Keenan's gut reaction to ^report(48) is to fix the costs together, in a few well-chosen changes, not one at a time; an agent fixing them one by one would spread special-case logic through the codebase. ^report(53) quotes his message and Matthew's replies, and answers each point from the series' numbers: they bear out each point the series measured, with two refinements (a hash belongs on the node it describes; a probe's environments are large only on their way to the page).

Six fixes, all from his message, would address the causes of 116 of the 196 costs: Merkle hashes in the grammar; cheap ids kept temporary inside the evaluator; a value's type checked once; the worker as a language server; per-item statics on dev; and Bonsai for derived state. Ids and per-item statics can start now; the others are design work first. The hazel-jit branch stays a prototype and a measurement; ^report(52) ranks its changes and orders a redo by hand. The report ends with the causes his message left out, the interpreter and the JS boundary the largest, each with a question for a gut opinion.

For the meeting: Do we agree on the six fixes, or a different short list, and in what order? Who takes ids and per-item statics, which can start now? A gut opinion on the interpreter and the JS boundary, the causes no fix here addresses.

Best guess (the agent's, 11-10 14:15): Per-item statics first (written, running on #2635, and aimed at the largest family), then cheap ids (written, one module), then a type checked once (after counting the checks), then Merkle hashes; the language server and Bonsai last, together, since both change how the page and the worker divide the work. The interpreter: hazel-jit stays a livelit's fast path for now, not a second way to run Hazel, since keeping two evaluators in step is a standing cost for a small team. The JS boundary: closed, first-order values get a representation of their own, ^ticket(718)'s data form, as a seventh fix. On the branch, with one other change, it took the worker's answer from 590 KB to 198 KB, and the Witch's picture is 48 KB as data against 142 KB as terms.

4. Undo and redo in O(log n), in space and in time: how close are we, and why not yet? measured; the O(log n) design is open #4 #

Asked by Cyrus (2026-11-05), carried over by Matthew · ^ticket(665) · as of 2026-11-03, the last measurements

Where an edit, undo and redo spend their time (% of the profile)MakeTerm's top-level passrecord_top_frame, the items' spansMakeTerm's top-level pass: 38%38%DefStatics' chain walkstep_chain, calc_chainDefStatics' chain walk: 20%20%the outline, rebuilton an undo or redo (#2469's sidebar)the outline, rebuilt: 15%15%Measured's walkpositions of the top levelMeasured's walk: 6%6%everything elsethe edited definition itself, GC, ...everything else: 21%21%
Time: what is linear is a few passes over every top-level definition, not the undo history. Profile at 3,200 definitions after the first two fixes (^ticket(665), 2026-11-02).
MB of heap each undo entry adds, by program size0246400 defs400 definitions, an entry kept whole: 0.55 MB0.55 whole400 definitions, compacted: about 0.011 MBabout 0.011 compacted1,600 defs1,600 definitions, an entry kept whole: 1.9 MB1.9 whole1,600 definitions, compacted: about 0.009 MBabout 0.009 compacted6,400 defs6,400 definitions, an entry kept whole: 6.9 MB6.9 whole6,400 definitions, compacted: about 0.0 MBabout 0 compacted
Space: a compacted entry costs about nothing at every size; the entry kept whole for a fast undo grows with the program, about 1.1 KB a definition (GitHub run 41695584813, one run).
10301003004008001,6003,2006,400definitions in the program (log scale)mslinearundo at 400 definitions: 18.5 ms after the first two fixes (23 before)undo at 800 definitions: 30 ms after the first two fixes (38 before)undo at 1,600 definitions: 61 ms after the first two fixes (80 before)undo at 3,200 definitions: 120 ms after the first two fixes (176 before)undo at 6,400 definitions: 292 ms after the first two fixes (422 before)undo 292redo at 400 definitions: 13 ms after the first two fixes (16 before)redo at 800 definitions: 16.5 ms after the first two fixes (30 before)redo at 1,600 definitions: 41 ms after the first two fixes (63 before)redo at 3,200 definitions: 85 ms after the first two fixes (130 before)redo at 6,400 definitions: 184 ms after the first two fixes (340 before)redo 184edit at 400 definitions: 10.5 ms after the first two fixes (14 before)edit at 800 definitions: 10 ms after the first two fixes (16.5 before)edit at 1,600 definitions: 22 ms after the first two fixes (34 before)edit at 3,200 definitions: 43 ms after the first two fixes (72 before)edit at 6,400 definitions: 106 ms after the first two fixes (163 before)edit 106after the first two fixesbefore
Each step against program size, both scales logarithmic: parallel to the dotted guide means in proportion to the program. Release build, medians of 12 (^report(36)).
050100150undoundo before the fix: 141 ms141 beforeundo after the fix: 85 ms85 afterredoredo before the fix: 96 ms96 beforeredo after the fix: 41 ms41 afteran edit: about 46 msan edit: 46 msms per step at 3,200 definitions
The third fix (9df1b2601e, on #2635): a redo now costs an edit; an undo, an edit and the outline (^report(38)).

Matthew showed Cyrus the analysis of undo's cost on 2026-11-05 (^report(38)). The two questions continue: how do we get closer to O(log n) for an undo and a redo, in space and in time, and why are we not there yet, in each.

Time, where it stands. Every step grows in proportion to the program: on a program of n top-level definitions, an edit, an undo and a redo each have a log-log slope of 1.1 to 1.16 (^report(36)). Three fixes on #2635 made each step cheaper without changing that: the program's root id read from a cache (394552d5d0), no completions after a numeral (bfa36a6ede), and realizing the view after an undo no longer counted as an edit (9df1b2601e). Now a redo costs about an edit (41 ms against 46 at 3,200 definitions, dev build, one run), and an undo costs an edit plus a rebuild of the outline (85 ms).

Time, why not O(log n) yet. The incremental caches do their part: an edit, an undo or a redo re-parses one or two definitions and re-measures one or two chunks. What is linear is a handful of passes around them that walk every top-level definition: MakeTerm's top-level pass (about 38% of the profile at 3,200 definitions), DefStatics' walk of the chain of definitions (20%), the outline rebuilt from scratch on an undo (15%; only #2469's modular editors have it) and Measured's walk (6%). None of it is the undo history: pushing and popping an entry costs almost nothing. The top level is a list of definitions, so any pass over it, or any summary of it rebuilt after a change, is O(n). Not measured yet: evaluation and the view during an undo.

Space, where it stands. Dev keeps a whole copy of the editor for every edit, and caps the history only when a setting that is off by default is on (on #2597, Full Body kept 89 MB more per edit). Andrew Blinn's compaction (6010128b7d, on #2469 and #2635) drops each entry's derived data and keeps its zippers: then an entry adds about 0.01 MB at 400, 1,600 and 6,400 definitions, flat, because consecutive entries share nearly all their structure (^ticket(665), GitHub run 41695584813).

Space, why not O(log n) yet. Two parts are still linear. The newest entry of each stack is kept whole so that the latest undo is fast (032fe3aca6): 0.55, 1.9 and 6.9 MB at the three sizes, about 1.1 KB a definition. And what compaction drops (syntax, statics, evaluation) is rebuilt on a restore, so the space saved is paid in time. One caveat on the flat number: the probe typed into the same definition again and again; edits spread over the program may share less.

Toward O(log n), the candidates. (a) The top level as a balanced tree of definitions, each node with summaries of its subtree (the names it binds, its part of the skeleton, its rows): each pass touches only the edited definition's path, an entry shares every other node, and the worker's request after an edit shrinks the same way (^ticket(666) found a one-literal edit re-sends about 10% of a chain of lets, every let around the edit hashing anew). (b) Undo as an inverse edit applied to the live state, so derived data updates as it does for a keystroke and no snapshot needs rebuilding. (c) First, and cheapest: build the outline incrementally, which every undo pays for, and every edit while the sidebar is shown.

For the meeting: Cyrus's read of the two directions, a balanced tree of definitions or undo as an inverse edit, and which to prototype first. Is the incremental outline the right first step? For space: does flat-per-compacted-entry answer the question, or should the next measurement spread edits over the program, use a release build, or count the newest whole entry differently?

5. hazel-jit: livelit views compiled to JS, to see the best case compiled code runs 13 to 1,140 times faster than the interpreter; a livelit's definition compiles in about a millisecond, a slide's whole run in 87 to 299 ms, once; ^report(51) says how to use it in a PR #5 #

Asked by Matthew and Cyrus (decided 2026-11-05) · ^ticket(694) · as of 2026-11-09 21:35

One step of a slider on the Witch slide, in Firefox: each part, from the slider's event (a log scale)the slide's run, compiled: a step's first eventthe slide's run, compiled: a step's first event: 8 to 21 ms (4 readings, run 42554043524)8 to 21 ms, about 48 to 125 fpsthe same, the step's next event (a drag)the same, the step's next event (a drag): 2 to 3 ms (4 readings, run 42554043524)2 to 3 ms, about 333 to 500 fpsthe picture, drawn from the compiled runthe picture, drawn from the compiled run: 286 to 386 ms (4 readings, run 42554043524)286 to 386 ms, 17 to 23 framesthe slider's own livelit redrawnthe slider's own livelit redrawn: 286 to 386 ms (4 readings, run 42554043524)286 to 386 ms, 17 to 23 framesthe picture, nothing compiledthe picture, nothing compiled: 1352 to 1744 ms (4 readings, run 42554043524)1.35 to 1.74 s, 81 to 105 frames16.7 ms: 60 fps, the floor1 ms10 ms100 ms1000 ms
One step of a slider on the Witch slide, in Firefox, with the slide's whole run compiled and run in the page at the slider's event: each part, against a 60 fps frame, a log scale (^report(49), 11-08 evening).
One step (neck 30 to 28, views compiled): the picture at 286 ms, the worker's answer at 1.33 sthe slide's run, compiledhazel-jit: the run: 8 ms at 0 mshazel-jit: the run: 3 ms at 8 msthe page: update, statics, viewupdate: 13 ms at 12 mssyntax: 13 ms at 25 mscalculate: 14 ms at 25 mscursor info: 1 ms at 38 mscolor map: 0 ms at 39 msview: 87 ms at 39 msupdate: 9 ms at 126 mscalculate: 44 ms at 135 msstatics: 27 ms at 136 mssyntax: 12 ms at 163 mscursor info: 0 ms at 179 mscolor map: 0 ms at 179 msview: 94 ms at 179 msafter display: 3 ms at 283 msafter display: 0 ms at 452 msupdate: 0 ms at 469 mscalculate: 60 ms at 469 mssyntax: 14 ms at 470 mssyntax: 8 ms at 521 mscursor info: 0 ms at 529 mscolor map: 0 ms at 529 msview: 78 ms at 529 msafter display: 0 ms at 616 msafter display: 0 ms at 622 msafter display: 1 ms at 635 msafter display: 1 ms at 651 msafter display: 0 ms at 668 msafter display: 0 ms at 685 msafter display: 1 ms at 701 msafter display: 0 ms at 718 msafter display: 0 ms at 735 msafter display: 0 ms at 752 msafter display: 0 ms at 769 msafter display: 1 ms at 785 msafter display: 1 ms at 801 msafter display: 1 ms at 818 msafter display: 0 ms at 835 msafter display: 1 ms at 851 msafter display: 0 ms at 869 msafter display: 1 ms at 885 msafter display: 0 ms at 902 msafter display: 0 ms at 918 msafter display: 0 ms at 935 msafter display: 1 ms at 951 msafter display: 0 ms at 968 msafter display: 0 ms at 985 msafter display: 0 ms at 1002 msafter display: 0 ms at 1019 msafter display: 0 ms at 1035 msafter display: 1 ms at 1051 msafter display: 0 ms at 1068 msafter display: 0 ms at 1085 msafter display: 0 ms at 1101 msafter display: 0 ms at 1118 msafter display: 0 ms at 1135 msafter display: 0 ms at 1151 msafter display: 0 ms at 1169 msupdate: 0 ms at 1195 mssyntax: 13 ms at 1195 mscalculate: 19 ms at 1195 mssyntax: 5 ms at 1209 mscursor info: 0 ms at 1214 mscolor map: 0 ms at 1214 msview: 106 ms at 1214 msafter display: 1 ms at 1327 msthe edited program compiled againhazel-jit: the run compiled: 159 ms at 292 msthe worker: its runworker: request decoded: 2 ms at 175 msworker: request decoded: 1 ms at 177 msworker: encode ack: 1 ms at 178 msworker: post ack: 0 ms at 179 msworker: request composed: 33 ms at 179 msworker: reuse plan: 15 ms at 212 msworker: slices: 131 ms at 212 msworker: encode reuse plan: 7 ms at 220 msworker: post reuse plan: 0 ms at 227 msworker: encode stream: 0 ms at 343 msworker: post stream: 0 ms at 343 msworker: slices: 31 ms at 343 msworker: slices: 31 ms at 374 msworker: slices: 30 ms at 405 msworker: slices: 31 ms at 440 msworker: slices: 30 ms at 475 msworker: slices: 30 ms at 510 msworker: slices: 31 ms at 543 msworker: slices: 31 ms at 579 msworker: slices: 30 ms at 615 msworker: slices: 30 ms at 649 msworker: slices: 31 ms at 683 msworker: slices: 110 ms at 717 msworker: slices: 30 ms at 831 msworker: slices: 30 ms at 865 msworker: slices: 30 ms at 899 msworker: slices: 75 ms at 933 msworker: make result: 0 ms at 1105 msworker: post result: 0 ms at 1169 msthe answer: encoded, decodedworker message decoded: 0 ms at 456 msworker message decoded: 1 ms at 459 msworker message decoded: 0 ms at 461 msworker: encode result: 64 ms at 1105 msworker message decoded: 23 ms at 1171 msthe slider and the picture redrawn, 286 msthe worker's answer, 1328 ms16.7 ms
One such step on a timeline: the compiled run at the start, the page's own work to its first redraw, the program compiled again, and the worker, which still runs (^report(49)).
After two cuts: the same small edits on the Witch slide, in Firefox, on the same scaleneck 28 to 30, views onthe page, before the request: 0.32 sthe worker's evaluator: 1.05 s1.0 sthe worker's other work: 0.14 sthe result shared (worker): 0.19 sencoded (worker): 0.05 sdecoded (main thread): 0.16 sthe page, to the picture: 0.18 sbefore the cuts: 6.4 s2.1 s; before the cuts 6.4 s (dashed)neck 30 to 28, views onthe page, before the request: 0.21 sthe worker's evaluator: 1.01 s1.0 sthe worker's other work: 0.12 sthe result shared (worker): 0.23 sencoded (worker): 0.05 sdecoded (main thread): 0.13 sthe page, to the picture: 0.16 sbefore the cuts: 5.6 s1.9 s; before the cuts 5.6 s (dashed)arms (up / down) 55 to 65, views onthe page, before the request: 0.20 sthe worker's evaluator: 1.06 s1.1 sthe worker's other work: 0.14 sthe result shared (worker): 0.15 sencoded (worker): 0.05 sdecoded (main thread): 0.13 sthe page, to the picture: 0.17 sbefore the cuts: 4.2 s1.9 s; before the cuts 4.2 s (dashed)arms (up / down) 65 to 55, views onthe page, before the request: 0.19 sthe worker's evaluator: 1.04 s1.0 sthe worker's other work: 0.13 sthe result shared (worker): 0.15 sencoded (worker): 0.05 sdecoded (main thread): 0.12 sthe page, to the picture: 0.17 sbefore the cuts: 5.2 s1.9 s; before the cuts 5.2 s (dashed)neck 28 to 30, views offthe page, before the request: 0.30 sthe worker's evaluator: 1.06 s1.1 sthe worker's other work: 0.15 sthe result shared (worker): 0.21 sencoded (worker): 0.06 sdecoded (main thread): 0.12 sthe page, to the picture: 0.48 s0.5 sbefore the cuts: 6.5 s2.4 s; before the cuts 6.5 s (dashed)neck 30 to 28, views offthe page, before the request: 0.20 sthe worker's evaluator: 1.00 s1.0 sthe worker's other work: 0.12 sthe result shared (worker): 0.26 sencoded (worker): 0.05 sdecoded (main thread): 0.13 sthe page, to the picture: 0.25 sbefore the cuts: 6.3 s2.0 s; before the cuts 6.3 s (dashed)arms (up / down) 65 to 55, views offthe page, before the request: 0.18 sthe worker's evaluator: 1.05 s1.1 sthe worker's other work: 0.17 sthe result shared (worker): 0.16 sencoded (worker): 0.05 sdecoded (main thread): 0.11 sthe page, to the picture: 0.25 sbefore the cuts: 5.5 s2.0 s; before the cuts 5.5 s (dashed)evaluator (worker)other (worker)shared (worker)encoded (worker)decoded (page)the page's own work0 s1 s2 s3 s4 s5 s6 s
After two cuts, the same small edits on the Witch slide, in Firefox: each edit's bar, and the same edit before the cuts, dashed (^report(46)).
A small edit on the Witch slide, in Firefox: the trip between the worker and the page (orange) against the evaluator (blue)neck 28 to 30, views onthe page, before the request: 0.20 sthe worker's evaluator: 1.14 s1.1 sthe worker's other work: 0.25 sthe result shared (worker): 1.45 s1.4 sencoded (worker): 1.23 s1.2 sdecoded (main thread): 1.90 s1.9 sthe page, to the picture: 0.24 sneck 30 to 28, views onthe page, before the request: 0.20 sthe worker's evaluator: 1.12 s1.1 sthe worker's other work: 0.11 sthe result shared (worker): 1.47 s1.5 sencoded (worker): 1.14 s1.1 sdecoded (main thread): 1.37 s1.4 sthe page, to the picture: 0.21 sneck 28 to 30, views offthe page, before the request: 0.18 sthe worker's evaluator: 1.25 s1.3 sthe worker's other work: 0.11 sthe result shared (worker): 1.44 s1.4 sencoded (worker): 1.18 s1.2 sdecoded (main thread): 2.01 s2.0 sthe page, to the picture: 0.34 sneck 30 to 28, views offthe page, before the request: 0.18 sthe worker's evaluator: 1.18 s1.2 sthe worker's other work: 0.12 sthe result shared (worker): 1.55 s1.6 sencoded (worker): 1.20 s1.2 sdecoded (main thread): 1.67 s1.7 sthe page, to the picture: 0.42 s0.4 sevaluator (worker)other (worker)shared (worker)encoded (worker)decoded (page)the page's own work0 s1 s2 s3 s4 s5 s6 s
A small edit on the Witch slide, in Firefox, the neck edits: the run's answer shared and encoded in the worker and decoded on the page (orange), against the worker's evaluator (blue) (^report(46)).
Two small edits on the Witch slide, in Firefox: where the time goes, seconds from the editneck, 28 to 30main threadupdate: 8 ms at 0.01 scalculate: 29 ms at 0.02 sview: 100 ms at 0.05 supdate: 7 ms at 0.15 scalculate: 48 ms at 0.16 sview: 127 ms at 0.20 safter display: 3 ms at 0.34 sworker message decoded: 3 ms at 0.35 sworker message decoded: 8 ms at 0.36 scalculate: 70 ms at 0.41 sview: 108 ms at 0.48 safter display: 2 ms at 1.13 supdate: 47 ms at 1.51 scalculate: 8 ms at 1.56 sview: 28 ms at 1.57 safter display: 2 ms at 3.88 sworker message decoded: 2387 ms at 6.09 s, 5.4 MBdecode 5.4 MB, 2.4 scalculate: 43 ms at 8.48 sview: 231 ms at 8.53 safter display: 3 ms at 8.77 sworkerthe worker, from the request to its result: 5.9 s, of which its evaluator 1.2 srequest 10 KB; its evaluator 1.2 s in all; the rest, making and sending 5.4 MB backfirst redraw, 0.3 sthe picture, 8.8 sarms (up / down), 55 to 65main threadupdate: 7 ms at 0.01 scalculate: 18 ms at 0.01 sview: 102 ms at 0.03 supdate: 9 ms at 0.13 scalculate: 42 ms at 0.14 sview: 113 ms at 0.18 safter display: 2 ms at 0.31 sworker message decoded: 4 ms at 0.32 sworker message decoded: 11 ms at 0.33 scalculate: 70 ms at 0.39 sview: 114 ms at 0.46 supdate: 52 ms at 1.49 scalculate: 8 ms at 1.54 sview: 24 ms at 1.54 sworker message decoded: 1335 ms at 3.75 s, 4.4 MBdecode 4.4 MB, 1.3 scalculate: 16 ms at 5.09 sview: 163 ms at 5.11 safter display: 2 ms at 5.50 safter display: 2 ms at 7.05 sworker message decoded: 2092 ms at 8.06 s, 5.4 MBdecode 5.4 MB, 2.1 scalculate: 17 ms at 10.15 sview: 156 ms at 10.17 sworkerthe worker, from the request to its result: 7.9 s, of which its evaluator 1.6 srequest 10 KB; its evaluator 1.6 s in all; the rest, making and sending 5.4 MB backfirst redraw, 0.3 sthe picture, 5.3 s0 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s
Two small edits on the Witch slide, in Firefox: the main thread's own work, its decoding of the worker's 4 to 5 MB answers, and the worker from the request to its result (^report(46)).
A small edit on the Witch slide, in Firefox: time from the edit, on a log scale, against a 60 fps frame (16.7 ms)1 ms10 ms100 ms1 s10 s60 fpsthe slider, redrawnthe page's first change, after the edit's own workthe slider, redrawn the page's first change, after the edit's own work: 372.0 ms0.37 s (22 frames)the picture shows the editcompiled views on (median of 4)the picture shows the edit compiled views on (median of 4): 7965.0 ms8.0 s (478 frames)compiled views off (median of 4) compiled views off (median of 4): 7033.0 ms7.0 s (422 frames)of which, the picture's viewon the interpreterof which, the picture's view on the interpreter: 87.0 ms87 ms (11 fps)compiled compiled: 3.0 ms3.00 ms (330 fps)
A small edit on the Witch slide, in Firefox: one slider step, from the edit to the slider's first redraw and to the picture showing it, both ways, and the picture's view alone, against a 60 fps frame (^report(46)).
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
Each program's time per run, the interpreter against compiled, a log scale: medians of 30, Node 22, a dev build (^report(45)).
The Witch slide's views in Firefox, in the app, ms a render on a log scale, against a 60 fps frame (16.7 ms)0.1 ms1 ms10 ms100 ms60 fps, 16.7 msDrawing.picture, before the fix: interpreterDrawing.picture before the fix: interpreter: 90.000 ms90 ms (11 fps)Drawing.picture, interpreterDrawing.picture interpreter: 87.000 ms87 ms (11 fps)compiled compiled: 3.000 ms3.00 ms (330 fps)Drawing.polygons 1, interpreterDrawing.polygons 1 interpreter: 26.000 ms26 ms (38 fps)compiled compiled: 0.373 ms0.37 ms (2,700 fps)Drawing.polygons 2, interpreterDrawing.polygons 2 interpreter: 26.000 ms26 ms (38 fps)compiled compiled: 0.293 ms0.29 ms (3,400 fps)Drawing.polygons 3, interpreterDrawing.polygons 3 interpreter: 27.000 ms27 ms (37 fps)compiled compiled: 0.333 ms0.33 ms (3,000 fps)Drawing.polygons 4, interpreterDrawing.polygons 4 interpreter: 29.000 ms29 ms (34 fps)compiled compiled: 0.453 ms0.45 ms (2,200 fps)
The Witch slide's views in Firefox, in the app, against a 60 fps frame: the picture before the fix and after it, compiled, and the polygon editors both ways; fps as if updating the state were free (^report(46)).
One frame of the Witch's picture, ms on a log scale, against a 60 fps frame (16.7 ms)0.1 ms1 ms10 ms100 ms60 fps, 16.7 msthe interpreterits view, command and drawingthe interpreter, its view, command and drawing: 155.43 ms155 ms (6 fps)hazel-jit, the appmodel in, view, drawinghazel-jit, the app, model in, view, drawing: 3.45 ms3.45 ms (290 fps)hazel-jit's viewin the app's processhazel-jit's view, in the app's process: 1.16 ms1.16 ms (860 fps)hazel-jit's viewin a Node process alonehazel-jit's view, in a Node process alone: 0.19 ms0.19 ms (5,200 fps)
One frame of the Witch slide's picture in the Hazel test, the picture handed over already evaluated, against a 60 fps frame; fps as if updating the state were free (^report(46)).
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.
A Polygons render from the model to the page's virtual DOM: through Hazel, or straight from the compiled view's JS answer, to scale (^report(45)).

hazel-jit compiles an elaborated Hazel term to the source of a JavaScript function, and the browser runs it: 13 to 1,140 times faster than the interpreter on the programs measured (^report(51), for colleagues and their agents: expected gains and costs, how to use it in a PR today, what was added since the first version, its limitations, and next steps). On trial/694-view-jit (hazelgrove/hazel#2817), each livelit's view is compiled, and so is a slide's whole run, with each livelit's model a parameter (^report(49)); where it meets a form it does not compile, that code runs on the interpreter instead.

The costs: a livelit's definition compiles in about a millisecond, the largest, a module of 62,077 nodes, in 14 to 21 ms; a slide's whole run, 24,000 to 112,000 nodes, in 87 to 299 ms (median 153), once, nearly all of it writing the JS; loading the slides with many livelits is no slower. The limits: JavaScript's numbers, no probes inside compiled code, the forms it does not compile (holes, tests, quotations and a few more), one browser measured, and not on dev.

For dev, the values it carries: ^report(47), a design note for ^ticket(718), proposes closed first-order values as a form of their own, with no ids, holes, closures or sharing, measured against Hazel's terms and Fumola's values; on the branch, sending the worker's sample values that way took its answer from 475 to 198 KB, and the page's decoding from 24 to 31 ms to 7 to 8. Its questions for Matthew are open.

For the meeting: Is the best-case framing right, numbers allowed to differ? Is hazel-jit ready for colleagues to try in their own PRs, and on which branch? Is first-order data as a form of its own (^report(47)) worth a plan for the group?

6. BuckleScript and ReScript (and Melange): to know, and to compare with compared in ^report(46) on two programs: the Petri rule, and the Witch's picture view #6 #

Asked by Cyrus (2026-11-05) · ^ticket(698) · as of 2026-11-07 11:45 MST

The Witch's picture: the view's own work, ms (and frames a second, as if updating the state were free)hand-written JShand-written JS: 0.168 ms0.17 ms (6,000 fps)MelangeMelange: 0.173 ms0.17 ms (5,800 fps)ReScriptReScript: 0.177 ms0.18 ms (5,600 fps)js_of_ocaml, toFixedjs_of_ocaml, toFixed: 0.189 ms0.19 ms (5,300 fps)hazel-jithazel-jit: 0.193 ms0.19 ms (5,200 fps)js_of_ocaml, Printfjs_of_ocaml, Printf: 1.010 ms1.01 ms (990 fps)toFixed alone, 1,985 calls: 0.14 ms00.250.50.751
The Witch slide's picture view, compiled five ways: the view's own work in one Node process, and the time toFixed alone takes, dashed (^report(46)).
The same calls with Hazel's interpreter among them, µs a call, a log scale (each step to the right is ten times as long)0.1 µs1 µs10 µs100 µs1000 µsMelange0.46 µsReScript0.55 µsjs_of_ocaml0.71 µshand-written JS0.90 µshazel-jit1.59 µsthe interpreter358 µs
^report(43)'s Petri rule, one call, compiled five ways and on the interpreter, a log scale: medians of five runs of 2,000 calls, Node 22 (^report(46)).

Update, 11-07 11:45: the second program, a view (^report(46), a view). The Witch slide's ^picture view, written again in ReScript and OCaml and by hand, on the slide's own picture (133 shapes, 924 points): by hand 0.17 ms, Melange 0.17, ReScript 0.18, js_of_ocaml 0.19, hazel-jit 0.19 (about 5,200 to 6,000 fps), all drawing the same SVG, byte for byte. Most of the work is one builtin, 1,985 numbers formatted with toFixed (0.14 ms alone), so the compilers converge; js_of_ocaml through OCaml's Printf takes 1.0 ms. A table of what holds across both programs: the compilers differ in calls, matches and layouts, and converge where a builtin does the work. Each compiled view has a page of its own.

Update, 11-07: compared, in ^report(46) (^ticket(698)). ^report(43)'s Petri rule, written in ReScript and in OCaml, compiled by ReScript 12.3.1, Melange 5.0.0 and js_of_ocaml 5.9.1, beside hazel-jit's output and a hand-written handler, each listing in the report. A call, in Node: Melange 0.46 µs, ReScript 0.55, js_of_ocaml 0.71, by hand 0.90, hazel-jit 1.59, the interpreter 358. ReScript's and Melange's code reads like the hand-written: a function's arguments as JS arguments, === on ints, loops for tail calls, options without a box, records as objects. Those are ^report(46)'s five suggestions for hazel-jit, and each section of its end weighs one route: hazel-jit as it is, ReScript or Melange as a back end, js_of_ocaml, by hand, the interpreter.

Cyrus named BuckleScript and ReScript as technologies to know about, and perhaps compare with, if not use. What they are, briefly, to be checked as part of ^ticket(698): BuckleScript, from Bloomberg (2016), compiled OCaml to readable JavaScript. Its team later renamed it ReScript, with a syntax of its own, aimed at the JavaScript world (version 12 in 2026). Melange is a fork that kept OCaml and Reason syntax, with first-class support in dune. Hazel itself is compiled to JS by js_of_ocaml, which works from OCaml's bytecode: a different route.

Three ways they bear on hazel-jit: (1) a reference for its output, since they map a typed functional language's values to JS (variants, records, lists, closures, functions of several arguments) and are known for fast, readable output; (2) a route to use: turn Hazel into OCaml, Reason or ReScript and let their compiler make the JS, ahead of time, or in the page if their compiler runs there; (3) Hazel's own build: what Melange's output would do to the speed of Hazel's evaluator, against js_of_ocaml's, a larger question.

For the meeting: Which did Cyrus have in mind: a reference for hazel-jit's output, a tool to use, or a different compiler for Hazel itself?

2. hazeljs for other JavaScript developers#

hazeljs is Hazel as a JavaScript library, on npm since 2026-11-02, and Messed Up Dress Up is the first program to use it for its scripts (a Hazlet: a JS program whose event handlers are written in Hazel). The next step is people outside the project: first, the group in Cambridge Cyrus mentioned, who simulate Petri nets with JS tools of their own.

Asked by Matthew (2026-11-06, as soon as possible) · ^ticket(696) · as of 2026-11-07 11:30 MST

hazeljs 0.0.1, 11-02 11:030.0.111-02 11:03first publish: hazel-lib.js,require, import, script tag,.d.ts, README; 648.5 kBhazeljs 0.0.2, 11-030.0.211-03source at hazelgrove/hazeljs;examples; an install checkon Node 18, 20, 22hazeljs 0.0.3, 11-030.0.311-03a tagline; README: errors,holes, unfinished code;checking hazel-lib.js's commithazeljs 0.0.4, 11-030.0.411-03#2719 at 1ba138ef28, msmeasured; the same bytesas Hazel's own deploy$ npm install hazeljsMUDU loads its Hazel from the package (jsDelivr) since Dress Up 0.0.476
hazeljs on npm, as of 2026-11-03: four versions, 0.0.4 the latest (npmjs.com/package/hazeljs). ^report(37)'s figure.

Opened 2026-11-06: #2812 (branch docs/readme-hazeljs, README only; CI running). A small PR against dev: a short section in Hazel's README on hazeljs, the experimental npm package (source: hazelgrove/hazeljs; 0.0.4 is the latest): Hazel as a JavaScript library, to analyze and run Hazel programs from Node or a web page and call the functions they define. It notes that the plan is for the package to track dev, but that it does not yet: it is built from the draft library in #2711 and #2719 (at 1ba138ef28). At the last meeting, hazeljs following dev was settled as the direction, perhaps after #2469 lands, and not urgent.

Why now: Cyrus knows people in Cambridge who simulate Petri nets with JavaScript tools of their own. Matthew would like to see whether they could move some of their JS logic into Hazel through hazeljs, to gain Hazel's types and its clarity in the middle of an edit. A link from Hazel's own README gives them a place to start.

For the meeting: Who should review it? And Cyrus's contacts in Cambridge: who they are, and whether he will introduce them.

8. A report for JS developers: scripting your app in Hazel, the way MUDU does drafted: ^report(43) live, ^report(44), and the example app live at 0.0.10 #8 #

Asked by Matthew (2026-11-06) · ^ticket(697) · as of 2026-11-07 11:30 MST

Your app, with some of its handlers in Hazel (hazeljs)your JS appkeeps the state,draws, takes inputa view of the statea typed Hazel recordthe eventa Hazel constructoron_eventa Hazel function,type-checked as typeda commanddata your appacts outthe app performs the command; while the Hazel program is unfinished or has errors, your own JS handler answers instead
The pattern the report would teach, the one Messed Up Dress Up's rooms use (^report(39)).

Update, 11-07: the example app is live, at 0.0.10 (matthewhammer.org/hazeljs-petri-example). Its rules on the left, each in Hazel's editor, with any error under the rule it is in; the net on the right, written in Hazel too, editable, and drawn again from its definition after every edit; a divider, and full screen. hazeljs is at 0.0.6 on npm: an object's keys in any order (the bug the example found, fixed in Hazel at 6c283c8a9f), and its listings script in the package, breaking long lines to fit each listing (hazelgrove/hazeljs#1, closed). ^report(43) and ^report(44) use that script. The editable embed they rely on is a PR, #2814 (js-library-embed), open.

Since 2026-11-06 afternoon: ^report(43)'s example runs on its page, every Hazel listing in Hazel's own editor with go to definition between listings, and an event log as the game's; ^report(44) says how any article can have such listings; and the example is an app of its own, in a public repository, matthewhammer/hazeljs-petri-example (0.0.1; its site, in the game's style, is planned). hazeljs's README now has both apps under Examples, with links to the two reports. Building it found a bug in hazeljs: a JS object whose keys come in another order than its type's fields gets stuck when a field is a list.

Drafted 2026-11-06: ^report(43), Scripting a JavaScript App in Hazel (work in progress). It explains the pattern and the game's pieces, with links to their lines in the game's code, then six steps for another app, then a worked Petri net example (two processes and a lock; the firing rule in two Hazel modules), run in Node through hazeljs 0.0.4. Its findings: the rule ran as written; in 2,000 random steps the two processes were never both busy; a mistake in a rule is reported by module before anything runs, while the app's own JS answers; a call costs about 3.5 ms against 0.7 µs for the same handler in JS, and a build 340 to 440 ms. That is fine for each click, but not for a simulator's inner loop, which ties this item to hazel-jit (item 2).

A Hazel report on how Messed Up Dress Up uses hazeljs for its scripts, written for another JavaScript developer who wants to do the same in their own program. It builds on ^report(33) (the game's scripts), ^report(34) (a library for Hazel in JS) and ^report(39) (Hazlets so far), but speaks to someone outside the project.

What it would cover: (1) the shape: the app hands an event and a typed view of its state to a Hazel function, and acts out the command it returns; Hazel never touches the page. (2) How the game does it: each room's on_event : (Globals, Event) -> Cmd, a program of modules (Common, then one per room) built by Hazel.runProgram, errors and holes reported module by module, the game's own JS answering while the program is unfinished, and the event log. (3) The steps for your app: install, write the types, call the function per event, interpret the commands. (4) Costs and limits today: a Hazel rule answers in about 3.5 ms of a 13.7 ms lever pull, the first event after a reset waits 0.5 to 0.7 s, and the package is a 0.0.x prototype. (5) A small worked example in another domain, perhaps a Petri net's firing rule, for the readers in Cambridge.

For the meeting: Is a Petri-net example the right one for Cyrus's contacts, and what would their tools need from a Hazel rule? Is ^report(43) ready to send them as it is, or after the example is a web page (its What next, step 3)?

If there is time#

How this agenda is kept#