Skip to content

engine: compile_project_incremental deep-clones CompiledSimulation out of the Arc on every call #643

Description

@bpowers

Problem

After the assembly-memoization change, assemble_simulation returns Arc<CompiledSimulation> (a salsa-tracked memo). But compile_project_incremental (src/simlin-engine/src/db.rs) does (*arc).clone() to return an owned CompiledSimulation, preserving its public signature.

The big win lands: a no-op recompile correctly skips assembly (the memo is reused). But the call still deep-clones the entire CompiledSimulation -- the modules / offsets / cached_constant_info maps -- on every call, even when nothing changed.

Why it matters

The deep clone is pure overhead on the hot recompile path. Returning Arc<CompiledSimulation> to callers would drop even that clone. The downstream callers (libsimlin / pysimlin / cli) construct Vm::new by value, so threading the Arc through (or having Vm::new accept &CompiledSimulation / Arc<CompiledSimulation>) would eliminate the clone end-to-end.

Not a correctness issue

This is a performance follow-up only -- results are unaffected.

Components affected

  • src/simlin-engine/src/db.rs (compile_project_incremental)
  • Callers constructing Vm::new: libsimlin, pysimlin, simlin-cli

Severity

low / perf.

Context

Identified during the salsa-pipeline-cleanup refactor (the assembly-memoization change that introduced Arc<CompiledSimulation> from assemble_simulation).

Activity

  1. added
    engineIssues with the rust-based simulation engine
    rustPull requests that update Rust code
    on May 31, 2026
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

    engineIssues with the rust-based simulation enginerustPull requests that update Rust codetech debt

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions