Skip to content

Cache compilation of Composer packages by content hash #497

Open

Description

@blacktrs

Problem

Every compile re-parses, re-analyzes and re-lowers the whole program, including Composer dependencies under vendor/. Vendor code is effectively immutable between compiles (it changes only on composer install/update), yet it dominates front-end time and IR size for real-world apps (Symfony, Laravel: minutes of compile time, multi-GB IR peak). Users pay that cost on every edit of their own code.

Goal

Cache the compilation results of Composer packages, keyed by a content hash, so an unchanged package is not analyzed again on the next compile. Editing application code must not invalidate vendor work.

Proposed approach (to be validated in design)

  • Cache key per package: hash of package files (or composer.lock entry: name + version + dist.reference, with a file-hash fallback for path/VCS repos) + compiler version + options that affect output (target, opt level, type-check mode, MemoryAbi version).
  • Cache unit: package-level (or autoload-unit) artifact, e.g. parsed AST / inferred signatures / MIR / object code. The right layer is the main design question; cheaper layers first (parse + signatures), object-level reuse later.
  • Invalidation: a package's key changes → rebuild that package and everything that depends on its signatures. The dependency graph must be tracked, since app code and other packages reference vendor symbols and vendor code may call app-defined classes (interfaces, callbacks).
  • Storage: a cache directory next to the project (e.g. .manticore/cache/), safe for concurrent compiles, with a cap/GC policy. --no-cache and a clean command for debugging.
  • Correctness first: a cached build must be byte-identical to a cold build. Cross-package whole-program passes (Monomorphize, InferTypes reruns, linkonce_odr coalescing) are the risk: specialization driven by app call sites cannot live inside a vendor artifact.

Open questions

  • Which pipeline stage gives the best win/complexity ratio (parse/AST, .sig-style signature export, MIR, LLVM IR, .o)? Prior art: stdlib already ships as lib/manticore_stdlib.o + .sig.
  • How do monomorphized/generic instantiations and inlined closures that cross the vendor/app boundary get keyed?
  • How are vendor packages with dynamic features (class_exists, reflection, autoload maps) handled?
  • Interaction with manifest builds and the module system (docs/modules.md).

Acceptance criteria

  • Second compile of an unchanged Symfony/Laravel app with a warm cache is measurably faster; report cold vs warm numbers.
  • Touching only app code does not re-process vendor packages (verifiable via a cache hit/miss log).
  • Changing a package version/files invalidates exactly that package and its dependents.
  • Cold and warm outputs are byte-identical; a test asserts it.
  • Self-host fixpoint is unaffected (cache off for the compiler's own build, or proven identical).

Activity

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

    @blacktrs
    ContributorAuthor

    Part of epic #498 (incremental compilation).

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