notes

What Rust comments cost, 2026-10-07 (provisional name)

Measured 2026-10-07 (UTC), read-only, at base 47a1d85f3, by lane/comment-cost-measurement. calef asked for it after #1799 ran the whole suite, CPU matrix included. calef: "We should also consider if the code comments are just too verbose. We know there is a cost to that verbosity." This note measures; the forks at the end are calef's. The scripts are in comment-cost-2026-10-07/ and run from the repository root (OUT=<dir> sets where they write).

Result.

1. Comment-only Rust changes, and what CI spent on them

Method. For each merged pull request, the diff of its merge commit against the commit's first parent (what the pull request landed). Every changed .rs file was lexed before and after by a small Rust lexer (rustlex.py: nested block comments, raw strings, char literals versus lifetimes). A file edit is comment-only when the code token stream is identical once comments are removed. An added or deleted .rs file counts as code. The non-Rust files of each candidate were then run through prose_only.classify against the tree at its merge commit, exactly as CI would.

pull requests
merged, last 300 300
touched Rust 115
Rust edits all comment-only 18 (16% of Rust pull requests)
... and every other file prose nothing reads 7 (#1794, #1771, #1756, #1679, #1539, #1512, #1507)
had at least one comment-only Rust file 58
already prose-only, no Rust (skipped today) 84

The other 11 of the 18 also changed a note some code names (notes/e1000e.md, the fatal-risks README), so they would run everything regardless. #1799, merged 2026-10-07 UTC, is an eighth of the first kind.

Doctests. None of the 18 changed the code inside a doc comment's fence once the fenced blocks were extracted and compared (q1c.py). One (#1512) edited a line inside a fenced diagram in components/src/line_editor.rs, a binary crate whose diagram no doctest runs. A coarser rule, "the edited doc block contains a fence anywhere", would have excluded 4 of the 7, leaving 3.

Runner minutes (minutes.py). For each pull request, every ci.yml and verify.yml run on its branch (pull_request) and its merge group (merge_group). Job wall time is rounded up to the minute per job. It is split between the jobs a prose-only change still runs (draft gate, clippy) and the rest.

pull request runs (PR + group) skippable minutes of which merge group
#1794 6 + 2 151 75
#1771 2 + 2 163 83
#1756 12 + 2 327 81
#1679 4 + 2 269 128
#1539 8 + 2 231 119
#1512 2 + 2 231 114
#1507 6 + 4 266 130
total 1,638 730

All 18 comment-only pull requests spent 5,918 such minutes, 2,662 of them in the merge queue; the other 11 needed a full run for their notes.

Caveats. Earlier pushes may have carried code a later push removed, so the pull-request half overstates; the merge-group half (730) is the firm figure. A merge group that held another pull request's code would have run everything anyway. The repository is public and hosted minutes are free, so the cost is pool contention and queue latency, not money. The prose gate exists because twelve prose pull requests on 2026-10-05 got required jobs cancelled for want of a runner.

2. Why comments change

Each of the 58 pull requests with a comment-only Rust edit was classified by hand from a word-level diff of the changed comments, by the cause that drove the edit (q1.py writes the diffs).

cause pull requests examples
a fact went stale: code, a ruling or a measurement moved under the comment 24 #1761 (the PCI survey settled which I219), #1739 (argon is a TX1), #1692 (§249 (a running address space stays nameable) changed what is consumed)
new content: a BUGS entry, a measurement, a finding 13 #1687 (eight BUGS from the outsider pass), #1794 (GUID measurement)
a record's status: name ratified, falsification state 8 #1771, #1701, #1730
a rename sweep of an identifier 6 #1584 (recv to receive), #1599 (OP_ to OPERATION_), #1773
a path reference moved 4 #1734 and #1527 (proposals promoted), #1543 (a script renamed), #1552
style or spelling 3 #1549 (backticks), #1539, #1610 (a counted number)

So reference churn as a cause is small. As a passenger it is larger: 38 comment-only file edits in 10 pull requests replaced a file path. And the paths that remain are rotting where nobody looks:

reference in a Rust comment lines citing it gated? dead today
milestone N 6,051 yes, script/roadmap --check and script/citations 0
§N 2,834 yes, script/decisions --check and script/citations 0
a source path (crates/..., kernel/..., script/...) 2,214 no about 60 (regex; some are deliberate history)
a note or design path (notes/...md, design/...md) 1,599 no 16
... of which design/roadmap/proposals/ 13 no 10
a pull request number 182 no not checked

The dead source paths are mostly rename sweeps that stopped at code: crates/slots (7 sites at the 2026-10-15 UTC re-measure, now generational_table), crates/regions (2, now memory_regions), crates/wake_handshake (3, now thread_wake_handshake). The proposal paths are dead by design, since promotion renames the file. The chain that produced #1799 is typical: #1507 cited proposals/the-install-gates-run-nowhere.md, and #1527 rewrote it to milestone 712 (the install gates run nowhere) eight hours later; #1756 cited proposals/the-package-client-becomes-a-program.md, and #1799 rewrites it to its new milestone number a day later. The gated citation kinds have zero dead references, which is the argument for preferring them.

3. How dense, and what a reader pays

Lines are physical lines: a line holding only comment counts as comment, a line with any code counts as code, blank lines neither. vendor/ and patches/ are excluded (q3.py).

area files code lines comment lines comment per code comment share of bytes
kernel/ 136 39,758 36,728 0.92 65%
components/ 65 15,847 12,490 0.79 63%
crates/ 233 91,929 56,615 0.62 54%
other 123 19,653 11,457 0.58 54%
xtask/ 29 13,098 6,469 0.49 50%
system_tests/ 83 20,580 9,917 0.48 49%
all 669 200,865 133,676 0.67 57%

79% of comment lines are doc comments (///, //!).

Reference points, measured with the same lexer on shallow clones taken 2026-10-07. C is lexed as if it were Rust, which is close enough for comments, and license headers count as comment.

tree comment per code comment share of bytes
seL4 src/ (C) 0.15 18%
seL4 include/ (C) 0.30 30%
Redox kernel src/ 0.09 12%
Linux kernel/ (C) 0.33 30%
Rust library/std/src 0.55 36%
Rust library/alloc/src 0.88 45%
Rust library/core/src 1.22 52%
nife kernel/ 0.92 65%

The kernel is commented about six times as densely as seL4's C and three times Linux's kernel/. It is in the range of Rust's alloc and core, whose comments are the published API documentation for every Rust user, examples included. seL4's thin comments are not thrift: its specification and proofs live in a separate repository, l4v ("formal specifications and proofs for the seL4 microkernel", including a Haskell model "kept in sync with the C code").

The top 20 files by comment lines:

file comment code
kernel/src/sched.rs 3,981 4,073
crates/system_initializer/src/lib.rs 2,959 3,169
crates/file_system_contract/src/lib.rs 2,812 2,637
crates/grant_plan/src/lib.rs 2,673 4,088
components/src/swish.rs 1,952 3,690
kernel/src/user.rs 1,888 1,737
xtask/src/swish_check.rs 1,563 2,628
kernel/src/lib.rs 1,384 1,436
redoxfs_server/src/lib.rs 1,351 3,122
components/src/login.rs 1,329 886
system_tests/src/user/tests.rs 1,315 1,885
crates/moho_abi/src/lib.rs 1,154 358
crates/swish/src/lib.rs 1,116 2,573
crates/video_terminal/src/lib.rs 996 2,054
kernel/src/arch/x86_64/mmu.rs 995 1,061
crates/user_mode_runtime/src/lib.rs 953 489
kernel/src/testing.rs 938 499
kernel/src/user/fs_service.rs 856 1,381
kernel/src/arch/riscv64/mmu.rs 849 876
crates/machine_discovery/src/acpi.rs 838 1,969

components/src/login.rs opens with a 689-line module doc. 75 files carry more than 100 lines of //!, 11,076 lines between them.

Reading cost, at the rough rate of 4 bytes per token (an estimate, not a tokenizer count). At the base the median Rust file was 14.3 KB, 56% of it comment; the mean 25.9 KB. Re-measured 2026-10-15 (UTC), after the split series: median 9.2 KB, mean 15.0 KB, 1,225 files where the base had 669. kernel/src/sched.rs was 481 KB at the base, about 120,000 tokens; no agent could read it whole in one call. It has since been split into kernel/src/sched/. The tree's Rust grew from 4.3 to 4.6 million tokens; the comment mass is unchanged, 2.5 million. Comment lines sit mostly in long blocks: 48% of them are in blocks over 10 lines, 20% in blocks over 40.

Milestone-title parentheticals are only 0.5% of comment bytes.

4. Thirty comment blocks, judged against CLAUDE.md's rule

A block is a run of adjacent comment lines of one kind. 28,536 blocks; median 2 lines, mean 4.8. Thirty were drawn uniformly with seed 20261007 (q4.py). Move means the block is a finding, history or design essay that a note should hold; keep and cut are AGENTS.md's own rule.

Keep 24 (80%), cut 4 (13%), move 2 (7%).

A uniform draw over blocks favors two-line comments, so 15 more were drawn weighted by length, which is where the bytes are. 12 keep, 3 move, 0 cut. The moves: components/src/login.rs (a 689-line design document that already has notes/login.md beside it), components/src/rmle.rs (the naming search, a record), and components/src/uptime.rs ("the finding worth stating"). The keeps were long for a reason, such as crates/memory_regions/src/table.rs::DestroyClaim, whose doctests are a gate on a type's traits.

The finding: almost nothing in this tree's comments restates the code. The cost is volume of legitimate explanation plus history and findings that accumulate in place, which is what "correct yourself loudly" produces when the correction is written at the site and never retired.

Caveats, together

Forks for calef

(a) Should helpers/prose_only.py treat comment-only Rust changes as prose?

(b) Should comments stop citing mutable locations?

(c) Should CLAUDE.md's comment-density rule change?