Geometry Node: Strange overhead on access to curve normals #104045

Closed
opened 2023-01-21 14:12:46 +01:00 by Iliya Katushenock · 14 comments

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 527.56

Blender Version
Broken: version: 3.3.2 Release Candidate, branch: master, commit date: 2022-10-26 09:55, hash: 2a7b8e78e1
Worked: (newest version of Blender that worked as expected)

Short description of error
Strange overhead on access to curve normals:

This example demonstrates the big difference in the speed of the Curve Sampling node.
It appears depending on whether the normal attribute for the curve has been precalculated in any way.
As I can guess, these are lazy normal calculations.

Save normals as named attribute No
image.png image.png

Exact steps for others to reproduce the error

  1. Create geometry node tree.
  2. Some curve primitive node and duplicate node. Create a lot of curves.
  3. Sample Curve node (Normal input). Sample Index (for sampled normal) on some other primitive. As index use single value.
    Now, if you save Normal attrinute as named on curve before sampling, you will see x8 time difference in tree timings.

Example file:
Performance5.blend

**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 527.56 **Blender Version** Broken: version: 3.3.2 Release Candidate, branch: master, commit date: 2022-10-26 09:55, hash: `2a7b8e78e1` Worked: (newest version of Blender that worked as expected) **Short description of error** Strange overhead on access to curve normals: This example demonstrates the big difference in the speed of the Curve Sampling node. It appears depending on whether the normal attribute for the curve has been precalculated in any way. As I can guess, these are lazy normal calculations. | Save normals as named attribute | No | | -- | -- | | ![image.png](https://archive.blender.org/developer/F14181309/image.png) | ![image.png](https://archive.blender.org/developer/F14181307/image.png) | **Exact steps for others to reproduce the error** 1. Create geometry node tree. 2. Some curve primitive node and duplicate node. Create a lot of curves. 3. `Sample Curve` node (`Normal` input). `Sample Index` (for sampled normal) on some other primitive. As index use single value. Now, if you save `Normal` attrinute as named on curve before sampling, you will see x8 time difference in tree timings. Example file: [Performance5.blend](https://archive.blender.org/developer/F14181316/Performance5.blend)
Author
Member

Added subscriber: @mod_moder

Added subscriber: @mod_moder
Author
Member

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Added subscriber: @Bradley_G

Added subscriber: @Bradley_G

Performance5_original.blend
The original file from simplification reported to Iliya.
image.png
There are several problems in the node tree.

  1. The Compare node is not and should never result in "True". This means the first switch should always use "Sample Curve-Normal", which makes the second/framed switch result irrelevant.
  2. The second/framed Switch node has a huge performance difference. 600 ms (False) Vs. 2500 ms (True). Note that less nodes in "True" node tree rather takes much more time for the performance.
    The first switch is the cause of this performance difference. If it uses "Normal", it will take less time while giving the wrong results; if it uses "Sample Curve-Normal", it will take more time. However according to 1., this node tree should never use "Normal".
  3. The "False" node tree is functioning well in non-simplified file. It means practically the node tree is using "Sample Curve-Normal", but it's faster than the node tree with just "Sample Curve-Normal".
[Performance5_original.blend](https://archive.blender.org/developer/F14181414/Performance5_original.blend) The original file from simplification reported to Iliya. ![image.png](https://archive.blender.org/developer/F14181415/image.png) There are several problems in the node tree. 1. The Compare node is not and should never result in "True". This means the first switch should always use "Sample Curve-Normal", which makes the second/framed switch result irrelevant. 2. The second/framed Switch node has a huge performance difference. 600 ms (False) Vs. 2500 ms (True). Note that less nodes in "True" node tree rather takes much more time for the performance. The first switch is the cause of this performance difference. If it uses "Normal", it will take less time while giving the wrong results; if it uses "Sample Curve-Normal", it will take more time. However according to 1., this node tree should never use "Normal". 3. The "False" node tree is functioning well in non-simplified file. It means practically the node tree is using "Sample Curve-Normal", but it's faster than the node tree with just "Sample Curve-Normal".
Member

Added subscriber: @HooglyBoogly

Added subscriber: @HooglyBoogly
Member

Changed status from 'Needs Developer To Reproduce' to: 'Archived'

Changed status from 'Needs Developer To Reproduce' to: 'Archived'
Member

Thanks for the report, but I don't think this is a bug. When the normals are calculated, they are cached on the curve. If you calculate them earlier, the price will be payed earlier in the node tree. There are other changes we could make to improve performance in this file, but we don't generally handle that with reports, other than specific todos.

Thanks for the report, but I don't think this is a bug. When the normals are calculated, they are cached on the curve. If you calculate them earlier, the price will be payed earlier in the node tree. There are other changes we could make to improve performance in this file, but we don't generally handle that with reports, other than specific todos.
Author
Member

I drew attention to this due to the fact that the wound several times. Rather, it looks like problems with locks when accessing the normal (or calculating it).

I drew attention to this due to the fact that the wound several times. Rather, it looks like problems with locks when accessing the normal (or calculating it).

This isn't necessarily a bug report, but rather a bizarre phenomenon I find and I can't explain it at all. That's why I talked to others including Iliya before filing a report.
Regardless of reason, I don't think my questions/confusions are really being answered. and especially as an end result, the performance difference is dramatic.

One difference between my file and Iliya's file is that, I have a Switch node that should have never evaluated "Normal" in the node tree.
But somehow it's still improving the performance with a correct result, while "it end up taking more unnecessary nodes".

This isn't necessarily a bug report, but rather a bizarre phenomenon I find and I can't explain it at all. That's why I talked to others including Iliya before filing a report. Regardless of reason, I don't think my questions/confusions are really being answered. and especially as an end result, the performance difference is dramatic. One difference between my file and Iliya's file is that, I have a Switch node that should have never evaluated "Normal" in the node tree. But somehow it's still improving the performance with a correct result, while "it end up taking more unnecessary nodes".
Member

Changed status from 'Archived' to: 'Confirmed'

Changed status from 'Archived' to: 'Confirmed'
Member

Okay, I'll keep this open for now. I don't have time to look into this much now, but D17134 might help a bit. Or the related CoW patch. Not sure.

Okay, I'll keep this open for now. I don't have time to look into this much now, but [D17134](https://archive.blender.org/developer/D17134) might help a bit. Or the related CoW patch. Not sure.

This issue was referenced by 7f958217ad

This issue was referenced by 7f958217ada294a3aa19116aebb7bef832b9c648
Hans Goudey was assigned by Iliya Katushenock 2023-02-03 19:40:41 +01:00
Author
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Author
Member
image.png image.png
| ![image.png](https://archive.blender.org/developer/F14237808/image.png) | ![image.png](https://archive.blender.org/developer/F14237810/image.png) | | -- | -- |
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
4 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#104045
No description provided.