Skip to content

perf: lazy-load stdlib; defer stage registration until referenced by a graph #45

Description

@alpibrupa

Problem

load_stdlib() eagerly loads ~46 stages into memory at CLI startup, regardless of whether the graph being run references any of them. This costs:

  • Cold-start latency (agent-facing; every noether run pays the full load).
  • Memory footprint (in ephemeral containers, small but real).
  • Embedding index construction time (semantic index must cover every stage loaded).

Proposed fix

  1. Parse the target graph first (crates/noether-engine/src/lagrange/ast.rs) and collect the set of signature_ids it references (transitively through Let/Branch).
  2. Load only those stages from the store (local or remote). Stdlib becomes just another lazy-resolved registry.
  3. Keep a --preload-stdlib flag on noether run for workflows that intentionally want the full catalogue in memory (introspection, bench).
  4. Measure: log cold-start p50 and memory before/after on a minimal 3-stage graph.

Acceptance criteria

  • noether run simple-graph.json loads only stages referenced (+ transitive deps).
  • noether stage list still shows the full stdlib (unaffected).
  • Benchmarks recorded in docs/engineering/perf/ showing cold-start improvement.

Priority

Low — polish; real impact is ~10% cold-start improvement for ephemeral invocations. Worth picking up once higher-priority issues clear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions