Performance
Benchmarks
All numbers below were measured on Lean 4.36.0, pinned to 8 cores (taskset -c 0-7) on an idle Intel Core i7-1265U WSL host, taking the median of three runs. When checking multiple files with canolean --check --bundled-only -j 8, files with the same resolved imports are grouped onto persistent workers, and each worker exits between groups to free imported .olean memory.
For the leanfmt v0.4.5 comparison on the 154 files covered by CCF’s default format check, leanfmt ran the same way CCF’s scripts/lean-format-checks.sh invokes it: lake exe fmt --check --jobs 4 across the four default packages in parallel (45.74 s with --jobs 8). That includes Lake startup time; the project modules leanfmt loads were built beforehand. Because canolean --bundled-only loads only bundled modules, the two tools are not using the same parser context.
For single-file runs across those same 154 CCF files (canolean --bundled-only FILE vs lake exe fmt --check FILE):
- canolean: 0.24 s mean, 0.19 s median, 2.19 s on the 7,775-line
SafetyInvariant.lean. - leanfmt: 0.86 s mean, 0.49 s median, 16.87 s on
SafetyInvariant.lean.
Peak anonymous resident memory (summed across canolean and its frontend, excluding file-backed mappings like Lean’s bundled libraries) was about 56 MiB for a median file and 276 MiB for SafetyInvariant.lean.
Reusing Formatter as a library
A single Formatter instance can format multiple files and caches the loaded Lean environment by its resolved imports (after --bundled-only drops unresolved local imports). Files with the same resolved imports reuse that environment without reloading. When the resolved imports change, the backing Lean process loads the new modules without freeing the old ones — several hundred megabytes each time — so create a separate Formatter per import group unless your files share the same imports.