Skip to content

perf: optimize the updater used for shadow variables in certain cases#1659

Merged
triceo merged 7 commits into
TimefoldAI:mainfrom
Christopher-Chianelli:perf/happy-paths-declarative-shadow-variables
Jun 26, 2025
Merged

perf: optimize the updater used for shadow variables in certain cases#1659
triceo merged 7 commits into
TimefoldAI:mainfrom
Christopher-Chianelli:perf/happy-paths-declarative-shadow-variables

Conversation

@Christopher-Chianelli

Copy link
Copy Markdown
Contributor
  • If only one entity has declarative variables, and all sources are either of the form "previous.*", "undirectional" or "declarative", then create a cascading updater using next to get successor and (index, id(entity)) for the initial sort.
  • If only one entity has declarative variables, and all sources are either of the form "next.*", "undirectional" or "declarative", then create a cascading updater using previous to get successor and (-index, id(entity)) for the initial sort.
  • If there are no dynamic edges, use a fixed topological order for each variable.
  • Otherwise use the current approach.

Undirectional mean variables that don't create edges in the graph (such as accessing a fact on the inverse or genuine variables).

…an update can go

- If only one entity has declarative variables, and all sources are either of the form "previous.*", "undirectional" or "declarative", then create a cascading updater using next to get successor and (index, id(entity)) for the initial sort.
- If only one entity has declarative variables, and all sources are either of the form "next.*", "undirectional" or "declarative", then create a cascading updater using previous to get successor and (-index, id(entity)) for the initial sort.
- If there are no dynamic edges, use a fixed topological order for each variable.
- Otherwise use the current approach.

Undirectional mean variables that don't create edges in the graph (such as accessing a fact on the inverse or genuine variables).

@triceo triceo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First round of review complete. In general, we need more comments/explainers.
I'll run the code through some benchmarks now, see what comes up.

@triceo triceo added this to the v1.24.0 milestone Jun 24, 2025
@triceo triceo linked an issue Jun 24, 2025 that may be closed by this pull request
@triceo triceo removed this from the v1.24.0 milestone Jun 24, 2025

@triceo triceo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The improvements are impressive!
LGTM after comments are resolved.
Also please resolve the Sonar issues - the vast majority of them are trivial, and make sense.

Co-authored-by: Lukáš Petrovický <lukas@petrovicky.net>
@triceo triceo merged commit 81374a6 into TimefoldAI:main Jun 26, 2025
43 checks passed
@sonarqubecloud

Copy link
Copy Markdown

@Christopher-Chianelli Christopher-Chianelli deleted the perf/happy-paths-declarative-shadow-variables branch May 14, 2026 18:02
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.

Performance regression in shadow variable processing

2 participants