Performance: AnimationSystem - Action Evaluation Performance #78250

Open
opened 2020-06-25 12:04:06 +02:00 by Jeroen Bakker · 3 comments
Member

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.

Idea

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.
#77124 ([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

    • Phase 1: Keep track of the last rna_resolved_path and use this when the rna_path is still the same.
    • Phase 2: Combine array indexes so we just trigger RNA updates once.

- [ ] 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

  • find curves that needs to be evaluated this list doesn't change that much and could be stored in an animsys_runtime
  • order the curves based on the RNA Property type.

calculate evaluation instructions to process these curves.

Depsgraph Evaluation time

  • pre-calculate the fcurves and store them in a array (one loop)
  • don't find original ID in the inner loop, but place it in the outer loop
  • go over the evaluate instructions and store the correct fcurve value and link it to the correct RNAProperty (don't store yet)
  • do the same for the original ID.

go over the value->property list and perform the updates.

notes

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.).

## 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. ## Idea 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. #77124 ([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 - - [ ] Phase 1: Keep track of the last rna_resolved_path and use this when the rna_path is still the same. - - [ ] Phase 2: Combine array indexes so we just trigger RNA updates once. # - [ ] 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** - find curves that needs to be evaluated this list doesn't change that much and could be stored in an animsys_runtime - order the curves based on the RNA Property type. # calculate evaluation instructions to process these curves. **Depsgraph Evaluation time** - pre-calculate the fcurves and store them in a array (one loop) - don't find original ID in the inner loop, but place it in the outer loop - go over the evaluate instructions and store the correct fcurve value and link it to the correct RNAProperty (don't store yet) - do the same for the original ID. # go over the value->property list and perform the updates. ## notes 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.).
Jeroen Bakker self-assigned this 2020-06-25 12:04:06 +02:00
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Member

Added subscriber: @Jeroen-Bakker

Added subscriber: @Jeroen-Bakker
Jeroen Bakker changed title from [WIP] Performance: AnimationSystem - Action Evaluation Performance to Performance: AnimationSystem - Action Evaluation Performance 2020-06-25 12:50:51 +02:00
Contributor

Added subscriber: @RedMser

Added subscriber: @RedMser
Jeroen Bakker removed their assignment 2022-02-14 15:46:42 +01:00
Philipp Oeser removed the
Interest
Animation & Rigging
label 2023-02-09 14:36:12 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#78250
No description provided.