louise
The Louise language: compiler, runtime, std, tooling
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
ADR 0074: Check only the std modules a program reaches
Status: Proposed (2026-11-01, issue #411); needs engineering review (#44). It changes the compilation model of ADR 0006: resolution and type checking no longer run over all of std.
Context
Db::new adds all 41 std modules, and resolution, type checking and Core lowering ran over every one of them, for every program. Only code generation pruned what the program does not use. Nothing documented why. Hello reaches 3 of the 41 modules (std/prelude, std/io and std/ffi), about 18% of std's lines.
Distribution's stage 1 added std/wire, std/dist and std/dist/remote, and louise check of hello took about 8% longer (ADR 0072, Consequences). Each std module added since makes every program slower to check, and the language server too.
Decision
Before resolution, Db::analyze finds the std modules the program reaches, from the parse trees. Only those go to lower_package_for. The others are parsed (std is parsed once per process and shared) but not resolved, type checked or lowered.
The roots:
every module outside std: the package's, its tests', its dependencies', and the generated
[application]module;the prelude;
the std modules that syntax names without an import:
Syntax Module Why an HTML literal std/htmlit is an Elementa template literal std/templateit is a Templateregionstd/refit handles standalloc@remotestd/dist/remotea reference is a Remote
The closure follows imports, transitively. A
@test importcounts only when tests are analysed (ADR 0064). An import names the module that resolution would pick (louise_hir::import_target, shared with it).Every other well-known std item (
louise_types'WellKnown:U64,Dec,Pid,Array, the effectsproc,clock,random, ...) can appear in a program only through an import of its module, or in a value that a reached module made.Nothing else changes. An import of a std module that does not exist is still E0103. The closure is found anew on every analysis, since an edit can add an import; it is a walk over the parse trees the database already holds.
All of std is still checked.
Db::with_all_std()keeps the previous behaviour.louise check --all-stduses it, andscripts/ci.shruns it ontests/run/hello.lsewith--deps-warnings --deny-warnings. The unit tests that read all of std use it too:std_checks_cleanly,std_externsandruntime_constructors.
The Wire table is unchanged
The definitions table and the schema hash must not depend on what is reached, or two builds of one program could disagree. Their roots are the Wire evidence of the modules analysed (ADR 0072). In std, only std/prelude, std/wire and std/dist name Wire, and their evidence is all dictionaries given by their callers. A program that computes the table reaches std/wire. So the table is the same in both modes. the_table_does_not_depend_on_unreached_std (louise_core/tests/wire.rs) compares the table and the hash in both modes for examples/cluster and the dist fixtures.
Consequences
louise checkof hello takes 77% less time, and the front and middle oflouise build85% less (Measurements).- A std module no program reaches is checked only by
--all-std, in CI and instd_checks_cleanly. A user never sees an error from it. --deps-warningsshows std's warnings only for the modules reached.- A rule for std: each
implstays in the module of its trait or of its type. Instances are global, and one in a module the program does not reach is not seen. Today every stdimplfollows this rule. A value whose type needs the instance then comes from a reached module. - New syntax that needs a std module needs a row in the table above (
louise_db'sreach.rs), or programs that use it without an import fail to check. The tests inlouise_dbcover each row. - A program that reaches no
std/wirehas nostd/wire.definitionsorstd/wire.entriesin its Core. Tests that read them importstd/dist. - A compiler pass must not need a std module the program may not reach. HTML precompilation (ADR 0057) needed
std/list'smapandfoldto run at all; it now fuses amaponly when the program hasstd/list, since it then has nomapto fuse. A program that does not reachstd/processgets no root capabilities for spawned actors (Program::actor_caps), since it cannot spawn one. - Optimiser decisions can change. Heuristics that count over the whole Core, such as inlining a function with one caller, no longer see callers in modules nobody reaches. On the 193 programs of
tests/run,tests/bench,tests/ui,tests/stressandtests/compare, the generated C differs for 9 beyond the root capabilities (inlining, and effect indices that follow the number of definitions). The native and interpreter suites print the same output. DefIds differ between the two modes. Nothing depends on them across builds: descriptors and@remotekeys use qualified names.
Measurements
Release builds of louise before and after, on one machine, 15 interleaved runs each, medians in milliseconds. The build runs defeated the build fingerprint with a changed LOUISE_* variable; the C objects stayed cached, so link is most of the rest.
tests/run/hello.lse | parse | resolve | typecheck | lower | optimise | total |
|---|---|---|---|---|---|---|
louise check, before | 5.3 | 15.4 | 35.6 | 59.3 | ||
louise check, after | 5.9 | 3.5 | 3.5 | 13.7 | ||
louise build, before | 5.9 | 14.7 | 34.9 | 7.8 | 9.0 | 196.8 |
louise build, after | 5.7 | 3.8 | 3.5 | 1.0 | 1.6 | 140.6 |
louise check examples/cluster, which reaches 25 of the 41 std modules, went from 79.2 to 40.1 ms (9 interleaved runs). Finding the closure is part of resolve.
Alternatives considered
- Parse only what is reached too. Imports are known only after a parse, so the closure would be found module by module. Std's parse is shared by every
Dbin a process, so the language server would gain nothing. Parse is now the largest phase oflouise checkof hello (5.9 of 13.7 ms); left for later. - Resolve everything, type check only what is reached. Simpler to reason about, but resolving all of std was a quarter of
louise checkof hello, and its diagnostics would still cover modules nobody uses. - Reachability per definition, not per module. Finer, but it needs resolution first, and the gain over modules is small for std, whose modules are small and focused.