Geometry Nodes: Edge Paths to Curves node speedup #115115
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#115115
Loading…
Reference in New Issue
No description provided.
Delete Branch "mod_moder/blender:tmp_speedup_edge_paths_to_curves"
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?
Shortest Path is the set of vertices where each point know index of next one.
For some subset of such points (selection input), is built curve from each point
to next one. In a lot of cases, at some point, multiple curve is merged in some
vertex and all next vertices is shared.
To know size of each curve, and allocate result array, each curve need to be traversed.
While traversing of some curves many vertices can be already visited by previous curves.
Idea is to cache count of all next points for each one. If rephrase this, this is traversal
for directed graph in depth. And by caching depth of visited point, this algorithm is
come to be linear for number of points.
Improvement of curves sizes exploring and point indices gathering (ms):
Total time of node evaluation (ms):
Measurement are made in the attached file.
Possible future improvements:
std::set
(with sorting by index) orblender::Set
stack to hold visited vertices, instead of write -i in each of them.Shortest Edge Path
and use more fast algorithm without handling of cycle case.Geometry Nodes: Edge Paths to Curves speedupto Geometry Nodes: Edge Paths to Curves node speedupBig picture, the goals seem nice. I do wonder how much improvement just reserving the vectors with a guess of the final size would give though.
It's not totally clear what's meant by
rang
. Maybe the translation is off. Is it possibly "range"?It seems the need to modify the input
next_indices
array might also cause unnecessary copying in the future (if the values are already stored in a contiguous attribute, for example). Maybe if we traded more strict behavior with invalid indices we could avoid the need to modify that array? (i.e. skipping the entire next vert path if it contains an invalid index).@ -49,1 +51,3 @@
if (next_vert < 0 || next_vert >= mesh.totvert) {
Array<int> rang(mesh.totvert, non_checked);
Array<bool> visited(mesh.totvert, false);
const auto rang_for_vertex = [&](const int vertex) -> int {
Seems there's no need for this to be a lambda
I changed that and it seems that come to be looks more complicated.
Just not sure if that makes sense to use vector is size is known at the begin.
Ah, that is my mistake, that is
rank
!.To me, problem is in another side.
destination
span should be used in evaluation process instead of simply replaceevaluator.get(0).materialize(in);
. Not for now, but hope in future, with new evaluation system...I just avoiding extra branch by representing invalid indices as loop (
a
->b
->c
->i
->-5
) -> (a
->b
->c
->i
->i
).More details about current PR state (file from pr description, but with x10 mesh copies):
Timer 'Roots mask': (Average: 0.64 ms, Min: 0.57 ms, Last: 0.60 ms)
Timer 'Loops incorrect indices': (Average: 0.44 ms, Min: 0.38 ms, Last: 0.47 ms)
Timer 'Count rank': (Average: 61.38 ms, Min: 57.80 ms, Last: 60.72 ms)
Timer 'Accumulate': (Average: 1.55 ms, Min: 1.43 ms, Last: 1.48 ms)
Timer 'Gather indices': (Average: 18.80 ms, Min: 17.02 ms, Last: 17.63 ms)
Timer 'New curves': (Average: 48.38 ms, Min: 44.02 ms, Last: 48.94 ms)
I think i still able to improve
Count rank
part by add lock-free parallelism and maybe by lock-free pool of branches.New curves
part will be fixed in #115693.I just found the fact that my current approach is works differently as current one in main with cycle case (currently loops is always checked until first collision, but in PR, we splits all loops by some certain point and do not check all unreached points...).
Here is a test case for cyclic attractor for Edge Path to Curves. Currently, in main, is expected to go in to the loop body and gather all points of loop single time. In another hand, i did the mistake in this PR, and stop gathering of the loop points at some certain one.
I did the test file to cover this case.
Main:
Timer 'Main loop': (Average: 382.35 ms, Min: 365.30 ms, Last: 378.61 ms)
Timer 'New curves': (Average: 51.83 ms, Min: 48.92 ms, Last: 51.25 ms)
Total: 430 ms
Optimized:
Timer 'Roots mask': (Average: 0.66 ms, Min: 0.57 ms, Last: 0.68 ms)
Timer 'Loops incorrect indices': (Average: 0.45 ms, Min: 0.37 ms, Last: 0.40 ms)
Timer 'Count rank': (Average: 49.03 ms, Min: 45.66 ms, Last: 47.92 ms)
Timer 'Accumulate': (Average: 1.57 ms, Min: 1.43 ms, Last: 1.46 ms)
Timer 'Gather indices': (Average: 19.62 ms, Min: 17.79 ms, Last: 18.88 ms)
Timer 'New curves': (Average: 50.64 ms, Min: 47.03 ms, Last: 51.42 ms)
Total: 120 ms
Parallel rank:
Timer 'Roots mask': (Average: 0.79 ms, Min: 0.57 ms, Last: 0.68 ms)
Timer 'Loops incorrect indices': (Average: 0.54 ms, Min: 0.39 ms, Last: 0.49 ms)
Timer 'Init rank': (Average: 0.37 ms, Min: 0.29 ms, Last: 0.37 ms)
Timer 'Count rank': (Average: 14.73 ms, Min: 11.54 ms, Last: 14.37 ms)
Timer 'Accumulate': (Average: 1.69 ms, Min: 1.44 ms, Last: 1.53 ms)
Timer 'Gather indices': (Average: 20.51 ms, Min: 18.47 ms, Last: 20.47 ms)
Timer 'New curves': (Average: 53.69 ms, Min: 47.52 ms, Last: 53.69 ms)
Total: 90 ms
And i found that in my test file result in different in the main (currently my pr (both simple, and parallel)) creates extra points and the roots of all branches.
Geometry Nodes: Edge Paths to Curves node speedupto WIP: Geometry Nodes: Edge Paths to Curves node speedupMultithreading might introduce a lot of complexity and not so many benefits, so i'll take out that for now.
WIP: Geometry Nodes: Edge Paths to Curves node speedupto Geometry Nodes: Edge Paths to Curves node speedupCheckout
From your project repository, check out a new branch and test the changes.