The checks at scale: the compiler’s own package (#1625)

How often the checker speaks on a large correct program, and how often it is wrong when it does. The program is the self-hosted compiler, the tools package crates/nikaia-std/src/compiler/*.nika. Each file is checked with the rest of the package beside it, as lower-std checks it.

Commands

target/fast/nikaia lower-std --findings > REPORT     # about 2 minutes
target/fast/nikaia run scripts/analysis_scale.nika -- REPORT [--seed N] [--per-code N]

--findings prints every warning the checker gives each file. A plain lower-std drops warnings and stops only on a refusal. Without REPORT the script runs lower-std --findings itself. The sample is seeded (default 1625, up to 20 sites per code), so the same sites come back on every run as long as the code at them stays.

One run

The run was made on develop 0305ee33 plus the --findings flag of this change, with target/fast/nikaia.

Code Warnings Files Per 1000 lines What it says
NK1261 2,828 232 14.43 ref on a parameter is redundant
NK1350 722 138 3.68 a .clone() makes nothing new
NK1111 12 7 0.06 braces in a plain string (migration notice)
NK1216 6 5 0.03 ?? over a value that always has one
NK1217 1 1 0.01 ?. on a value that is never absent

Files with the most warnings:

File Warnings
text_tiers.nika 150
bounds_walk.nika 111
bounds_rules.nika 94
view_changes.nika 87
sharing.nika 72

Reviewed sample (seed 1625)

Each site was read in its source.

Code Sample Correct False alarm Unsure False-alarm rate
NK1261 20 of 2,828 20 0 0 0 % (n = 20)
NK1350 20 of 722 20 0 0 0 % (n = 20)
NK1111 12 of 12 3 9 0 75 % (n = 12), all by design
NK1216 6 of 6 6 0 0 0 % (n = 6)
NK1217 1 of 1 1 0 0 0 % (n = 1)

NK1261. All 20 sites are parameters written ref String, ref String? or ref collections::BTreeMap[..], where a parameter already lends.

NK1350. All 20 sites are correct:

NK1216 and NK1217. Each site sits where the value is known to be there:

NK1111. Three sites are correct, and each is a real defect in the compiler:

The other nine are migration notices on text that means its braces literally. They are by design: unmarked_hole warns on every doubled brace, and on every hole that names something here, because a migration notice cannot know intent. The sites:

So a false alarm here is no bug to file. It counts against keeping the notice once the migration is over.

Site lines. NK1111 and NK1216 inside a match that is bound by a let point at the let, not at the string or the ??. sysroot_package.nika:308 and view_changes.nika:815 are such sites; the code they mean is two and nine lines further down. This was filed as its own defect.

Cost per analysis

lower-std --findings took 2 min 0.7 s wall time (2 min 30.9 s user) for the 271 files; on 2026-11-21 (f03819a5e) 3 min 52.9 s wall, 6 min 22.4 s user.

On one file, nikaia check scripts/analysis_scale.nika (179 lines, 2026-11-21, f03819a5e plus #2187’s change, read with --read):

Analysis Instructions Share of the walk
handles (ADR-312) 2,502 0.0 %
outside data (ADR-prover-refusals-v1) 10,176,230 8.2 %
bounds (ADR-prover-walk-v1) 0 0.0 %
proofs (ADR-269 D4, ADR-prover-refusals-v1 D10) 43,878,584 35.4 %
views (NK2302, NK2305, NK2303) 26,228,170 21.2 %
lints (NK1261, NK1350) 189,707 0.2 %
rest of the walk 43,371,707 35.0 %
the walk 123,846,900 100.0 %

Bounds reads 0 there: a plain check does not run the unsigned-slot pass. The whole package was counted once, file by file, in the next section.

Cost per file against its lines (#2649)

The package cannot be cut by its dependencies. 213 of its 271 files form one cycle, 180,437 of about 205,000 lines (88 %), so no 25 %, 50 % or 75 % cut keeps every file’s dependencies. The unit is the file instead.

The package stays whole. Each file is checked with the others beside it, as lower-std checks it. Only the counting is done per file.

The run:

The run holds 276 dumps:

The sample is --sample 24 (sample_ranks in the script). The 274 files are sorted by lines. The sample takes the smallest file, the 5 largest, and 18 files at evenly spaced ranks in between. The quarters and the fit below are over all 274 files.

File Lines handles (ADR-312) outside data (ADR-prover-refusals-v1) bounds (ADR-prover-walk-v1) proofs (ADR-269 D4, ADR-prover-refusals-v1 D10) views (NK2302, NK2305, NK2303) lints (NK1261, NK1350) rest of the walk the walk walk per line
sources.nika 35 55 685,647 0 20,651,575 366,162,522 4,780 354,691,850 742,196,429 21,205,612
prover_results.nika 103 72 669,850 0 19,351,944 365,651,323 8,395 355,029,915 740,711,499 7,191,373
interpreter.nika 132 427 2,294,761 0 26,569,135 370,180,033 37,056 374,434,466 773,515,878 5,859,968
check_literals.nika 179 1,124 4,222,473 0 66,813,641 376,729,319 127,140 386,618,347 834,512,044 4,662,078
comptime_driver.nika 219 460 3,339,223 0 74,118,210 372,418,898 132,871 380,149,993 830,159,655 3,790,683
emit_keeps.nika 243 520 2,718,363 0 25,914,947 370,891,894 23,238 380,802,518 780,351,480 3,211,322
fix.nika 284 1,145 6,725,391 0 240,884,987 378,071,748 155,911 394,762,747 1,020,601,929 3,593,668
check_notes.nika 329 1,854 5,605,328 0 78,148,959 377,393,248 181,193 416,713,641 878,044,223 2,668,827
emit_kinds.nika 364 24 1,659,212 0 13,552,255 365,684,887 16,859 371,029,987 751,943,224 2,065,778
check_lambdas.nika 402 1,055 4,227,519 0 80,530,183 376,707,824 179,872 410,056,148 871,702,601 2,168,414
emit_holes.nika 463 928 5,982,299 0 106,945,469 386,093,109 222,398 421,971,264 921,215,467 1,989,666
check_boundary.nika 536 1,096 10,390,504 0 48,524,864 380,576,251 220,302 426,541,739 866,254,756 1,616,146
project_check.nika 613 1,834 13,489,361 0 118,218,667 386,365,976 161,192 477,808,557 996,045,587 1,624,870
cexport_node_text.nika 642 0 3,001,260 0 11,393,514 364,103,090 83,987 354,973,233 733,555,084 1,142,609
emit_expr.nika 803 4,232 16,976,335 0 353,528,919 407,419,015 346,116 501,817,216 1,280,091,833 1,594,136
project_features.nika 969 4,285 15,437,844 0 282,174,418 411,994,493 455,855 544,164,083 1,254,230,978 1,294,356
check_state.nika 1,083 213 3,449,072 0 25,044,068 368,569,984 88,784 413,149,009 810,301,130 748,200
check_facts.nika 1,394 134,329 47,907,034 0 1,276,260,233 428,450,922 975,232 614,571,109 2,368,298,859 1,698,923
check_core_places.nika 1,681 6,937 35,857,827 0 253,001,396 449,548,948 774,075 738,725,205 1,477,914,388 879,187
views.nika 3,912 497,014 86,771,955 0 1,080,050,503 593,395,107 2,002,551 1,173,152,701 2,935,869,831 750,477
check_core_stmt.nika 4,795 17,838 105,808,274 0 1,268,532,680 813,412,709 2,381,408 1,554,088,611 3,744,241,520 780,863
prover_walk.nika 5,605 12,768,128 138,014,783 0 1,423,964,262 806,168,477 4,951,417 2,266,262,780 4,652,129,847 829,996
text_tiers.nika 10,081 39,499 176,879,006 0 3,128,899,392 797,961,446 5,661,811 2,301,353,791 6,410,794,945 635,928
bounds_walk.nika 12,955 333,170 220,568,532 0 3,355,581,639 1,167,013,446 6,862,628 3,051,758,011 7,802,117,426 602,247

Instructions per line, all files sorted by lines and cut into quarters (each quarter’s instructions over its lines):

Analysis 35-241 lines 242-439 lines 441-896 lines 924-12,955 lines
handles (ADR-312) 328 208 94 180
outside data (ADR-prover-refusals-v1) 17,935 16,218 17,801 19,989
bounds (ADR-prover-walk-v1) 0 0 0 0
proofs (ADR-269 D4, ADR-prover-refusals-v1 D10) 332,098 248,021 238,360 273,062
views (NK2302, NK2305, NK2303) 2,449,744 1,114,172 625,034 249,300
lints (NK1261, NK1350) 2,568 1,440 693 553
rest of the walk 2,196,567 1,209,843 734,726 398,662
the walk 4,999,242 2,589,904 1,616,711 941,749

A cost fixed per file makes that ratio fall as files grow, even where the cost grows with the lines. So each analysis is fitted as fixed + per line × lines, by least squares over all 274 files. The slope is also fitted alone over the smaller and the larger half of the files by lines:

Analysis Fixed per file Per line Per line, smaller half Per line, larger half
handles (ADR-312) -11,944 189 52 202
outside data (ADR-prover-refusals-v1) 116,778 18,861 15,468 18,587
bounds (ADR-prover-walk-v1) 0 0 0 0
proofs (ADR-269 D4, ADR-prover-refusals-v1 D10) -4,247,843 271,672 217,940 274,214
views (NK2302, NK2305, NK2303) 358,543,347 60,850 38,750 61,354
lints (NK1261, NK1350) 211,314 503 514 551
rest of the walk 320,894,061 225,442 406,827 222,174
the walk 675,505,713 577,518 679,552 577,082

Slopes over narrower ranges of the larger files, from the same 274 rows:

Analysis 440-1,499 lines (104 files) 1,500-3,999 (29) from 1,500 (33) from 3,000 (8)
outside data 20,461 17,554 17,166 15,703
proofs 326,062 198,013 273,188 290,662
views 64,851 51,731 56,934 51,645
lints 325 516 564 518
rest of the walk 258,375 227,384 215,503 192,322
the walk 670,196 495,213 563,533 550,822

Verdict per analysis

In the file’s lines, every analysis is linear. From about 440 lines up, no slope rises with file size. The smaller half’s lower slopes come from the few hundred lines it spans, where the content of each file weighs more than its size.

The fixed cost per file is where the package grows faster than its lines. It is 676 M per file, about 185 G (61 %) of the 305 G that the file checks cost. The 35-line sources.nika costs 742 M. The callgrind inclusive costs of its dump (files.callgrind.275) show where:

Both are worked out again in each file’s check. So the file checks cost about files × package on top of the linear part, and grow with the square of the package as it gets more files.

After the package facts are worked out once (#2685)

Measured again on November 22, 2026, at 0.0.1541, over a sample of 24 files (analysis_cost.nika --files --sample 24), the same fit:

Analysis Fixed per file Per line Per line, smaller half Per line, larger half
handles (ADR-312) -14,072 193 155 205
outside data (ADR-prover-refusals-v1) -651,838 24,366 19,019 24,203
bounds (ADR-prover-walk-v1) 0 0 0 0
proofs (ADR-269 D4, ADR-prover-refusals-v1 D10) -30,994,485 321,103 231,293 331,750
views (NK2302, NK2305, NK2303) 46,319,293 62,477 45,547 62,917
lints (NK1261, NK1350) 40,755 532 376 548
rest of the walk 33,870,860 215,309 179,967 214,797
the walk 48,570,514 623,980 476,357 634,419

The fixed cost per file fell from 676 M to 49 M (views from 359 M to 46 M, the rest of the walk from 321 M to 34 M). What is left grows with the lines; the slopes are those of the 274-file run within the noise of a smaller sample.

This site is open source. Improve this page.