Skip to content

Releases

Mimic nightly 0.4.3-nightly.20261129

Pre-release

Choose a tag to compare

@github-actions github-actions released this 29 Nov 11:26
4c78584

A nightly build of the development branch: not a stable release. Install it with mimic upgrade --nightly.

Added

  • C structs in a hand-written extern "C" block: struct pollfd { fd: i32, events: i16, revents: i16 } with the functions that use it, imported as a trusted header would be (the record c::Pollfd, taken and given by those functions) but with only what the block declares, so the audit does not warn about trusting a whole header. Reported by a user.
  • mimic why says why a map stays off the GPU: on macOS, a fused map with no GPU kernel gets a note with the reason (it computes in f64, reads another list, or calls a function with no GPU version), where only the maps that went there were shown. Reported by a user.
  • term::poll_key(ms): a key, or None when none is typed within ms milliseconds, so a real-time program (a game's loop) reads keys without stopping. And Ctrl-C restores the terminal: in raw mode, Ctrl-C, SIGTERM or a closed terminal ended the program without restoring it (raw mode, a hidden cursor and the alternate screen stayed); the terminal is restored, the cursor shown and the normal screen brought back first (unless the program set os::on_interrupt). Both reported by a user's game.
  • Constants: const width: f64 = 80.0 at module level (glyph ≝, digraph \c; pub const too), usable wherever an expression is. A list, text or record constant is worked out the first time it is used, then shared; a constant's value cannot have effects (E0606). Reported by a user's game, approved by the owner.
  • Typed maps [K: V]: a map's key and value types, declared (let m: [str: i64], parameters, record fields) or worked out from a literal. A lookup has the value's type (a plain number in m[k] + 1), get gives a typed Option, keys and values typed lists; a key or value of another type is refused when checking (E0401), an integer next to floats promoted as in a list.
  • Sized lists [T × n] (also [T * n]): [f64 × 3], [i64 × 9], a list with its length in its type, for parameters, lets, results and record fields. Up to 16 numbers are kept in registers. A written-out list of another length, or a constant index outside it, is refused when checking (E0217; a call with a list of another known length, E0401); a list of unknown length is checked where it is bound; [f64 × n] turns integers into floats.
  • Assignment into nested lists and records: g[r][c] = v, s.pos.x = v, l.todos[1].done = true, and += and the like on them, on a let mut variable. Each level is changed in place when nothing else holds it and copied once otherwise: 4 million writes into a 2000×2000 grid take 0.7 s (a row copied each time before: 63 s), and a record's list field changed in a loop is no longer copied per step.
  • random::at(seed, i) and random::at_float(seed, i): the i-th random number from a seed, with no state, so a program makes its input on every core (⍳ n ¨ (i => random::at(seed, i)): 50 million numbers in 0.16 s on a 12-core Mac) and gets the same numbers on every run.
  • Loops: for, while and break (∀, ⟳, ↯; digraphs \F, \O, \B): for i in a ‥ b { … } over a range, for x in xs { … } over a list's elements, while cond { … }, and break to leave the innermost loop (E0216 outside one, or inside a lambda). A loop changes its function's let mut variables, one step after another; parallel work stays with ¨ and the array primitives. settle, evolve and recursion are unchanged. Tutorial chapter 4 and the syntax reference describe them; the editors' grammars know them.
  • Compound assignment +=, -=, ×= and ÷= (ASCII *= /=; glyphs +↩ -↩ ×↩ ÷↩) on a let mut name or a list element: total += i, counts[k] += 1. An index other than a name or a number is computed once.

Changed

  • join(⍳ n ¨ (k => …text…), sep) makes no list of texts: each text is appended to the result as it is made and released, where a list of n texts was built and joined after; a pure function that calls the program's own functions keeps the parallel map when the program has several workers (chosen when running). translit (8 million texts) 0.83 s → 0.30 s on one core, 0.40 s → 0.28 s on all cores; aho 0.58 s → 0.38 s on one core, the same on all.
  • Output is written before a C call that replaces the process: what a program printed just before execl (or fork, _exit, system, …) was lost when its output went to a pipe or a file (buffered); it is flushed first now. Reported by a user.
  • mimic test file.mim works on a file of a project: it was refused (E0903, a library module used on its own); it builds the project and runs that file's tests only, from anywhere. Reported by a user.
  • build.mim settings are checked: an unknown setting, or a value of the wrong kind (opt = 7, leak_check = 1), is an error naming the nearest known setting, where a misspelt one was silently ignored. New: strict_math = true in a profile, as --strict-math (--fast-math overrides it). Reported by a user.
  • MIMIC_GPU values are checked, and 1 has a floor: 0/off never uses the GPU, unset or auto lets the runtime decide, 1/on sends maps of 65,536 elements or more (a smaller one costs more to start than it saves), always every map (what the tests use); any other value stops the program with a message, where 2, default or the empty text meant "always". New os::unset_env(name). Reported by a user's game.
  • Functions passed to a parameter of a declared function type are typed: with more: fn(i64) -> bool, a lambda passed as more works on integers (it was typed with unknown arguments, its arithmetic the runtime's generic operators), and a call more(x) gives a bool. tokenize twice as fast (0.87 s → 0.43 s on one core).
  • Searching text jumps to its first byte: find, contains, replace and split compared the part at every position; they look for its first byte with the C library's vectorised memchr now, then compare the rest. url 35% faster on one core (3.27 s → 2.11 s), http_parse 44% (1.21 s → 0.68 s), ini 8%.
  • A loop's tuple state changes its list in place: in settle and evolve, a step such as (s.0 + 1, put(s.1, k, v)) copied the list each step, as the state still held it. The step owns its state now, and a field it reads once as the list put, push or concat changes is taken out of it and changed in place (a start state still held elsewhere is copied as before). huffman's decoding table: no values made in the loop's steps, 0.12 s → 0.10 s.
  • A shared list of numbers written by index is copied in one pass: put or xs[i] = v on a list held elsewhere copied it element by element; it is one copy of the bytes now (huffman, whose decoding table of 512K numbers is written from a loop's tuple state: 0.18 s → 0.12 s on an M3 Pro).
  • A list a loop only reads and writes element by element is checked once, at the loop's start: a let mut list of numbers that a for or while body uses only as xs[i], xs[i] = v and ≢ xs is made held once there (copied if shared, as its first write would have) and its kind and length checked; each element write in the loop is then a bounds check and a store, with no atomic read of its count. levenshtein written with loops 14% faster.

Install

Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.

System File Install Also needed
Windows x86_64 (10, 11) mimic-0.4.3-nightly.20261129-windows-x86_64.zip Double-click install.cmd Nothing: Windows programs are linked with the MinGW-w64 inside mimic.
macOS Apple silicon mimic-0.4.3-nightly.20261129-macos-arm64.tar.gz ./install.sh The Xcode Command Line Tools (xcode-select --install), for the macOS SDK.
Linux x86_64 mimic-0.4.3-nightly.20261129-linux-x86_64.tar.gz ./install.sh glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else.

On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:

powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"

The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.

Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.

  • macOS: the script clears the download quarantine. If you copy mimic by hand instead, run xattr -d com.apple.quarantine mimic once.
  • Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
  • Uninstall: ./install.sh --uninstall, or install.cmd -Uninstall on Windows. Your projects are not touched.

First program

mimic create hello
cd hello
mimic run

mimic --help lists every command. SHA256SUMS has the checksum of each file.

Mimic 0.4.3

Choose a tag to compare

@github-actions github-actions released this 28 Nov 08:31
31d87df

Step 0.4.3, loops and values in registers: a memory check in debug builds that stops at the first use of a freed value; every run fixture checked five ways in CI, and random valid programs run the same ways (seven daily seeds on the frozen release, rerun until all agreed; the three bugs they found fixed: an element of a list in registers assigned with an index of unknown type, a list released inside a later argument of the call holding it, and list headers and record fields read as never-changing memory, which let a read move past a release; that last fix gave back some speed, accepted by the owner: lcs up to 20% slower, regex 5–6% on one core); and the held-out set (40 programs written plainly, never used for tuning) made faster without a change to them: Mimic's time over C's on one core, as a geometric mean, from 4.65× to 3.61× on Linux, 4.18× to 3.17× on macOS and 4.33× to 3.33× on Windows. Loops that grow a short list, tuples holding lists and the steps of qoi go through the Mimic IR; text mapped character by character is one pass (caesar 2.7× faster); a function value capturing nothing is made once; push onto a short list stays inline; Windows release executables are a third of their size; ⍬ and x ⥊ [n] are typed; and tools/rc-count.py counts the values made in loop steps. Moved to 0.4.4, with the owner's approval and recorded in docs/versions.md: qoi within 1.5× of C and paths within 1.3× (now 1.9× and 1.75×), escape analysis, loops making no values in their steady state, and the gaps.md rows still open for 0.4.3.

Added

  • Values made in loop steps, counted: a MIMIC_COUNT_RC=1 build also counts the values made while an evolve or settle step runs (past each loop's first step, which may copy a start still shared elsewhere), and tools/rc-count.py lists the benchmarks whose loops make any in their steady state.
  • A matrix row assigned in one write: m[i] = [10 40 70] replaces row i (a number fills it; with more dimensions, fewer indices than dimensions replace that cell, cube[1, 0] = [7 8]), copied first when shared, a byte matrix keeping bytes. It stopped the program with needs one index per dimension; a list of the wrong length says how long the row is.
  • Character literals: `a` is the number 97 (a character's code, as char_code("a"); escapes `\n`, `\ , \x1b , \u{e9} ). Text work on bytes compares and computes with characters as numbers, (c - a + 13) % 26 + a ``, instead of making a one-letter string for each one.
  • ⍬, an empty list with a type (digraph \z): ⍬ is an empty [i64], ⍬[f64], ⍬[str], ⍬[Point] an empty list of that element type. A bare [] has no element type and, where nothing gives it one, sent the code using it the slow generic way; the prelude's [0] ↓ 1 (and [0.0] ↓ 1, …) for an empty typed list is now ⍬.
  • Every keyword has a glyph, each with a digraph: ⇑ pub, ⇄ mut, ⍰ if, ⋄ else, ⏎ return, ⇐ use, ≔ as, ⌁ extern, ☡ unsafe, ✓ trusted, ⊡ type, ⊨ match, ⊕ with, ● true, ○ false, and ⊢ test, ∀ for (property tests), ⎘ include, beside § module and ƒ fn. Words and glyphs mix freely; mimic fmt writes glyphs back as words, mimic glyphs lists them all, and the editor grammars (TextMate, tree-sitter) colour them as their words.
  • e else { … } is an expression: the value inside an Option or Result (Some, Ok), else what the block gives, anywhere an expression goes: if 1 < ≢ args { parse_int(args[1]) else { 1086 } } else { 1086 }, xs ¨ (s => parse_int(s) else { 0 }), and let port = parse_int(s) else { 8080 } (the block may still leave with return, as let … else did). The block must give the type inside (E0401) or something (E0504); a value that is not an Option or Result is E0406. Result gets its fallback this way too.
  • A memory check in debug builds. A freed value is marked, filled with junk and kept a while before its memory is used again; retaining, releasing or reading it afterwards stops the program at once, naming what was done and what the value was (memory check: a value ([i64], 4 elements) was read after it was freed). mimic lldb stops right there, with the stack. Release builds are unchanged.
  • Random programs, nightly (tools/fuzz.py, the fuzz workflow): valid programs written at random (numbers, lists, functions that call themselves with a list they grow, copies changed in place) run in release and debug, without the Mimic IR, on one thread and on many; all must print the same. A disagreement is kept with each way's output, to become a fixture.
  • math::to_bits, math::from_bits (and to_bits32/from_bits32 for f32), bytes::of_f64s and bytes::to_f64s: a float's bits as an integer, and floats as little-endian bytes, both exact (weights saved and read back bit for bit).
  • ∧/ and ∨/, the and and or reductions (all and any written as glyphs, as in APL): same ▷ ∧/, ∨/ flags.
  • math::tanh, math::sinh, math::cosh, math::log1p, math::expm1 and math::sigmoid (libm calls that fuse into array kernels like math::exp; log1p and expm1 exact near zero; sigmoid without overflow for large negative inputs), and unwrap_or for an Option: parse_int(s) ▷ unwrap_or(300). Reported by a user.

Changed

  • Text mapped character by character is one pass: chars(t) ¨ (c => …) ▷ join(sep) with a function giving text walks the bytes of t once, hands the function each character and appends its text at once: no list of one-character strings made, none joined. A pure function is asked once for each ASCII character, its texts kept for the rest of the loop. The held-out caesar 2.7× faster on one core; translit added to the corpus for it.
  • push onto a short list stays inline: a list of numbers in one of the runtime's pools (up to 256 bytes) told the compiled code nothing of its room, so every push onto it called the runtime, which looked up its block's size. The compiled code now knows the pools' sizes. A row grown to 45 numbers called the runtime for its first 32; levenshtein 32% faster.
  • A function value that captures nothing is made once: run(b, p, x => alpha(x) or digit(x)) or run(b, p, digit) made a new function value at every call and freed it after; one is now made the first time and shared, never freed. tokenize's scanning loop made 1.07 million values, now none; 8% faster.
  • A tuple holding a list, taken apart at once, stays compiled whole: let (bytes, op) = chunk(p, prev), a tuple of 2 to 4 numbers, lists and records, no longer sends the function back to the old code generator. The Mimic IR calls the version of the callee that gives its parts (no tuple made) and holds each part as a value of its own, a part not named released at once. qoi's encode_step and decode_step are now compiled whole. In a record update, a short list kept in registers is appended with no list made for it, concat(s.px, p ⥊ [n]) appends n copies in place, and an empty list appended is no call at all.
  • A loop that grows a short list stays compiled whole: first ▷ evolve(48, w => push(w, …)), its start a list of up to 16 numbers kept in registers and its state a list on the heap, puts the start on the heap once and pushes in place at each step. The loop went back to the old code generator, which copied the list at every push: sha256's message schedule freed 97 values per block, now 1 (3.18 million values in the benchmark, now 33 thousand).
  • gather(^), gather(&), gather(|) (and trail) over integers fold in a loop, as gather(+) does: the runtime's generic fold called a function value with two boxed numbers for every element. siphash (hashes ▷ gather(^)): reference-count operations from 4 million to 8, 25% faster on one core.
  • [256 -1 255] is three numbers: in a list written out, a - with a space before it and a digit right after is a negative element, not a subtraction (which gave [255 255] with no error). [a - 1], [a-1], an index xs[n -1] and parentheses inside a list still subtract; ¯1 works everywhere as before.
  • A list of strings written out and indexed at once makes only the element picked: ["" "-alpha.{k}" "-beta.{k}"][i], its elements literals, variables or text formatted from them, is a switch on i that formats one string, not the list and every string in it (an index outside it: the list made and indexed as before, the same error). semver: reference-count operations from 41 million to 20 million.
  • A list of lists no longer sends a function back to the old code generator: the Mimic IR holds, passes on and releases it as any other list (its rows read by the old path, as for a list of strings), so the rest of the function is compiled through the IR. vm, whose program is a list of [operation, argument] pairs: its machine loop compiled whole, reference-count operations from 46 million to 51, 4× faster.
  • A loop whose state is a record or short list kept in registers is compiled whole, a short list read and changed at any index there too: xs[i] and put(xs, i, x) on a list of up to 16 numbers kept in registers (a machine's tape in its record) are checked against its length and stay in registers, so a step changing it no longer builds the whole state on the heap to do so. A loop's first state with an empty list in it, (0, []), takes the list's type from the step. brainf: reference-count operations from 42 million to 5 thousand, 3× faster.
  • A tuple of a list and a number (and such: 2 to 4 numbers or values on the heap) is returned as its parts: where the caller takes it apart at once (let (p, root) = find(parent, i)), the function gives its parts in registers, with no tuple made, filled, checked and freed; a tuple written out as the result, in any branch, or handed on from another such call, makes none. A caller that keeps the tuple gets one,...
Read more

Mimic 0.4.3-preview.1

Mimic 0.4.3-preview.1 Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 26 Nov 22:27
53d7561

A preview of the next version: not a stable release. Install it with mimic upgrade --preview.

Step 0.4.3, loops and values in registers, so far (0.4.3-preview.1): a memory check in debug builds that stops at the first use of a freed value; every run fixture checked five ways in CI and random valid programs run the same ways each night; and the held-out set (40 programs written plainly, never used for tuning) traced and made faster without a change to them: Mimic's time over C's, as a geometric mean, from 4.65× to 3.67× on Linux, 4.18× to 3.24× on macOS and 4.33× to 3.44× on Windows. A tuple of a list and a number is returned as its parts, ¨ over lists of strings and lists of lists is one compiled loop, v[i] = x changes a let mut list in place, join writes its string once, lists of truth values keep their type, and settle/evolve over a record or a list go through the Mimic IR: histogram 15×, bfsgrid 4.4×, unionfind 2×, sudokucheck 2× faster; markdown, soundex and template 17–29%. qoi's encoder and decoder steps no longer allocate.

Added

  • A memory check in debug builds. A freed value is marked, filled with junk and kept a while before its memory is used again; retaining, releasing or reading it afterwards stops the program at once, naming what was done and what the value was (memory check: a value ([i64], 4 elements) was read after it was freed). mimic lldb stops right there, with the stack. Release builds are unchanged.
  • Random programs, nightly (tools/fuzz.py, the fuzz workflow): valid programs written at random (numbers, lists, functions that call themselves with a list they grow, copies changed in place) run in release and debug, without the Mimic IR, on one thread and on many; all must print the same. A disagreement is kept with each way's output, to become a fixture.
  • math::to_bits, math::from_bits (and to_bits32/from_bits32 for f32), bytes::of_f64s and bytes::to_f64s: a float's bits as an integer, and floats as little-endian bytes, both exact (weights saved and read back bit for bit).
  • ∧/ and ∨/, the and and or reductions (all and any written as glyphs, as in APL): same ▷ ∧/, ∨/ flags.
  • math::tanh, math::sinh, math::cosh, math::log1p, math::expm1 and math::sigmoid (libm calls that fuse into array kernels like math::exp; log1p and expm1 exact near zero; sigmoid without overflow for large negative inputs), and unwrap_or for an Option: parse_int(s) ▷ unwrap_or(300). Reported by a user.

Changed

  • A tuple of a list and a number (and such: 2 to 4 numbers or values on the heap) is returned as its parts: where the caller takes it apart at once (let (p, root) = find(parent, i)), the function gives its parts in registers, with no tuple made, filled, checked and freed; a tuple written out as the result, in any branch, or handed on from another such call, makes none. A caller that keeps the tuple gets one, as before. Held-out unionfind 6.2 s → 3.2 s, bfsgrid 1.3 s → 0.45 s, textstats 18% faster.
  • char_of(n) of a number takes it as it is: no boxed number made and checked for each character (the same errors for a number that is not a character). The held-out caesar 12% faster.
  • A list of truth values is typed as one when passed or returned: a parameter declared [bool] given [] (or a list of unknown type) is compiled for [bool], the list converted once at the call, and a function declared -> [bool] gives back a typed list, as [i64] and [f64] already did. The held-out bfsgrid read its walls through the generic path at every step: 2.0 s → 1.3 s.
  • join writes its string once: the length is added up first and the parts copied into the new string, instead of a buffer grown (and reallocated) as it goes and then copied again. A word of a few letters joined millions of times: the held-out textstats 24% faster.
  • v[i] = x on a let mut list of numbers is written in place, with nothing counted per step: the number stored directly where the list is held once (else copied first, as before, with the same errors); v[i] read without a reference of its own; and let mut v = xs, changed and then handed on (fill(n - 1, y, v)), moves the list there instead of keeping a reference. The held-out histogram about 15 times as fast.
  • xs ¨ f over a list of lists is one compiled loop (split over the cores when long): each row is lent to f as it is, a lambda that captures or a named function, which returns a number, a truth value, a string or a record (g ¨ (row => row[c]), rows ¨ group_ok). The held-out sudokucheck about twice as fast.
  • xs ¨ f over a list of strings is one compiled loop (split over the cores when long), as it already was over numbers and records: f, a lambda that may capture values (chars(text) ¨ (c => shift(c, k))), gets each string lent and returns its string or number directly, instead of one boxed call per element with its arguments checked each time. markdown, soundex and template 17–29% faster; the held-out caesar from 50× C to 35×.
  • settle and evolve over a record or a list are compiled through the Mimic IR, as they already were over numbers and values kept in registers: the loop holds the state, each step takes it on (changing it in place) and the first state is left as it was when it is still read after the loop. A record built from short lists (S { heap: [x], … }) goes through the IR too. paths' search is in the IR now.
  • concat(s.f, v ⥊ [n]) on a record's list of numbers writes the n copies into the list itself when the record holds it alone: no list of them is made first and joined (qoi's decoder repeating a pixel for a run).
  • if c { [x] } else { [] } taken at every step allocates nothing for the []: a [] typed by the branch next to it is one shared empty list, made once (a change to it copies, as to any shared list), and concat(s.out, flush) with an empty flush leaves the record's list as it is, without a call. A QOI encoder's flush of a run: 46 ms → 29 ms a frame.
  • A small helper returning a tuple, unpacked just before a record update, no longer allocates: let (bytes, op) = chunk(p, prev) followed by { s with out: concat(s.out, bytes), ops: put(s.ops, op, …) } inlines chunk and makes the update in each of its branches, where bytes is a list of known length kept in registers and appended to the record's own list in place; concat(s.out, concat(flush, bytes)) grows s.out instead of building the inner list. qoi on one core: 0.87 s → 0.47 s.
  • A record's list grows in place when the new list is chosen by an if first: let out = if k == 0 { push(s.out, x) } else { concat(s.out, ys) } followed by { s with k: s.k + 2, out: out } gives each branch the update, so a record held once has its list changed in place (as { s with out: push(s.out, x) } already did) instead of copied at every step. An LZ77 decoder's settle over a 512 KiB output: 1.71 s → 0.03 s.
  • push, put and concat of a short list on a record's list of numbers are done inline when the record holds the list alone and it has room: the numbers are stored and the length raised where the code runs, without a call into the runtime (as put on a variable's list already was). A QOI encoder written with them: 0.49 s → 0.35 s on one core.
  • if c { xs } else { [] } is a list of xs's numbers ([i64], [f64] or bytes), not a list of unknown type: the [] takes the other branch's type, as a literal number already did, so code using the result is compiled for its numbers instead of the generic path.
  • Lists of lists are typed by their rows ([[i64]], [[f64]], a matrix built by ⍳ n ¨ (r => ⍳ n ¨ …)): grid[r][c] is a bounds check and a load, where it was two lookups through the runtime with type checks. Conway's Life on a list of rows: 161–338× C before, 5.4× now.
  • Text one character at a time is faster: chars and char_of share one string per ASCII character instead of making a new one each time, and char_code of ASCII text is read in place (of a literal, char_code("a"), it is a constant). A Caesar cipher over 10 MB: 8.8 s to 3.2 s, 1.27 GB to 365 MB.
  • put(xs, i, xs[j]) changes xs in place when it is the list's last use, also as the first argument of another call (insert(put(xs, j + 1, xs[j]), j - 1, v)): the element is read first. It copied the list at every call; a hand-written insertion sort of 20,000 numbers went from 4.4 s and 3 GB to 0.37 s and 2.5 MB.
  • xs ↑ k and xs ↓ k shrink the list in place where it is used for the last time and held nowhere else (a heap's pop, h ↑ (n - 1), copied the heap every time); a read guarded by an if after the take (if n > 1 { rest[0] = h[n - 1] }) is made before it. A heap of a million numbers used over 4 GB; it uses 11.5 MB.
  • A float prints as the shortest text that reads back as the same number ("{x}", print): 15 significant digits where those do, as before, and 16 or 17 where they do not, so parse_float("{x}") is always x. 0.1 + 0.2 now shows as 0.30000000000000004, as in Rust, Go, JavaScript and Python.
  • A list returned in a tuple, or handed back to the function that holds it, is changed in place: let (p, root) = find(…) moves p at its one use, a list passed to the function itself or returned in its result is handed over, and a variable read by another argument of the same call (find(parent, parent[i])) is let go once the arguments are read. A union-find over a million elements used over 4 GB; it now uses 137 MB.
  • A pure ¨ over a short list runs on one core unless its elements are worth sharing out: up to 16,384 elements, a function's first such ¨ is shared out as before while its cost per element is timed, and later ones go to the other cores only when that cost pays for waking them (else they run on one core, timed as they go). A sudoku ...
Read more

Mimic 0.4.2

Choose a tag to compare

@github-actions github-actions released this 23 Nov 23:53
c1ff440

Step 0.4.2, ownership by analysis: in the functions the Mimic IR compiles, a list or record is released right after its last use, handed over instead of shared, and changed in place wherever nothing else holds it, through helper calls, record updates and branches, in debug builds as in optimised ones. Text and functions that call several others now go through the IR too, numbers and literals that live for the whole run are never counted, and operators on values of unknown type no longer allocate their results. Reference-count operations over the corpus fell by 40% (937 million to 563 million, short of the halving the plan aimed at; what is left is mostly in code the IR does not cover yet). mimic check --copies lists the copies a program still makes and why: paths' step makes none; qoi's steps are still compiled by the old code generator (they wait for typed empty lists and tuples holding lists, 0.4.3–0.4.4). sudoku 1.9× faster, vm 1.7×, tokenize 1.5×, totient 1.3×, paths 1.27×, hull 1.2×, lz77 1.18× on this machine; the whole corpus on Linux, macOS and Windows is in BENCHMARK.md.

Added

  • mimic check --copies lists every copy of a list or record the program still makes, where, and why: a put, push or { … with … } on a value used again later (and at which line), read from outside a loop, or borrowed from the caller. Functions the compiler does not analyse yet are listed with the reason. --emit-json gives the same as JSON.

Changed

  • A step function takes its record state wherever it hands it on or updates it last: a record parameter read first (let p = ps[s.i], s.v[i]) and then passed to a function that changes it, or used as the base of a { … with … }, is now taken over, so the change is made in place instead of on a copy: look(look(s, 0), 1), { grow(t, at) with k: t.k + 1 }, let e = learn(d, c) after codes[d.i]. And a field changed in one branch and kept in the other (next: if d == 0 { push(k.next, w) } else { k.next }) is two updates, the one taken in place. These shapes took minutes in 0.4.0 (docs/gaps.md); the corpus already avoids them.
  • A list field changed under a let and stored back is changed in place: let table = put(s.table, h, x) then { s with table: table } copied the whole list (the record still held it when the put ran); the change now happens in the with, which takes the field out of the record, so it is made in place when nothing else holds them. The same for chains of put and push, and { s with out: concat(s.out, ys) } now appends in place in the functions the IR compiles. lz77 is 15% faster (its table of 65,536 entries was copied for every byte).
  • Values are released as soon as they are last used, and handed over instead of shared (docs/design/ownership.md): in the functions the IR covers, a list or record is freed right after its last use (not at the end of its block), given as it is to a function that takes it over, and stored into a record without a new reference. A field read borrows its record. Records on the heap, { r with … } and functions that take over a record argument now go through the IR; floyd is 1.26× faster.
  • put and push on a list of i64 change it in place when nothing else holds it: a list the function owns at its last use (let g = push(h, x), put(put(h, p, b), i, a)) is changed where it is, and { s with v: put(s.v, i, x) } stores the number in place without a call. A function whose list parameter is changed this way at its last use (a heap's sift-up up(put(put(h, p, b), i, a), p)), or handed on to one that is, now takes the list from its caller, so the change is in place there too. Before, a bare put always copied the list.
  • Releasing a number, true, false or a literal no longer calls the runtime: these values live for the whole run, and compiled code now skips them where it releases a value. They were half or more of all reference-count operations in vm, soundex and url; vm is about 4% faster.
  • Text, and functions that call several others, now go through the IR: functions that take or return strings, and blocks with more than one call (only blocks the compiler would actually run in parallel, or start as a task, stay on the old path), now get release-at-last-use and in-place updates. sudoku is 1.9× faster, paths 1.27×; put/push on a list a function only borrows copies it directly instead of taking a reference first. MIMIC_IR=why prints why a function stays on the old path.
  • Comparing or computing with two numbers of unknown type no longer allocates: an operator on two single values whose type the compiler does not know (op == 0 in an interpreter's loop) gave a new value every time; a truth value or an integer from such an operator, and from not, - and ∣ on one value, is now the runtime's own true/false or cached small integer. vm is 1.7× faster (8× fewer values freed), tokenize 1.5×, brainf 6% faster.

Install

Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.

System File Install Also needed
Windows x86_64 (10, 11) mimic-0.4.2-windows-x86_64.zip Double-click install.cmd Nothing: Windows programs are linked with the MinGW-w64 inside mimic.
macOS Apple silicon mimic-0.4.2-macos-arm64.tar.gz ./install.sh The Xcode Command Line Tools (xcode-select --install), for the macOS SDK.
Linux x86_64 mimic-0.4.2-linux-x86_64.tar.gz ./install.sh glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else.

On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:

powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"

The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.

Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.

  • macOS: the script clears the download quarantine. If you copy mimic by hand instead, run xattr -d com.apple.quarantine mimic once.
  • Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
  • Uninstall: ./install.sh --uninstall, or install.cmd -Uninstall on Windows. Your projects are not touched.

First program

mimic create hello
cd hello
mimic run

mimic --help lists every command. SHA256SUMS has the checksum of each file.

Mimic 0.4.1

Choose a tag to compare

@github-actions github-actions released this 22 Nov 09:39
3135c17

Step 0.4.1, the Mimic IR: programs are now compiled through a typed intermediate representation between the syntax tree and LLVM, on by default, with fusion as a pass over it. Array code computed element by element (⍳ n, operators on lists, xs ¨ f, reductions) is fused by the IR, across lets and small helpers it inlines; what the IR does not cover yet is compiled by the old code generator where it stands, until that is retired (0.4.10). Also a security fix for the HTTP client's redirects, and the slowest benchmarks of 0.4.0 traced and most of them made several times faster without a change to the programs: tuples of numbers and short lists stay in registers, lists grown in a loop and lists from flatten stay typed, let lambdas and count's lambda are compiled as functions, gather/trail with a lambda are typed loops, and debug builds change lists in place. fnv1a, crc32, adler32, pagerank, topo and siphash 7–25× faster, sha256 13×, diff 7×, utf8 5.6×; no benchmark slower on Linux, macOS or Windows.

Added

  • The Mimic IR (docs/design/ir.md): a typed intermediate representation (SSA, with structured control flow) between the syntax tree and LLVM, with passes over it: fusion, sinking (work moved into the one branch that needs it) and inlining of small helpers. MIMIC_IR=print shows each function's IR, MIMIC_IR_ONLY=text sends only the functions whose path holds text through it.

Security

  • The HTTP client keeps credentials to the server they were meant for. A redirect from https to http is refused with an Err (the request would go on unencrypted), and a redirect to another server (a different scheme, host or port) leaves Authorization, Cookie and Proxy-Authorization behind; other headers still go along. Before, http::request sent them on to wherever it was redirected.

Changed

  • Programs are compiled through the Mimic IR: the functions it covers (numbers, values kept in registers, loops, match, lists read and owned, reductions, lists computed element by element) go through it, and what it does not cover yet is compiled by the old path where it stands. The same output and speed; MIMIC_IR=0 turns it off.
  • Fusion is decided by the IR: a list computed element by element and read once by a later computation is never built (let ys = xs × 3, let zs = ys + xs, zs ▷ +/ is one loop), nor is a small one read several times (computed again where it is read); xs ¨ f takes part, and so does a small helper, inlined first (fn sq(xs) { xs × xs } then sq(v) ▷ +/ is one loop).
  • +/ ×/ ⌈/ ⌊/ of a list of numbers is the fused engine's kernel (SIMD, split over the cores) instead of the runtime's generic call, its result unboxed.
  • Lists grown in a loop stay typed: push of a number onto a list of that kind of number gives such a list, a loop whose list state changes length (⍳ 16 grown to 64 by push) keeps it typed, and a tuple holding short lists of known length ((i, [8 words])) stays in registers. sha256 13× faster (4.7 s → 0.35 s).
  • A function declared -> [i64] (or [f64]) returns a typed list: a body joining [] with [x] gave a list of unknown type, which the declaration only checked, so the caller worked on boxed values. The result is now made typed as it is returned. diff 7× faster (3.8 s → 0.54 s). A function that returns something else under such a declaration now stops at its return instead of later.
  • flatten(xs ¨ (x => …)) of lists of numbers is typed: its result had no known type, so everything after it ran on the generic path; when the lambda gives a list of numbers, the result is that list of numbers. utf8 5.6× faster (4.0 s → 0.71 s).
  • gather and trail with a lambda over numbers are a typed loop: ways ▷ gather((x, y) => (x + y) % p) sent every pair through the runtime boxed; a lambda that gives back the same kind of number as the list's is now typed and folded in a loop. 3,000,000 numbers: 2.35 s → 0.08 s. A lambda giving another type keeps the general path.
  • count(xs, x => …) is typed and fused: the prelude's count called its lambda as a function value for every element; given a lambda, the call is now written out as its body, +/ (xs ¨ (x => …)). maze 5× and markdown 1.2× faster.
  • A list of literals is built once: ["M" "CM" "D" …] or [1 2 3 …] in a function was built again on every call; it is now built the first time and shared after (a change to it copies, as to any list held twice). roman 2.1× faster (3.2 s → 1.5 s of CPU).
  • A lambda kept in a let and only called is a function: let at = (x, y) => table[…], then at(a, b), called the lambda as a function value, every argument boxed; it now becomes a hidden function taking what it captures as arguments, specialised like any function. 8 million calls in a map: 5.8 s → 0.03 s. A lambda used as a value, or one that assigns, returns or sees a variable that changes later, stays as it was.
  • Tuples of numbers stay in registers: a settle or evolve over a tuple state (a sequential pass, a hash, a binary search) allocated and freed a tuple on every step; a tuple of numbers and truth values is now kept in registers, as records of numbers are. crc32 6.8 s → 0.79 s, fnv1a 4.5 s → 0.62 s, topo 5.1 s → 0.79 s (one core, macOS).
  • Small programs build faster: a one-line program in about 0.45 s instead of 0.6 s on macOS. The linker runs inside mimic instead of as a second process (which took ~0.1 s just to start), and the macOS SDK and OS version are read from their files instead of asking xcrun and sw_vers on every build (~70 ms). MIMIC_DEBUG_PHASES=1 also times code generation, the runtime and linking.

Fixed

  • push onto a short list no longer reallocates every time: a list that had grown past its first block kept asking realloc for more room on each push, though it had plenty. levenshtein (rows built a number at a time) runs 2.5× faster on macOS, more on Windows.
  • MIMIC_IR and MIMIC_DEBUG_DISABLE are part of the build cache's key: a program built with one of them could be reused by a build without it (and the other way round).
  • A redirect to //host/path goes to that host with the request's scheme; it was taken as a path on the same server. A Location too long to follow is an Err instead of a cut-short URL.
  • Debug builds update records in place, as optimised ones do: { s with f: put(s.f, …) } copied the whole list on every step in a debug build (functions never took over their parameters there). A debug sieve of 200,000 took over ten minutes; now 1.8 s.
  • A program with only small maps no longer opens Metal on macOS: the GPU was asked before the map's size was checked, and asking opens Metal (~0.13 s). A program over 1,000 numbers ran in 0.14 s; now 0.01 s. Large maps go to the GPU as before.

Install

Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.

System File Install Also needed
Windows x86_64 (10, 11) mimic-0.4.1-windows-x86_64.zip Double-click install.cmd Nothing: Windows programs are linked with the MinGW-w64 inside mimic.
macOS Apple silicon mimic-0.4.1-macos-arm64.tar.gz ./install.sh The Xcode Command Line Tools (xcode-select --install), for the macOS SDK.
Linux x86_64 mimic-0.4.1-linux-x86_64.tar.gz ./install.sh glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else.

On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:

powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"

The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.

Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.

  • macOS: the script clears the download quarantine. If you copy mimic by hand instead, run xattr -d com.apple.quarantine mimic once.
  • Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
  • Uninstall: ./install.sh --uninstall, or install.cmd -Uninstall on Windows. Your projects are not touched.

First program

mimic create hello
cd hello
mimic run

mimic --help lists every command. SHA256SUMS has the checksum of each file.

Mimic 0.4.1-preview.1

Mimic 0.4.1-preview.1 Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 21 Nov 03:40
f68d90e

A preview of the next version: not a stable release. Install it with mimic upgrade --preview.

Step 0.4.1, the Mimic IR, so far (0.4.1-preview.1): its first part (functions of plain numbers through a typed intermediate representation, off by default), a security fix for the HTTP client's redirects, and the slowest benchmarks of 0.4.0 traced and most of them made several times faster without a change to the programs: tuples of numbers and short lists stay in registers, lists grown in a loop and lists from flatten stay typed, let lambdas and count's lambda are compiled as functions, gather/trail with a lambda are typed loops, and debug builds change lists in place. fnv1a, crc32, adler32, pagerank, topo and siphash 7–25× faster, sha256 13×, diff 7×, utf8 5.6×; no benchmark slower on Linux, macOS or Windows.

Added

  • The first step of the Mimic IR (docs/design/ir.md): functions of plain numbers and truth values can be compiled through a typed intermediate representation, with the same results. Off by default while it grows: MIMIC_IR=1 turns it on, MIMIC_IR=print shows each function's IR.

Security

  • The HTTP client keeps credentials to the server they were meant for. A redirect from https to http is refused with an Err (the request would go on unencrypted), and a redirect to another server (a different scheme, host or port) leaves Authorization, Cookie and Proxy-Authorization behind; other headers still go along. Before, http::request sent them on to wherever it was redirected.

Changed

  • Lists grown in a loop stay typed: push of a number onto a list of that kind of number gives such a list, a loop whose list state changes length (⍳ 16 grown to 64 by push) keeps it typed, and a tuple holding short lists of known length ((i, [8 words])) stays in registers. sha256 13× faster (4.7 s → 0.35 s).
  • A function declared -> [i64] (or [f64]) returns a typed list: a body joining [] with [x] gave a list of unknown type, which the declaration only checked, so the caller worked on boxed values. The result is now made typed as it is returned. diff 7× faster (3.8 s → 0.54 s). A function that returns something else under such a declaration now stops at its return instead of later.
  • flatten(xs ¨ (x => …)) of lists of numbers is typed: its result had no known type, so everything after it ran on the generic path; when the lambda gives a list of numbers, the result is that list of numbers. utf8 5.6× faster (4.0 s → 0.71 s).
  • gather and trail with a lambda over numbers are a typed loop: ways ▷ gather((x, y) => (x + y) % p) sent every pair through the runtime boxed; a lambda that gives back the same kind of number as the list's is now typed and folded in a loop. 3,000,000 numbers: 2.35 s → 0.08 s. A lambda giving another type keeps the general path.
  • count(xs, x => …) is typed and fused: the prelude's count called its lambda as a function value for every element; given a lambda, the call is now written out as its body, +/ (xs ¨ (x => …)). maze 5× and markdown 1.2× faster.
  • A list of literals is built once: ["M" "CM" "D" …] or [1 2 3 …] in a function was built again on every call; it is now built the first time and shared after (a change to it copies, as to any list held twice). roman 2.1× faster (3.2 s → 1.5 s of CPU).
  • A lambda kept in a let and only called is a function: let at = (x, y) => table[…], then at(a, b), called the lambda as a function value, every argument boxed; it now becomes a hidden function taking what it captures as arguments, specialised like any function. 8 million calls in a map: 5.8 s → 0.03 s. A lambda used as a value, or one that assigns, returns or sees a variable that changes later, stays as it was.
  • Tuples of numbers stay in registers: a settle or evolve over a tuple state (a sequential pass, a hash, a binary search) allocated and freed a tuple on every step; a tuple of numbers and truth values is now kept in registers, as records of numbers are. crc32 6.8 s → 0.79 s, fnv1a 4.5 s → 0.62 s, topo 5.1 s → 0.79 s (one core, macOS).
  • Small programs build faster: a one-line program in about 0.45 s instead of 0.6 s on macOS. The linker runs inside mimic instead of as a second process (which took ~0.1 s just to start), and the macOS SDK and OS version are read from their files instead of asking xcrun and sw_vers on every build (~70 ms). MIMIC_DEBUG_PHASES=1 also times code generation, the runtime and linking.

Fixed

  • push onto a short list no longer reallocates every time: a list that had grown past its first block kept asking realloc for more room on each push, though it had plenty. levenshtein (rows built a number at a time) runs 2.5× faster on macOS, more on Windows.
  • MIMIC_IR and MIMIC_DEBUG_DISABLE are part of the build cache's key: a program built with one of them could be reused by a build without it (and the other way round).
  • A redirect to //host/path goes to that host with the request's scheme; it was taken as a path on the same server. A Location too long to follow is an Err instead of a cut-short URL.
  • Debug builds update records in place, as optimised ones do: { s with f: put(s.f, …) } copied the whole list on every step in a debug build (functions never took over their parameters there). A debug sieve of 200,000 took over ten minutes; now 1.8 s.
  • A program with only small maps no longer opens Metal on macOS: the GPU was asked before the map's size was checked, and asking opens Metal (~0.13 s). A program over 1,000 numbers ran in 0.14 s; now 0.01 s. Large maps go to the GPU as before.

Install

Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.

System File Install Also needed
Windows x86_64 (10, 11) mimic-0.4.1-preview.1-windows-x86_64.zip Double-click install.cmd Nothing: Windows programs are linked with the MinGW-w64 inside mimic.
macOS Apple silicon mimic-0.4.1-preview.1-macos-arm64.tar.gz ./install.sh The Xcode Command Line Tools (xcode-select --install), for the macOS SDK.
Linux x86_64 mimic-0.4.1-preview.1-linux-x86_64.tar.gz ./install.sh glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else.

On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:

powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"

The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.

Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.

  • macOS: the script clears the download quarantine. If you copy mimic by hand instead, run xattr -d com.apple.quarantine mimic once.
  • Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
  • Uninstall: ./install.sh --uninstall, or install.cmd -Uninstall on Windows. Your projects are not touched.

First program

mimic create hello
cd hello
mimic run

mimic --help lists every command. SHA256SUMS has the checksum of each file.

Mimic 0.4.0

Choose a tag to compare

@github-actions github-actions released this 20 Nov 11:37
e910c9d

Stage 0.4.0, the measuring stick: a benchmark corpus of 130 everyday algorithms (hashing, parsing, graphs, text, interpreters, compression, numbers, simulations, geometry, images, data structures and dynamic programming), each in Mimic, C and Rust and checked against an independent reference; the machine's limits; and a speed gate on Linux, macOS and Windows that fails CI on a slowdown. The corpus found the bugs and slow paths fixed below, and the gaps left for the rest of stage 0.4 (docs/gaps.md). Its algorithms also became standard modules: hash, text, graph, order, parse, compress, and whole numbers in math.

Changed

  • The standard library's own records hold raw numbers, as a program's do: its private helper records (the state of hash, graph, compress, math::primes …) kept every number boxed, so their loops ran 2–15× slower than the same code in a program (math::primes(10000000): 5.0 s → 0.35 s; compress::rle of 4 MB: 1.2 s → 0.15 s). Public types, which the runtime builds too, keep their layout.
  • sieve and kmeans are written as one would write them: sieve keeps its flags in bytes, as C does, and kmeans passes its centres as a record. Both workarounds are gone now that put on bytes is in place and a record passed along a recursion is borrowed.
  • The speed gate times short benchmarks longer: each side runs until it has run for a second (at most 30 runs) before the best time is taken. Benchmarks of 50–130 ms raised false alarms of 6–22% with the best of 3.
  • The gate's noise is measured as the gate compares: bench/run.py --noise now runs the gate's comparison with the same compiler on both sides; a benchmark too noisy for the 25% limit on a platform is reported there, not gated. (The first noise data, ratios to C across whole rounds, overstated it, and a preview's identical compiler failed the gate on tree and ui.)
  • Benchmarks against C and Rust only: the Go versions are gone, from the suite and from the tables in BENCHMARK.md and on the website. The http benchmark's load generator is now a Rust program (bench/http/load/main.rs).

Added

  • Whole numbers in math, from the corpus: math::gcd, lcm, powmod and mulmod (exact for any i64, with 128-bit products), is_prime (Miller-Rabin, exact for every i64), primes (a sieve) and totient, checked against Python and sympy. Golden test math_whole, docs/std.md and the tutorial.
  • compress, from the corpus: compress::rle/unrle, compress::lzw/unlzw (12-bit codes) and compress::varints/unvarints (zigzag LEB128 deltas), checked against reference implementations in Python, with every round trip and each decoder's Err for input it did not make. Golden test compress_module, docs/std.md, the tutorial (chapter 16) and man pages.
  • order and parse, from the corpus: order::lower_bound, upper_bound, select (quickselect) and merge, checked against Python's bisect and sorted; parse::csv (RFC 4180, against Python's csv), parse::url (against urllib.parse.urlsplit) and parse::semver with semver_compare (against the precedence chain of semver.org). Golden test order_parse, docs/std.md, the tutorial (chapter 6) and man pages.
  • graph, from the corpus: graph::bfs, graph::shortest (Dijkstra with a binary heap), graph::components (union-find), graph::topo (Kahn's algorithm, None for a cycle) and graph::mst (Kruskal), on nodes 0 … n - 1 and edges as lists, checked against networkx on graphs of up to 20,000 nodes. Golden test graph_module, docs/std.md, the tutorial (chapter 6) and man pages.
  • text, from the corpus: text::distance (Levenshtein, by characters), text::find_all (every occurrence, overlapping, by KMP), text::soundex and text::wrap (greedy, as Python's textwrap), checked against Python and Soundex's published examples. Every loop is a loop in debug builds too, so a pattern that falls back far or a long name cannot exhaust the stack. Golden test text_module, docs/std.md, the tutorial (chapter 6) and man pages.
  • hash, the first module graduated from the corpus: hash::crc32, crc64, adler32, fnv1a32, fnv1a64, murmur3, xxhash32, xxhash64, siphash, md5, sha1 and sha256 on bytes, checked at every length around their block sizes against Python's zlib, hashlib, xxhash and mmh3 and the published test vectors, in optimised and debug builds alike. Byte-by-byte loops run in chunks, so a debug build hashes any size without running out of stack, and an optimised one as fast as the benchmark's loop. Golden test hash_module, a section in docs/std.md and the tutorial (chapter 16), and man pages (mimic man hash).
  • The corpus reaches 130: 41 more everyday algorithms in Mimic, C and Rust, each checked against an independent reference: numbers (gauss, millerrabin, coprime, totient, partitions, fibmod, catalan, polyeval, bigfact), simulations (shuffle, randwalk, ising, sandpile, rule110, traffic, langton), puzzles (tsp, sudoku, knight, matchain), graphs (mst, bellman, bipartite, flood, maze), data structures (lru, rangemin, intervals, bitset), text (roman, soundex, wordwrap, xmltags, markdown, template, lisp), hashing and ciphers (crc64, sha1, chacha20), base32 and dct. On one core on the M-series Mac most are within 1-2× of C (intervals, mst, bellman, ising, partitions, sha1 and base32 faster); the slowest are text built piece by piece (markdown 4.9×, xmltags 4.4×, soundex 3.6×, roman 3.5×), tsp 4.2× (the table rewritten for each set size), sudoku 3.8× (a new board for each placement) and flood 3.4× (a pair made for each neighbour). Writing them found the fixes above, and gaps recorded in docs/gaps.md.
  • The corpus, more text: zalgo (Z-algorithm), manacher (Manacher's palindromes) and anagram (anagram classes), in Mimic, C and Rust, checked against Python. On one core on the M-series Mac, against C: manacher 1.9×, zalgo 3.2× (sequential passes that put into a list held by a record: 0.4.3), anagram 6.5× (half a million words built letter by letter as strings).
  • The corpus, geometry: hull (convex hull by monotone chain), pip (point in polygon by ray casting) and segments (segment intersection, all pairs), in Mimic, C and Rust, in exact integer arithmetic, checked against Python. On one core on the M-series Mac, against C: hull 0.75× (sorting one number per point), segments 1.1×, pip 1.3×; on all cores 2.2–4.5× faster than C. Found on the way: (a > y) != (b > y) is refused as a chained comparison, and a long condition cannot be split over lines except inside parentheses (docs/gaps.md).
  • The corpus, more parsing, and servers: numparse, semver and ini (checked against Python, ini against configparser), and two servers with their own load generators: http_route (a JSON API with path parameters and 404s) and http_echo (POST bodies answered in upper case), in Mimic, C and Rust (hyper). On one core on the M-series Mac, against C: http_echo 0.96×, http_route 1.6×, numparse 2.4×, semver 3.2×, ini 4.0× (each slice and trim makes a new string: docs/gaps.md, 0.4.12); on all cores both servers match or beat the single-threaded C server.
  • The corpus, more compression and hashing: varint (zigzag LEB128 deltas), bitpack (13-bit values in 64-bit words), lzw, xxhash64, md5 and siphash (SipHash-2-4), in Mimic, C and Rust, checked against Python (xxhash, hashlib, and the SipHash paper's test vector). On one core on the M-series Mac, against C: bitpack 1.8×, md5 1.4×, xxhash64 1.6×, varint 3.9×, lzw 3.8×, siphash 22× (its rounds return the state as a tuple, which is allocated: docs/gaps.md, 0.4.3). bitpack packs and unpacks as one parallel map each; the hashes loop with a function that calls itself, which is many times faster than a settle over a tuple. Found on the way: deep recursion through a function that takes a list or returns a tuple can still overflow the native stack past ~50,000 levels, with no message (docs/gaps.md); a type name for a tuple is not accepted.
  • The corpus, dynamic programming: lcs (longest common subsequence, each row one map and one trail(⌈)), coins (ways to make change) and lis (longest increasing subsequence by patience sorting), in Mimic, C and Rust, checked against Python. On one core on the M-series Mac, against C: lis 0.7×, lcs 1.5×, coins 4.3× (a step that puts into a list held by a record goes through the record each time: docs/gaps.md, 0.4.3). Found on the way: gather with a lambda goes through the runtime one boxed pair at a time (docs/gaps.md, 0.4.1).
  • The corpus, sorting and searching: radix (LSD radix sort), bsearch (binary search, lower bounds) and select (quickselect), in Mimic, C and Rust, checked against numpy. On one core on the M-series Mac, against C: bsearch 0.9×, select 1.6×, radix 4.8× (every put of its placing pass is a call into the runtime: docs/gaps.md, 0.4.3). A bottom-up merge sort is written but waits for lists built from pieces to keep their type (docs/gaps.md).
  • The corpus, images: histeq (histogram equalization), rotate (90° turns), dither (Floyd–Steinberg error diffusion) and integral (a summed-area table and 8,000,000 box sums), in Mimic, C and Rust, checked against Python (numpy for all but dither). On one core on the M-series Mac, against C: histeq 1.7×, rotate 1.6×, dither 2.2×, integral 1.5×; on all cores each is faster than C (frames, rows and boxes run in parallel). Found on the way: a lambda kept in a let and called in a hot loop is 15–40× slower than the same named function (docs/gaps.md, for 0.4.1).
  • The corpus, data structures: bloom, hashmap, heap and fenwick, in Mimic, C and Rust, checked against Python. Each updates a list...
Read more

Mimic 0.4.0-preview.2

Mimic 0.4.0-preview.2 Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 18 Nov 11:02
b6ecd28

A preview of the next version: not a stable release. Install it with mimic upgrade --preview.

Stage 0.4.0, the measuring stick, so far (0.4.0-preview.2): a benchmark corpus of 54 everyday algorithms (hashing, parsing, graphs, text, interpreters, compression, numbers and simulations), each in Mimic, C and Rust; the machine's limits; and a speed gate that fails CI on a slowdown. The corpus already found bugs and the gaps the rest of stage 0.4 closes.

Changed

  • The speed gate times short benchmarks longer: each side runs until it has run for a second (at most 30 runs) before the best time is taken. Benchmarks of 50–130 ms raised false alarms of 6–22% with the best of 3.
  • The gate's noise is measured as the gate compares: bench/run.py --noise now runs the gate's comparison with the same compiler on both sides; a benchmark too noisy for the 25% limit on a platform is reported there, not gated. (The first noise data, ratios to C across whole rounds, overstated it, and a preview's identical compiler failed the gate on tree and ui.)
  • Benchmarks against C and Rust only: the Go versions are gone, from the suite and from the tables in BENCHMARK.md and on the website. The http benchmark's load generator is now a Rust program (bench/http/load/main.rs).

Added

  • The 0.4.0 corpus, text: levenshtein, kmp, utf8, aho (Aho-Corasick), diff (Myers), trie and wordfreq, in Mimic, C and Rust with the same algorithms, checked against Python. Work that splits into independent pieces runs close to C on all cores (kmp 1.07×), while one byte or cell at a time stays 22–36× on one core.
  • The 0.4.0 corpus, numbers and simulations: sieve, montecarlo, blackscholes, heat, life, fft, kmeans and bigmul, in Mimic, C and Rust with the same algorithms, checked against Python (numpy, or its own big integers). Arithmetic over independent elements is at or near C on one core (montecarlo 1.0×, blackscholes 1.18×, kmeans 0.84×) and several times faster on all cores. Writing them found four gaps (docs/gaps.md): a record used inside ¨ is retained and released for every element (20× the CPU time on all cores), put on [u8] copies, math::pi without () passes the checker, and an FFT built from ¨ stages is 6× C.
  • The 0.4.0 corpus, graphs: bfs, components, topo and pagerank, in Mimic, C and Rust with the same algorithms, checked against Python. Writing them found two more ways an update is copied instead of made in place (docs/gaps.md): an if inside { … with … } (118 s against 7 s) and a helper that changes an array its caller's record holds.
  • The 0.4.0 corpus, interpreters and regex: regex (a Thompson NFA engine, checked against Python's re), brainf (a Brainf**k interpreter) and vm (a stack bytecode VM), in Mimic, C and Rust. An interpreter's loop is 27–54× C today (docs/gaps.md).
  • The speed gate: bench/run.py --gate BEFORE builds every benchmark with the changed compiler and with the one it changes, times them in turns on the same machine, and fails on a slowdown beyond that benchmark's tolerance (twice its noise measured on GitHub's machines, 3–25%, from bench/noise/) in 2 of 3 measurements. The bench workflow runs it on release pull requests, nightly on dev, and on pull requests that change what is measured, and checks each time that the compiler without its optimizer (MIMIC_DEBUG_DISABLE=optimizer) fails it.
  • The 0.4.0 corpus, hashing: crc32, adler32, fnv1a, murmur3, xxhash32 and sha256 benchmarks in Mimic, C and Rust, checked against independent references. They show sequential passes over arrays 13–57× slower than C and SHA-256 170× (docs/gaps.md, with the 0.4 steps that fix them), and that Mimic has no fold.
  • The 0.4.0 corpus, parsing: csv, expr, tokenize, url and http_parse, checked against Python's csv, eval, re and urllib. Parsing that splits into independent pieces runs in parallel and is at or near C's time on all cores (csv 0.90×, expr 0.95×); scanning characters one at a time is 25× C on one core (docs/gaps.md).
  • The 0.4.0 corpus, compression: rle, base64 and lz77, checked against Python (base64, and reference implementations). They show where growing a list in a loop copies it: the LZ77 decoder is 476× C (docs/gaps.md). rle found flatten quadratic (fixed above). huffman and bwt follow: huffman showed a settle step written as a lambda copying its state where a named step function changes it in place (37 s against 2.1 s).
  • The share of the machine: bench/machine/ measures the peak floating-point rate and the memory bandwidth, on one core and on all, and benchmarks that declare their work (meta.json: matmul, mandelbrot, prefix_sum so far) also show what share of that limit each version reached (bench/run.py --machine measures again).
  • bench/run.py --json writes a run's times as JSON, and --noise N runs everything N times unchanged and records how much each ratio to C varies on the machine (bench/noise/<platform>.json; the bench workflow's noise input runs it on GitHub's machines). It is the first part of 0.4.0: the speed gate's tolerances come from this measured noise.

Fixed

  • Builds running at once could fail with redefinition of 'MIM_UI_JS': each rewrote the runtime's cached sources while others compiled from them, and the C compiler, which tells files apart by inode, could take one file for another once an inode was reused. The sources of each runtime version are now written once, into a directory moved into place whole.
  • --preview picks only a release with files: the releases feed it reads also lists a tag whose release is still being built, so during the minutes a preview was building, mimic upgrade --preview chose it and failed with a 404. It now takes the newest preview or stable release whose files are there.
  • No release without its files: a release is now published only after its binaries and checksums are uploaded. Before, for a moment a new release could be the latest with nothing to download, and the install command failed with "Not Found" (the install scripts' check on the 0.3.18 release did). That check now runs when the release workflow finishes; it never ran on a release before.
  • Builds at the same time no longer spoil the runtime: files Mimic writes "atomically" (through a temporary file) used a temporary name per process, so two threads of one build writing the same runtime file shared it and could interleave their bytes; CI saw redefinition of 'MIM_UI_JS' once. Every write now has a temporary name of its own, the runtime's object file too.
  • flatten is linear: it joined the lists two at a time, copying the growing result again for every list, so flattening many small lists was quadratic (200,000 pairs: about a minute; now milliseconds). Each element is now placed once, in parallel. The same in the ui module. Found by the 0.4.0 benchmark corpus.

Install

Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.

System File Install Also needed
Windows x86_64 (10, 11) mimic-0.4.0-preview.2-windows-x86_64.zip Double-click install.cmd Nothing: Windows programs are linked with the MinGW-w64 inside mimic.
macOS Apple silicon mimic-0.4.0-preview.2-macos-arm64.tar.gz ./install.sh The Xcode Command Line Tools (xcode-select --install), for the macOS SDK.
Linux x86_64 mimic-0.4.0-preview.2-linux-x86_64.tar.gz ./install.sh glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else.

On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:

powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"

The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.

Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.

  • macOS: the script clears the download quarantine. If you copy mimic by hand instead, run xattr -d com.apple.quarantine mimic once.
  • Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
  • Uninstall: ./install.sh --uninstall, or install.cmd -Uninstall on Windows. Your projects are not touched.

First program

mimic create hello
cd hello
mimic run

mimic --help lists every command. SHA256SUMS has the checksum of each file.

Mimic 0.4.0-preview.1

Mimic 0.4.0-preview.1 Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 17 Nov 22:38
8bb19a1

A preview of the next version: not a stable release. Install it with mimic upgrade --preview.

Stage 0.4.0, the measuring stick, so far (0.4.0-preview.1): a benchmark corpus of everyday algorithms, each in Mimic, C and Rust; the machine's limits; and a speed gate that fails CI on a slowdown. The corpus already found two bugs and the gaps the rest of stage 0.4 closes.

Changed

  • Benchmarks against C and Rust only: the Go versions are gone, from the suite and from the tables in BENCHMARK.md and on the website. The http benchmark's load generator is now a Rust program (bench/http/load/main.rs).

Added

  • The speed gate: bench/run.py --gate BEFORE builds every benchmark with the changed compiler and with the one it changes, times them in turns on the same machine, and fails on a slowdown beyond that benchmark's tolerance (twice its noise measured on GitHub's machines, 3–25%, from bench/noise/) in 2 of 3 measurements. The bench workflow runs it on release pull requests, nightly on dev, and on pull requests that change what is measured, and checks each time that the compiler without its optimizer (MIMIC_DEBUG_DISABLE=optimizer) fails it.
  • The 0.4.0 corpus, hashing: crc32, adler32, fnv1a, murmur3, xxhash32 and sha256 benchmarks in Mimic, C and Rust, checked against independent references. They show sequential passes over arrays 13–57× slower than C and SHA-256 170× (docs/gaps.md, with the 0.4 steps that fix them), and that Mimic has no fold.
  • The 0.4.0 corpus, parsing: csv, expr, tokenize, url and http_parse, checked against Python's csv, eval, re and urllib. Parsing that splits into independent pieces runs in parallel and is at or near C's time on all cores (csv 0.90×, expr 0.95×); scanning characters one at a time is 25× C on one core (docs/gaps.md).
  • The 0.4.0 corpus, compression: rle, base64 and lz77, checked against Python (base64, and reference implementations). They show where growing a list in a loop copies it: the LZ77 decoder is 476× C (docs/gaps.md). rle found flatten quadratic (fixed above). huffman and bwt follow: huffman showed a settle step written as a lambda copying its state where a named step function changes it in place (37 s against 2.1 s).
  • The share of the machine: bench/machine/ measures the peak floating-point rate and the memory bandwidth, on one core and on all, and benchmarks that declare their work (meta.json: matmul, mandelbrot, prefix_sum so far) also show what share of that limit each version reached (bench/run.py --machine measures again).
  • bench/run.py --json writes a run's times as JSON, and --noise N runs everything N times unchanged and records how much each ratio to C varies on the machine (bench/noise/<platform>.json; the bench workflow's noise input runs it on GitHub's machines). It is the first part of 0.4.0: the speed gate's tolerances come from this measured noise.

Fixed

  • No release without its files: a release is now published only after its binaries and checksums are uploaded. Before, for a moment a new release could be the latest with nothing to download, and the install command failed with "Not Found" (the install scripts' check on the 0.3.18 release did). That check now runs when the release workflow finishes; it never ran on a release before.
  • Builds at the same time no longer spoil the runtime: files Mimic writes "atomically" (through a temporary file) used a temporary name per process, so two threads of one build writing the same runtime file shared it and could interleave their bytes; CI saw redefinition of 'MIM_UI_JS' once. Every write now has a temporary name of its own, the runtime's object file too.
  • flatten is linear: it joined the lists two at a time, copying the growing result again for every list, so flattening many small lists was quadratic (200,000 pairs: about a minute; now milliseconds). Each element is now placed once, in parallel. The same in the ui module. Found by the 0.4.0 benchmark corpus.

Install

Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.

System File Install Also needed
Windows x86_64 (10, 11) mimic-0.4.0-preview.1-windows-x86_64.zip Double-click install.cmd Nothing: Windows programs are linked with the MinGW-w64 inside mimic.
macOS Apple silicon mimic-0.4.0-preview.1-macos-arm64.tar.gz ./install.sh The Xcode Command Line Tools (xcode-select --install), for the macOS SDK.
Linux x86_64 mimic-0.4.0-preview.1-linux-x86_64.tar.gz ./install.sh glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else.

On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:

powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"

The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.

Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.

  • macOS: the script clears the download quarantine. If you copy mimic by hand instead, run xattr -d com.apple.quarantine mimic once.
  • Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
  • Uninstall: ./install.sh --uninstall, or install.cmd -Uninstall on Windows. Your projects are not touched.

First program

mimic create hello
cd hello
mimic run

mimic --help lists every command. SHA256SUMS has the checksum of each file.

Mimic 0.3.18

Choose a tag to compare

@github-actions github-actions released this 17 Nov 13:28
2c339f4

Release channels: previews of the next version and nightly builds, alongside stable releases.

Added

  • Release channels: mimic upgrade --preview installs the newest preview of the next version (or stable, when it is newer) and mimic upgrade --nightly the nightly build of the development branch; the channel is remembered, so later mimic upgrades stay on it, and --stable goes back. The install commands take the same options (sh -s -- --preview, $env:MIMIC_CHANNEL = "nightly" on Windows). Stable stays the default, and previews and nightlies never reach the install command or the website unless asked for.

Changed

  • How Mimic is developed: work comes together on a dev branch through reviewed pull requests, main holds releases only, and a nightly build and weekly previews keep each long step visible (docs/versions.md).

Install

Download the file for your system below and unpack it. Then run the install script inside: it copies mimic to ~/.mimic/bin, puts that folder on your PATH, and checks what your system needs.

System File Install Also needed
Windows x86_64 (10, 11) mimic-0.3.18-windows-x86_64.zip Double-click install.cmd Nothing: Windows programs are linked with the MinGW-w64 inside mimic.
macOS Apple silicon mimic-0.3.18-macos-arm64.tar.gz ./install.sh The Xcode Command Line Tools (xcode-select --install), for the macOS SDK.
Linux x86_64 mimic-0.3.18-linux-x86_64.tar.gz ./install.sh glibc 2.28 or newer (Ubuntu 20.04, Debian 10, RHEL 8 or later) and a C compiler (cc) to link native programs. --target x86_64-linux needs nothing else.

On Windows, if double-clicking install.cmd does nothing (some company PCs block scripts), open PowerShell in the unpacked folder and run:

powershell -NoProfile -ExecutionPolicy Bypass -File ".\install.ps1"

The script says if something is missing and how to install it. Open a new terminal afterwards so the new PATH applies.

Upgrading from an earlier Mimic: run the new install script the same way. It replaces the old mimic, clears the build cache the old version left in ~/.mimic/cache (it is rebuilt on first use), and keeps your projects and installed libraries. If another mimic comes first on your PATH, it says where, and offers to remove it.

  • macOS: the script clears the download quarantine. If you copy mimic by hand instead, run xattr -d com.apple.quarantine mimic once.
  • Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
  • Uninstall: ./install.sh --uninstall, or install.cmd -Uninstall on Windows. Your projects are not touched.

First program

mimic create hello
cd hello
mimic run

mimic --help lists every command. SHA256SUMS has the checksum of each file.