Skip to content

perf: make require of large section-heavy developments fast - #1147

Merged
strub merged 1 commit into
mainfrom
long-import
Sep 23, 2026
Merged

strub merged 1 commit into
mainfrom
long-import

Conversation

@strub

@strub strub commented Sep 22, 2026

Copy link
Copy Markdown
Member

Loading a required file skips proofs, but three costs made it slow on
big developments:

  • EcEnv.Mod.by_mpath on a parameterless module went through
    EcSubst.subst_module with an empty substitution, deep-copying the
    whole module expression on every lookup. Inside a section, the
    locality check performs this lookup for each module reference of each
    lemma and module, which dominated the loading time of files built on
    a large extracted module. subst_module now returns such modules
    unchanged.

  • The section dependency analysis descended into the declaration of
    every referenced operator and type, transitively, with a fresh cache
    per item. Each operator and type now records, when bound, the
    non-global items reachable through its declaration, and references
    replay that list instead of descending. Global items always satisfy
    the check, so the outcome is unchanged.

  • The docgen state appended each global item to a list with @,
    quadratic in the number of items of a theory.

@strub strub self-assigned this Sep 22, 2026
Comment thread src/ecSubst.ml Outdated
@strub
strub force-pushed the long-import branch 3 times, most recently from e9289c9 to 2e39fb0 Compare September 23, 2026 13:08
Loading a required file skips proofs, but three costs made it slow on
big developments:

- `EcEnv.Mod.by_mpath` on a parameterless module went through
  `EcSubst.subst_module` with an empty substitution, deep-copying the
  whole module expression on every lookup. Inside a section, the
  locality check performs this lookup for each module reference of each
  lemma and module, which dominated the loading time of files built on
  a large extracted module. `subst_module` now returns such modules
  unchanged.

- The section dependency analysis descended into the declaration of
  every referenced operator and type, transitively, with a fresh cache
  per item. Each operator and type now records, when bound, the
  non-global items reachable through its declaration, and references
  replay that list instead of descending. Global items always satisfy
  the check, so the outcome is unchanged.

- The docgen state appended each global item to a list with `@`,
  quadratic in the number of items of a theory.
@strub
strub enabled auto-merge September 23, 2026 13:11
@strub
strub added this pull request to the merge queue Sep 23, 2026
Merged via the queue into main with commit 884dad7 Sep 23, 2026
19 checks passed
@strub
strub deleted the long-import branch September 23, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants