Skip to content

Route compilation dependency analysis through salsa tracked queries #294

@bpowers

Description

@bpowers

Problem

In src/simlin-engine/src/model.rs, set_dependencies_cached invokes all_deps directly, which walks variable ASTs and recomputes dependency closures on every compile. Because this path never consults db::variable_direct_dependencies or db::model_dependency_graph, salsa's backdating mechanism is bypassed during normal compilation. This means edits that keep dependency sets unchanged still pay the full dependency-analysis cost.

Why it matters

This is an optimization opportunity for the incremental compilation pipeline. Salsa's key performance benefit is skipping recomputation when tracked inputs haven't changed ("backdating"). By computing dependencies outside of salsa's tracked functions, the compilation pipeline cannot take advantage of this -- every recompile pays O(variables * AST-depth) even when no dependencies have changed. For large models this is wasted work.

This is not a correctness issue; the current code produces correct results.

Component(s) affected

  • src/simlin-engine/src/model.rs (set_dependencies_cached, all_deps)
  • src/simlin-engine/src/db.rs (variable_direct_dependencies, model_dependency_graph)

Possible approach

Route the compilation pipeline's dependency analysis through the salsa tracked functions already defined in db.rs (variable_direct_dependencies, model_dependency_graph). This would allow salsa to detect when dependency sets are unchanged and skip downstream recomputation via backdating.

Context

Identified during code review of PR #289.

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineIssues with the rust-based simulation engine

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions