Page MenuHome

Performance: AnimationSystem - Action Evaluation Performance
Confirmed, NormalPublicDESIGN


Current Implementation

Currently when evaluating an action the fcurves are evaluated one by one, and does not keep the previous state so it re-evaluates for every curve.


Typically fcurves are ordered (or where not could be ordered) that you are already near the RNA path of the previous evaluated fcurve. When using this concept we could remove rna path resolve partially or completely in most cases. This will reduce the 'steps' to evaluate rna paths, but also allows for optimizations on branching and caching.
T77124: [WIP] Cache `RNA_path_resolve` in dependency graph demonstrates that we can extract some essential bits from an RNA_path_resolve and transfer it to other IDBlocks/types. The patch is limited as it still walks from the start of the IDBlock to the RNAProperty, what still contains overhead (memory creation, memcpy, hashing, etc)

Phases of the implementation

Minimum implementation

  1. Phase 1: Keep track of the last rna_resolved_path and use this when the rna_path is still the same.
  2. Phase 2: Combine array indexes so we just trigger RNA updates once.
  3. Phase 3: Find the shortest path from the last RNA resolved path to the next resolved rna path.

Future developments

Current implementation reduces performance as it reaches to multiple areas of blender in the internal loop. This reduces the branch prediction, d-cache and i-cache of the CPU. We could reduce the inner loop and needed branches to perform the animsys update in multiple phases. Some part of the code is currently done twice (during read and write)

Depsgraph Build time

  1. find curves that needs to be evaluated this list doesn't change that much and could be stored in an animsys_runtime
  2. order the curves based on the RNA Property type.
  3. calculate evaluation instructions to process these curves.

Depsgraph Evaluation time

  1. pre-calculate the fcurves and store them in a array (one loop)
  2. don't find original ID in the inner loop, but place it in the outer loop
  3. go over the evaluate instructions and store the correct fcurve value and link it to the correct RNAProperty (don't store yet)
  4. do the same for the original ID.
  5. go over the value->property list and perform the updates.


The above is focussed on bActions of the AnimSystem. Drivers seems to be evaluated one by one, we should see if we can group them together based on the target.
Still need to look into the overhead of fcurves in the NlaStrip. (id is the object so it could also benefit from the above.).

Event Timeline

Jeroen Bakker (jbakker) changed the task status from Needs Triage to Confirmed.Thu, Jun 25, 12:04 PM
Jeroen Bakker (jbakker) created this task.
Jeroen Bakker (jbakker) changed the subtype of this task from "To Do" to "Design".
Jeroen Bakker (jbakker) renamed this task from [WIP] Performance: AnimationSystem - Action Evaluation Performance to Performance: AnimationSystem - Action Evaluation Performance .Thu, Jun 25, 12:50 PM
Jeroen Bakker (jbakker) updated the task description. (Show Details)