Repository navigation
Description
Editing a dimension (renaming it, or adding an element) re-lowers and recompiles every variable in the project, not just the variables that use that dimension.
An equation edit recompiles one variable.
Results are correct; this is only the cost of the edit.
Example
On a two-model test fixture with LTM on, adding one element to a dimension re-runs 77 per-variable compiles and 70 lowerings (the whole project).
Editing one equation on the same fixture re-runs 1 of each.
Counted with db::exec_probe::ProbedDb, which records which salsa queries actually re-execute.
Why it matters
Dimension edits are a normal action in the web editor and through MCP edit_model.
On a C-LEARN-sized project each one pays for a full recompile.
The real-model cost has not been measured; the counts above come from a small constructed fixture.
Fix
The parse step already reads only the dimensions a variable's equation names (variable_relevant_dimensions), so a dimension edit re-parses only the variables that use it.
The per-variable compile step does not: it reads the whole-project dimension context.
Give it a per-variable projection instead: the variable's own dimensions, those of each variable it reads, any subrange or element named in a subscript (x[SubA], x[a1]), and the mapping and parent chains of all of those.
Helpers synthesized for a variable (for SMTH1 and the like) use their parent's projection.
Trap: a helper's dimension names are resolved against this context, so if the projection misses one, the helper's shape silently becomes scalar.
Land it with an execution-count test over a dimension edit, beside the existing parse-side ones; the current test (test_dimension_invalidation_different_dim_immune) checks values only and passes either way.
Pointers
src/simlin-engine/src/db/var_fragment.rs:implicit_dep_shape,lowered_source_variable,explicit_fragment_inputsrc/simlin-engine/src/db/fragment_compile.rs:lowered_implicit_variable,implicit_fragment_inputsrc/simlin-engine/src/db/query.rs:variable_relevant_dimensions;db/sync.rs:expand_maps_to_chainsdocs/tech-debt.mdentry 18 tracks the same item
Activity
[-]engine: a dimension edit recompiles every fragment -- the fragment tier reads project_dimensions_context whole while the parse tier is per-variable[/-][+]engine: editing a dimension recompiles every variable in the project[/+]