Dependency Graph Evaluation Optimizations #75208

Open
opened 2020-03-30 09:14:41 +02:00 by Jeroen Bakker · 12 comments
Member

During Animation Playback performance analysis we detected some areas the dependency graph evaluation could be improved.

    • Store RNA_path_resolve during dependency graph build
      ** Design Note: If RNA_path_resolve points to a sub-data of ID you are in trouble as CoW pointers aren't available on build time.
    • Reference Custom Data layers During Viewport Dependency Graph Evalution
    • minimize number of relations and nodes.
      ** we should make sure transitive reduction works fine. and remove unused nodes
During Animation Playback performance analysis we detected some areas the dependency graph evaluation could be improved. * - [ ] Store RNA_path_resolve during dependency graph build ** Design Note: If RNA_path_resolve points to a sub-data of ID you are in trouble as CoW pointers aren't available on build time. * - [ ] Reference Custom Data layers During Viewport Dependency Graph Evalution * - [ ] minimize number of relations and nodes. ** we should make sure transitive reduction works fine. and remove unused nodes
Author
Member

Added subscriber: @Jeroen-Bakker

Added subscriber: @Jeroen-Bakker
Author
Member

This comment was removed by @Jeroen-Bakker

*This comment was removed by @Jeroen-Bakker*
Author
Member

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

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

Added subscriber: @sozap

Added subscriber: @sozap

Added subscriber: @Sergey

Added subscriber: @Sergey

Store RNA_path_resolve during dependency graph build
Design Note: If RNA_path_resolve points to a sub-data of ID you are in trouble as CoW pointers aren't available on build time.

Other notes:

  • Builder does not resolve all RNA paths. It does resolution for drivers, but not for f-curves in actions.
  • Builder works in a single thread, so adding more resolutions than needed will give a huge penalty.
  • Builder resolves paths in original datablocks. So you can not re-use resolution result to access properties in evaluated (copy-on-written datablock).

So it's either something like evaluation cache stored in ID which will try to re-use resolved path if it is known. Just similar to how simple Python expressions are parsed and stores. Or, builder would need to do actual datablock copy and switched to work on copied objects (but then sub-data pointers are still a problem).

Reference Custom Data layers During Viewport Dependency Graph Evalution

For the viewport is fine.

For render is safer to copy them rather than reference. Same for dependency graphs which might be used to evaluate same subset of scene from multiple threads.

I would also add TBB flow graphs here. Seems like natural fit, which should reduce amount of code to maintain from our side.

> Store RNA_path_resolve during dependency graph build > Design Note: If RNA_path_resolve points to a sub-data of ID you are in trouble as CoW pointers aren't available on build time. Other notes: - Builder does not resolve all RNA paths. It does resolution for drivers, but not for f-curves in actions. - Builder works in a single thread, so adding more resolutions than needed will give a huge penalty. - Builder resolves paths in original datablocks. So you can not re-use resolution result to access properties in evaluated (copy-on-written datablock). So it's either something like evaluation cache stored in ID which will try to re-use resolved path if it is known. Just similar to how simple Python expressions are parsed and stores. Or, builder would need to do actual datablock copy and switched to work on copied objects (but then sub-data pointers are still a problem). > Reference Custom Data layers During Viewport Dependency Graph Evalution For the viewport is fine. For render is safer to copy them rather than reference. Same for dependency graphs which might be used to evaluate same subset of scene from multiple threads. I would also add TBB flow graphs here. Seems like natural fit, which should reduce amount of code to maintain from our side.

Added subscriber: @ckohl_art

Added subscriber: @ckohl_art
Author
Member

In #75208#909376, @Sergey wrote:

I would also add TBB flow graphs here. Seems like natural fit, which should reduce amount of code to maintain from our side.

The challenge with TBB flow graphs is that a join_node can have max 10 pending tasks. Some options to overcome this limitation are:

  • stack several join_nodes, but this has a penalty and the general advice is not to do this, but use a different scheduling.
  • Only schedule parts of the graph that fit within this limitation and schedule the rest when the pending tasks of a node becomes equal or less then 10. This is tricky as this changes the tree during execution and requires a fence.
  • Only schedule parts that have a 0 or 1 parent. Schedule children only when they get 1 parent. This fits in the current implementation of D7578: Task: Graph Flow Task Scheduling.
  • Schedule only a child when all the parents have been executed. This does not fit the TBB flow graph anymore and we should keep the current implementation.

Looking at it I wouldn't bet too much on TBB flow for depsgraph evaluation, without making sure that num_links_pending fits within this limitation.

> In #75208#909376, @Sergey wrote: > I would also add TBB flow graphs here. Seems like natural fit, which should reduce amount of code to maintain from our side. The challenge with TBB flow graphs is that a join_node can have max 10 pending tasks. Some options to overcome this limitation are: * stack several join_nodes, but this has a penalty and the general advice is not to do this, but use a different scheduling. * Only schedule parts of the graph that fit within this limitation and schedule the rest when the pending tasks of a node becomes equal or less then 10. This is tricky as this changes the tree during execution and requires a fence. * Only schedule parts that have a 0 or 1 parent. Schedule children only when they get 1 parent. This fits in the current implementation of [D7578: Task: Graph Flow Task Scheduling](https://archive.blender.org/developer/D7578). * Schedule only a child when all the parents have been executed. This does not fit the TBB flow graph anymore and we should keep the current implementation. Looking at it I wouldn't bet too much on TBB flow for depsgraph evaluation, without making sure that `num_links_pending` fits within this limitation.
Contributor

Added subscriber: @RedMser

Added subscriber: @RedMser

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

This task doesn't contain enough information to actually work on it. Since there is some discussion going on, I've reclassified it as Design task.
See the 2020-11-12 module meeting notes for more information.

This task doesn't contain enough information to actually work on it. Since there is some discussion going on, I've reclassified it as Design task. See the [2020-11-12 module meeting notes](https://devtalk.blender.org/t/2020-11-12-animation-rigging-module-meeting/16092) for more information.

Added subscriber: @Garek

Added subscriber: @Garek
Philipp Oeser removed the
Interest
Animation & Rigging
label 2023-02-09 14:36:14 +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
7 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#75208
No description provided.