Anim: thread remake_graph_transdata #119497
No reviewers
Labels
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#119497
Loading…
Reference in New Issue
No description provided.
Delete Branch "ChrisLend/blender:thread_remake_transdata"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
On animations with high key counts,
remake_graph_transdata
takes most of the compute time when moving keys.This patch threads the loop over FCurves in that function to speed things up.
Test file with 10.000 keys per F-Curve
As demonstrated in the measurements, this speeds up the case of modifying a lot of data, while not impacting the case of modifying very little data.
The measurements were taken on an 8c/16t CPU. The higher the thread count, the better the performance gain.
Measurements of
remake_graph_transdata
using the following test file.https://download.blender.org/ftp/sybren/animation-rigging/heavy_mocap_test.blend
For the review:
Is it needed to excludetesthandles_fcurve
from the threading? Is it an issue if we create threads within threads?Answer by @HooglyBoogly on Blender Chat:
No, that's done all the time, and it's a great way to achieve more parallelism. It's a good way to cover both 10000 different FCurves with 4 points each, and 4 FCurves with 10000 points each in the same code
Doing this gave an additional speedup (grain size 1) from 330ms to 275ms.
Grain Size Tests
Note: those tests were done before moving
testhandles_fcurve
into the threaded loop@ -893,3 +893,1 @@
for (FCurve *fcu : fcurves) {
if (fcu->bezt) {
BeztMap *bezm;
blender::threading::parallel_for(fcurves.index_range(), 1, [&](const blender::IndexRange range) {
Looks like you don't need the index here, so it might be better to use
parallel_for_each
. Of course, that's only if you actually want a grain size of one.Even with grain size
1
,range
can have any size. But i wonder if this will be better to testparallel_for_weighted
here.parallel_for_each
uses a different algorithm internally that has more overhead. AFAIK it will always give each element its own thread. I think it's typically only suitable for much more expensive tasks.How about a grain size of 8?
Nice work! Just two small notes that can be addressed when landing.
@ -893,3 +892,1 @@
for (FCurve *fcu : fcurves) {
if (fcu->bezt) {
BeztMap *bezm;
blender::threading::parallel_for(fcurves.index_range(), 8, [&](const blender::IndexRange range) {
Add a comment that explains how the 8 got here.
@ -899,3 +896,1 @@
bezm = bezt_to_beztmaps(fcu->bezt, fcu->totvert);
sort_time_beztmaps(bezm, fcu->totvert);
beztmap_to_data(t, fcu, bezm, fcu->totvert);
if (fcu->bezt) {
if (!fcu->bezt) { continue; }
Gitea already doesn't present this as "it's all the same, just indented", so I think it's fine to restructure the code a bit further for readability.