Skip to content

ltm: LTM helper variables push C-LEARN toward the VM slot limit #654

Closed

Description

@bpowers

With LTM on, C-LEARN (test/xmutil_test_models/C-LEARN v77 for Vensim.mdl) generated about 30k helper variables, mostly to capture PREVIOUS(...) values, and compiled to 56,891 result slots against the bytecode VM's limit of 65,536.
A somewhat larger model would not have compiled with LTM.

Current state

C-LEARN with LTM now uses 30,896 slots, 34,640 under the limit, with 6,061 LTM variables.
clearn_ltm_var_count_guardrail pins the variable count and its doc comment records the slot width after each change.
Two of the proposed reductions are in: PREVIOUS/INIT of a single declared element reads the slot directly, and generated equations accept an unambiguous bare element name as a static subscript instead of creating a helper.

A model that does exceed the limit gets a clear compile error suggesting running without LTM (check_layout_addressable), not corrupted output.

Remaining options

If headroom becomes a problem again:

  • pass each referenced variable's declared dimensions to qualify_element_index so ambiguous bare element names can be resolved by position instead of through a helper;
  • compile PREVIOUS(module·output) to a direct read of the output's slot.

Pointers

  • src/simlin-engine/tests/integration/simulate.rs: clearn_ltm_var_count_guardrail
  • src/simlin-engine/src/ltm_augment_index.rs: qualify_element_index, wrap_index_non_matching_in_previous
  • src/simlin-engine/src/compiler/symbolic.rs: check_layout_addressable

Activity

  1. added
    ltm
    on Jun 1, 2026
  2. changed the title [-]ltm: residual ~30k synthesized PREVIOUS helper-aux vars on C-LEARN threaten the VM 65k-slot ceiling[/-] [+]ltm: LTM helper variables push C-LEARN toward the VM slot limit[/+] 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.

    clearn_ltm_var_count_guardrail (src/simlin-engine/tests/integration/simulate.rs:7227) pins C-LEARN's LTM variable count at 6,061, down from about 30k, and its doc comment records 30,896 slots against the 65,536 limit. Exceeding the limit is a clean compile error from check_layout_addressable (src/simlin-engine/src/compiler/symbolic.rs:985, called at db/assemble.rs:1628, tested at symbolic.rs:2344).

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

    enhancementltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions