Repository navigation
Mimic 0.4.0-preview.2
Pre-releaseA 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 --noisenow 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 ontreeandui.) - 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),trieandwordfreq, 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 (kmp1.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,kmeansandbigmul, 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 (montecarlo1.0×,blackscholes1.18×,kmeans0.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),puton[u8]copies,math::piwithout()passes the checker, and an FFT built from¨stages is 6× C. - The 0.4.0 corpus, graphs:
bfs,components,topoandpagerank, 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): anifinside{ … 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'sre),brainf(a Brainf**k interpreter) andvm(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 BEFOREbuilds 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%, frombench/noise/) in 2 of 3 measurements. The bench workflow runs it on release pull requests, nightly ondev, 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,xxhash32andsha256benchmarks 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 nofold. - The 0.4.0 corpus, parsing:
csv,expr,tokenize,urlandhttp_parse, checked against Python'scsv,eval,reandurllib. Parsing that splits into independent pieces runs in parallel and is at or near C's time on all cores (csv0.90×,expr0.95×); scanning characters one at a time is 25× C on one core (docs/gaps.md). - The 0.4.0 corpus, compression:
rle,base64andlz77, 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).rlefoundflattenquadratic (fixed above).huffmanandbwtfollow:huffmanshowed asettlestep 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 --machinemeasures again). bench/run.py --jsonwrites a run's times as JSON, and--noise Nruns everything N times unchanged and records how much each ratio to C varies on the machine (bench/noise/<platform>.json; the bench workflow'snoiseinput 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. --previewpicks 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 --previewchose 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. flattenis 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 theuimodule. 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
mimicby hand instead, runxattr -d com.apple.quarantine mimiconce. - Windows: the script unblocks the downloaded files. SmartScreen may still ask the first time: "More info" → "Run anyway".
- Uninstall:
./install.sh --uninstall, orinstall.cmd -Uninstallon Windows. Your projects are not touched.
First program
mimic create hello
cd hello
mimic runmimic --help lists every command. SHA256SUMS has the checksum of each file.