Skip to content

Epic: incremental compilation #498

Open

Description

@blacktrs

Goal

Make recompilation cost proportional to what changed. Today every compile re-parses, re-analyzes and re-lowers the whole program, so a one-line edit in a large app (Symfony, Laravel) pays the full front-end cost (minutes, multi-GB IR peak). Target: warm rebuild after a small app edit in seconds, with output byte-identical to a cold build.

Principles

  • Correctness over speed: warm output == cold output, enforced by a test. A cache bug that silently serves stale code is worse than no cache.
  • Content-addressed: keys are hashes of inputs (sources, compiler version, options, MemoryAbi version), never mtimes.
  • Layered: land the cheapest layer with the best win first; each layer is useful on its own.
  • Whole-program passes are the hard part (Monomorphize, InferTypes reruns, InlineClosures, linkonce_odr coalescing): specialization driven by one unit's call sites must not leak into another unit's cached artifact.

Layers (candidate order, to be settled in design)

  1. Parse / AST cache per file, keyed by content hash. Lowest risk; the tolerant parser and ranges (Parser: tolerant mode, source ranges and written names (LSP foundation, phase 1) #481) already give a stable per-file unit.
  2. Signature / symbol index per file or package (.sig-style export, analyzer per-file index Analyzer: library API, incremental per-file index, ranged diagnostics #453), so unchanged units are not re-inferred, only re-linked against.
  3. Per-unit MIR / LLVM IR / .o reuse with a dependency graph and invalidation on signature change. Prior art: the stdlib is already a prebuilt .o + .sig, and auto-split compiles IR in parts.
  4. Dependency units: Composer packages cached by content hash (Cache compilation of Composer packages by content hash #497) — the first concrete customer, since vendor rarely changes.
  5. Watch / daemon mode (long-lived process keeping the index warm), shared with the LSP (manticore lsp: language server over stdio #454).

Work items

  • Cache compilation of Composer packages by content hash #497 Cache compilation of Composer packages by content hash
  • Design doc docs/design/incremental.md: cache unit, key, dependency graph, invalidation, storage layout, GC
  • Cache infrastructure: directory layout, concurrency-safe writes, --no-cache, cache-clean command, hit/miss log
  • Per-file parse/AST cache
  • Signature export/import for unchanged units
  • Cold-vs-warm byte-identity test; cache disabled (or proven identical) for the self-host fixpoint
  • Benchmarks: cold vs warm on examples/symfony-console, Symfony app, Laravel

Out of scope

  • Cross-machine / remote cache (revisit once local cache is stable).
  • Speeding up a cold build (tracked separately: front-end inference cost, IR size).

Acceptance

Warm rebuild after touching one app file does not re-process vendor or untouched app files (verifiable via hit/miss log), is measurably faster with numbers recorded in the design doc, and is byte-identical to a cold build.

Activity

  1. added
    enhancement
    needs-design
    on Oct 26, 2026
  2. blacktrs commented on Oct 26, 2026

    @blacktrs
    ContributorAuthor

    Related spike: #500 (hot reload, time-boxed research).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementneeds-design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions