Description
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.rssrc/simlin-engine/src/db.rs(SimlinDb::sync,sync_state)src/simlin-engine/src/db/sync_identity_tests.rs
Activity
engine: incremental salsa sync, u16 truncation fix, and coverage
engine: incremental salsa sync, u16 truncation fix, and coverage
Incremental compilation via salsa framework (#289)
docs: add finish-salsa-migration design plan
[-]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[/+]bpowers commentedon Oct 12, 2026
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);SimlinDbowns the handles insync_state(db.rs:235) and libsimlin syncs only throughdb.sync/sync_staged/restore. Pinned by db/sync_identity_tests.rs and db/sync_differential_tests.rs.