Spec M35 — benchmark tooling (owner, 2026-09-03)
Goal: numbers over time for the compiler and for compiled programs, reproducible and comparable.
scripts/bench.sh(andmake bench): compile-time benchmarks —mc0 src/mc.mc,mc1 src/mc.mc,mc-exe --exe src/mc.mc,examples/*builds — and run-time micro-benchmarks written in mc (bench/*.mc: fib(30), loops with loads/stores, string building, a channel ping-pong fromexamples/conc, an lx object churn), each run N times withhyperfinewhen installed else an internal timer; output as a Markdown table and a CSV row (bench/results/<date>-<commit>.csv), plus binary sizes and max RSS (/usr/bin/time -l,vmmapown mappings).mc benchsubcommand? No — the tool is a script plus mc programs; nothing enterssrc/.- CI: a
benchjob onmacos-15(manualworkflow_dispatchand on tags) uploading the CSV as an artifact and appending to abenchbranch; the site gets a "Numbers" page rendered from the CSVs. - Regression guard:
make checkkeeps only the cheap size/RSS ceilings (M34); timings are reported, never asserted (runner noise).
Memory evaluation ("mem paranoid") — owner's addition, 2026-09-03 #
Compiled mc programs cannot use ASan/UBSan (those are clang instrumentation; the seed keeps
make stage0-san for the compiler's own C). The equivalent for mc programs is built from the
surface, outside the core:
lib/memcheck.mc(bundled as<memcheck>): a runtime with a shadow map of the program's arena (allocation headers with canaries, red zones, poisoning on free, quarantine for use-after-free, double-free detection, leak report and high-water mark at exit, per-site counters), and a Tier 2pass()that rewrites everyld8..st64and&x-derived access into checked calls (mchk_ld64(p, file, line)), plus UBSan-style checks (shift >= 64, division by zero, signed overflow on+ - *when asked). Cost is opt-in: nothing changes without the flag.- Activation:
[profile] mem = "paranoid"inmc.tomlormc build --paranoid(and--paranoidon the single-file CLI); the driver builds through a taught compiler that registers the pass and links the runtime; aMC_PARANOID=1environment switch at run time toggles the report verbosity. - Taught languages plug in:
examples/lang's rc runtime exposes its allocator to the checker sorc_decbelow zero, dispose-after-free and leaked objects are reported with the.lxposition. lib/bench.mc(bundled as<bench>): timers, counters, allocation statistics and a CSV/Markdown reporter for programs, activated by--bench/[profile] bench = true; the M35 tooling uses it.- Tests: a corpus of deliberately broken programs (
tests/mem/*.mc) each expected to be caught with the right message; a clean program with zero reports; overhead measured and documented. - Distribution to developers: both modules travel in the bundle;
mc --paranoid prog.mcworks from the binary alone. Nothing enterssrc/except the driver flag and the bundle entries.