cgm-zig / What changes
What changes
cgm-zig is a patch set on Zig 0.16.0. Every new compiler behaviour sits behind a new flag, so a stock invocation behaves like stock Zig.
The rows below are drawn from the repository’s commit messages and verification records. Where the record holds no measurement of a change’s effect, the row says not yet measured and does not claim one. The full table, with every file and commit, is in the README.
“Ships off” means the change is in the build but only runs when you ask for it, because its own measurement came out slower.
A crash becomes a named message
| Change | What the record shows | Status |
|---|---|---|
Running out of room in the compiler’s index table stops with a message naming the thread, the index reached, the limit and the remedy. Stock Zig has only an assert, which release builds remove. | Fired live in production twice. The 1,800-module workload then completed where every stock compiler died: exit 0, 18 min 10 s, 18.4 GiB peak (commit a7f31c36). | In the promoted build |
| The index grows from 30 to 31 bits, and the limit the report line prints grows with it. | The per-partition ceiling goes from 67,108,863 to 134,217,727. The plan predicted 4 times; the tree measured 2 times, and the correction is recorded where the prediction was made. The functional suite matched its control: identical failure sets, none unique to this tree. | In the promoted build |
Source rows: (a) in the README.
Messages and reports that name the thing
| Change | What the record shows | Status |
|---|---|---|
| The error for a file owned by two modules names that file, not whichever importer was scanned first. | Before: mod_b.zig:1:1. After: dupe.zig:1:1. Two test snapshots that had pinned the wrong text are tightened, not weakened. | In the promoted build |
-femit-module-graph writes the resolved module graph as JSON before any analysis. | Stock invocations are byte-identical. Effect on a real workload: not yet measured. | In the promoted build |
--time-report-json <path> writes the time report to a file, without needing a live listener. | It made one finding measurable: the linker’s CPU time was 11.2 times its wall time, so it ran beside analysis. | In the promoted build |
The thread-plan report line stays quiet under --listen, as --time-report already does. | A green zig build of a 13-step fixture went from 6 error lines to 0. | In the promoted build |
Source rows: (b) in the README.
Threading and ordering
| Change | What the record shows | Status |
|---|---|---|
std.Thread.Topology reads physical cores and SMT siblings, limited to the cores the process may use. Unknown stays unknown: never guessed as 1 or half the logical count. | 7 of 7 test masks match the sysfs reference. The affinity sabotage control: not yet measured. | In the promoted build |
The worker count is separated from the number of index partitions, so -j moves workers and leaves the limit alone. | -j1 gives 8 partitions. 1,200 files at -j64 give the same result as -j1. On a 6-core, 12-thread host the derived limit is 4.00 times the crash’s ceiling, derived from constants; the real workload’s reproduction is not yet measured in the harness. Race freedom is read and type verified only, and named as a residual. | In the promoted build |
Build steps run in layered order by default (--step-order). | 13 steps: 3.567 s layered, 3.631 s random, 3.760 s declared. A weak result, inside the noise against random. | In the promoted build |
--analysis-order=layered, a priority over work that would be analysed anyway. | +6.59% slower than insertion order in 3 of 3 paired runs, so it stays off. The new optional index behind it has no end-to-end timing yet. | Ships off |
| A reserve of slots keeps the linker from being starved by bulk work. | 0 of 881 thread samples were parked waiting. The deliberate-failure controls: not yet measured. | In the promoted build |
zig build --child-jobs=keep|share|N passes -j to child compilers. Default keep. | share cut peak worker threads from 35 to 10 but was 6.55% slower in 3 of 3 paired runs, so the default stays keep. A small fixture is where share costs most; a large project could invert it. | share ships off |
| A hang the patch set itself caused (a starved thread-id pool) is refused by name. | Found by the harness and fixed in the same run: 0 hangs in 6 configurations, where the first build hung. | In the promoted build |
Source rows: (c) in the README.
Checks before compiling
| Change | What the record shows | Status |
|---|---|---|
zig ast-check --module-graph=<path> file.zig checks a file’s imports against the module graph and ends with one summary you can reconcile. | Without the flag, output is byte-identical to upstream. Effect on a workload: not yet measured. | In the promoted build |
zig ast-check takes many files at once, with a machine-readable --json report. | Memory stays flat: 400 files at 7.6 MB. Beyond that: not yet measured. | In the promoted build |
One word: Compilation.resolveEmitPath becomes pub, because the module graph code calls it from another file. | After the fix the type check reports 0 errors and the stage 3 build exits 0. | In the promoted build |
Source rows: (d) and (e) in the README.
How it was checked
The repository keeps a verification harness of 38 rows that register themselves. After three defects in the harness were fixed without relaxing any row, its final table reads 22 green, 2 red, 9 unknown and 4 inconclusive. The two reds are the two features that ship off. The harness found the hang and the noisy report line above; neither was a row someone had queued. Source: (f) in the README.
What is not claimed
- No speed-up against any other configuration. The two compile-time figures above are wall-clock readings.
- The clean-machine cost acceptance for the newer candidate is unfulfilled, and the repository says no retroactive performance pass is given.
- Neither build is a portable Linux package: both need the system’s LLVM and Clang 21.1 libraries.
- No change to the language, and none to the standard library beyond three additions (
std.Thread.Topology,Io.Threaded.concurrent_reserveandstd.Build.Graph.child_jobs) and one enum member, each with a stock-preserving default.
Which Zig version
0.16.0 is the base and the patch target. Version 0.17 enters only after upstream promotes it to stable; the 0.17 development line failed on the motivating workload from language changes alone, before reaching the crash. Source: README, “What the fork does not change”.