pragmatrix / granularity

Fine-grained incremental-computation for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Separate static from dynamic dependencies.

pragmatrix opened this issue · comments

commented

With the introduction of the computed! and memo! macros, it can be guaranteed that the dependencies provided are tracked with every re-evaluation of a node.

So it should be possible to separate them into "static" and "dynamic" dependencies. And because most of dependencies will be static, this can be used to optimize runtime behavior in the following ways:

  1. There is no need to dynamically track static dependencies anymore. They are stored in the Computed node at construction time only.
  2. Evaluation can be separated into a iterative and a recursive part. The iterative part makes sure that all static dependencies are up to date before executing the computation and the recursive part "forces" the dynamic dependencies to be re-evaluated. This should keep recursion depths at bay, though I am not sure how effective this is in practice.