Open and answer this issue on GitHub.
tools, decision, future · opened 2026-11-04 · updated 2026-11-04 · 0 comments
Should the toolchain get a command that runs a program once with light measurement and then suggests where parallel work would pay, for example nikaia profile? And should those suggestions stay suggestions, or may the compiler later apply them on its own?
This is not needed for the current focus. It is filed now so the reasoning is not lost, and labelled future.
Two questions decide whether a piece of work should run in parallel:
A compiler suggestion built on the first answer alone would be a guess, and a guess is not worth printing. A measured run supplies the second answer. A suggestion that rests on a proof and a measurement is reliable enough to show:
check.nika:212: this loop may run in parallel (proved) and took 38 % of the run, 4 ms per pass on average. Withpar_iterit would spread across the cores.
A loop that may run in parallel but takes microseconds is not mentioned at all.
No interpreter is needed; it is a build option of the existing compiler.
A — no profiling tool. Parallel work stays the programmer’s call, found with an outside profiler. Cost: none. Weakness: the proof the compiler already has is never used to point at a place.
B — suggestions only. nikaia profile measures and prints suggestions; the programmer writes par_iter or async where they agree. What runs is always what is written.
Cost: the instrumented build and the report. Weakness: the programmer must act on it.
C — suggestions, and later an optional checked-in profile. As B. In a later step a project may check in a profile file; the compiler then parallelises the places it proved independent and the profile measured heavy, without a change in the source. Cost: as B, plus the profile format and its place in the build. Weakness: what runs is no longer fully visible in the code; a stale profile can parallelise the wrong places (never an incorrect one, because the proof still decides what may run in parallel).
D — automatic, without a file. The compiler measures and applies on its own. Cost: builds that depend on a run. Not recommended.
The two complement each other:
par_iter or a task in the code.The variant B5 in #1232 (hand a known-heavy call to the pool) needs to know which calls are heavy; a profile is one way to know.
Our compiler is written in Nikaia and has a large, realistic input: the test programs, examples/ and lower-std. Today almost none of its Nikaia runs in parallel. A profiled run would show directly whether the prover’s obligations, the check per function or the emit per function are worth parallelising, and how much of a build is spent in our code against rustc. Before that, a plain measurement as docs/measuring.md says (counted instructions, per phase) answers part of the question without any new tool.
The checker currently threads one mutable context (errors, caches, counters) through every function; that context, not a missing annotation, is what keeps it sequential. A suggestion there would have to say so, not just “add par_iter”.
B now, C as a later step once B has shown its suggestions are right. D not at all.
docs/measuring.md says.nikaia profile: what it measures, what it reports, and that it never changes the program.No build work starts before the owner decides and the version that carries it is chosen.
Generated by Claude Code