Semantic Diff

#9252 Drop unread data from .cmt files

3 commits

827be160cce2386954ea3cf27d3c106540cb2bf6..pr-9252

bc2f41bd6 · cknitt + Claude · Nov 06, 2026, 21:06 UTC

Record value dependencies in .cmt files as two locations and a flag

Why

Each value inclusion check stored both full value descriptions (type, attributes, doc comments) in the .cmt, a fifth of the stdlib's .cmt bytes. Reanalyze, the only reader, uses the two locations and whether both types take optional arguments; the compiler now records just that.

Review

  • Does reanalyze still see the same optional-argument references? Yes: the flag is computed with the same check on the same two types, the deadcode snapshots are unchanged, and forcing the flag off adds three findings to them.
5a289d9e3 · cknitt + Claude · Nov 06, 2026, 21:10 UTC

Stop writing .cmt fields that no tool reads

Why

Eight cmt_infos fields came from OCaml and had no reader: the comments (always empty), the command line, source file, build directory, load path, initial environment, imports and the use_summaries flag. Dropping them and the OCAML_BINANNOT_WITHENV switch (which kept full environments in the typed tree) leaves the module name, the typed tree, the value dependencies, the source digest (rescript-tools migrate) and the deprecation uses. The runtime's .cmt and .cmti files get 3% smaller.

14fa937d6 · cknitt + Claude · Nov 06, 2026, 21:12 UTC

Remove environment summaries

Why

Every environment extension also prepended a summary node (a log of the bindings and opens that built it), and .cmt files kept these logs in every environment of the typed tree. OCaml tools replay them with Envaux to rebuild an environment; this compiler has no Envaux and no tool reads them. The environments stored in .cmt files now keep only their GADT local constraints and flags, and the runtime's .cmt and .cmti files get 7% smaller.

Review

  • Do reanalyze and gentype lose anything? No: they only look types and modules up in typed-tree environments, and the tables those lookups read were already empty in .cmt files.