Skip to content

engine: each sync creates new salsa inputs, so nothing is ever cached #290

Closed

Description

@bpowers

Syncing a datamodel into the salsa database created new project, model, and variable inputs every time.
Salsa caches by input identity, not by value, so every sync looked like a change to everything: no cached result was ever reused, and the database grew with stale inputs on each edit.

Sync should keep the input handles from the previous sync, update changed fields in place with salsa's setters, create inputs only for new variables, and drop removed ones.

Current state

This is how sync works on main.
sync_from_datamodel_incremental (in src/simlin-engine/src/db/sync.rs) takes the previous handles and updates fields with set_*(db).to(...), and SimlinDb keeps those handles itself (sync_state) so callers get reuse via SimlinDb::sync without threading state.
The non-incremental sync_from_datamodel still exists for one-shot callers.

Pointers

  • src/simlin-engine/src/db/sync.rs
  • src/simlin-engine/src/db.rs (SimlinDb::sync, sync_state)
  • src/simlin-engine/src/db/sync_identity_tests.rs

Activity

  1. added
    engine
    on Jun 8, 2026
  2. changed the title [-]sync_from_datamodel creates new salsa inputs on every call, defeating cache reuse[/-] [+]engine: each sync creates new salsa inputs, so nothing is ever cached[/+] on Oct 12, 2026
  3. added
    enhancement
    on Oct 12, 2026
  4. bpowers commented on Oct 12, 2026

    @bpowers
    OwnerAuthor

    Closing: already fixed on main.

    sync_from_datamodel_incremental (src/simlin-engine/src/db/sync.rs:1219-1453) reuses the previous sync's input handles and calls a salsa setter only for a field whose value changed (update_source_variable, sync.rs:1150); SimlinDb owns the handles in sync_state (db.rs:235) and libsimlin syncs only through db.sync/sync_staged/restore. Pinned by db/sync_identity_tests.rs and db/sync_differential_tests.rs.

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

    engineenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions