PBVH task scheduler performance issues #72943
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
8 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#72943
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
This is a task to investigate a possible issue in the PBVH task scheduler.
Issues
Some users report bad performance in sculpt mode, while others can work without problems on really high poly meshes with similar hardware.
On my main computer, brush strokes with TBB disabled feel more responsive regardless the mesh vertex count. When TBB is enabled, strokes usually stop generating new samples in the middle of the stroke or take a fraction of a second to start. I know this is happening to some other users.
Simple operations that need to loop over all vertices on high poly meshes are extremely slow for no specific reason. (doing x = 1.0f - x on a 25M elements array often takes up to 5 seconds). When the operation is more complex (like updating the normals or updating the nodes on the GPU), this can take minutes to finish.
We are not getting the reports of people that may be affected by this issue because most of them assume that Blender sculpt mode performance is just bad by default, so I can't tell if this is a problem with a specific configuration of hardware/software or a general problem in how the scheduler works. It would be nice to have more data from this test (and sculpt mode performance in general) on different hardware/software configurations to have a better understanding of how we can improve it.
How to test:
My results
Operating system: Linux-5.4.2-1-MANJARO-x86_64-with-glibc2.29 64 Bits
CPU: Intel i7 6700K @ 4.00GHz x 8
RAM: 32GB
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 430.64
Subdivide default cube N number of times:
Subdivide default cube 6 times, use multires to N level.
As you can see, a simple loop over all vertices in the mesh is way faster on my setup with TBB disabled.
If I change the ##LEAF_LIMIT## in ##pbvh.c## to 100000 (x10) in order to increase the amount of work each node has and reduce the number of total nodes:
If we compare the two results with TBB on:
It seems like if we avoid starting TBB with a large number of nodes the performance improvement is huge. Increasing the leaf limit makes these kinds of operations up to 23 times faster, but that would be like disabling multithreading for small brush strokes.
Added subscriber: @PabloDobarro
Added subscriber: @ErickNyanduKabongo
Added subscriber: @tux21b
Added subscriber: @ThatAsherGuy
Exposing the leaf limit through the API might let you create a testing script to find the sweet-spots for different scenarios. If there isn't a workable middle ground between the ideal leaf limit for looping over all of the vertices in a high poly mesh and the ideal leaf limit for small brush strokes, you might be able to finesse it with a scaling factor. It'll depend on where the overhead comes from and how linearly that overhead changes, though, and we all know how that goes.
On an abstract level, It'd be interesting to see if we could extend and refit a BVH tree quickly and accurately enough to adjust the leaf limit without rebuilding the tree every time. That's more of a BIH thing than a BVH thing, though.
Added subscriber: @LazyDodo
I only tested the subdivided cube but I can't seem to be able to reproduce your numbers.
System Information
CPU: Intel i7 3770K @ 3.40GHz x 8
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce GTX 1660/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 441.28
Blender Version
Broken: version: 2.82 (sub 6), branch: master (modified), commit date: 2020-01-06 20:54, hash:
3a35301fd1
Subdivide default cube N number of times:
Quite sure unrelated issues i ran into while testing:
I thought i save some time and save the subdivided cube and ran into some crashing behavior
Second thing i ran into is when you use the subdivision modifier i get the same 'PBVH nodes' as listed in your table, but when i used the subdivision set ... operator(?) i get
MASK INVERT: 1 nodes - 0.000005s
nice and fast, but and i pretty much can't sculpt cause blender keeps locking up for a couple of seconds every time i try to make a strokeYo Lazydodo i m in the middle of updating my windows 7 to windows 10, no time compiling, can you share your windows build with this patch so that i test it with different models?
Sorry, went to work on something else afterwards don't have the build anymore
No problemo :)
Added subscriber: @brecht
Likely what happens is that a thread working on a PBVH node is interrupted by the Linux scheduler, and then it takes too long for it to be scheduled again to complete the node, holding up all other threads. There is no direct way to prevent that kind of thing, you can only really ensure code is using good practices and tweak things to indirectly get the Linux scheduler to do what you want. And this is also affected by threads outside of Blender, like a music player or some other more obscure background process.
But you can look into the TBB docs and find some things to tweak:
grainsize
, setting that to 10 means a single thread would handle blocks of 10 PBVH nodes at a time. https://software.intel.com/en-us/node/506144parallel_for
andparallel_reduce
: https://software.intel.com/en-us/node/506149I created a patch to debug Sculpt Mode performance and try to find better defaults. It exposes the settings from the scheduler and the PBVH in the UI: P1208
2020-01-13 18-51-17.mp4
I would like to focus on:
Is there any chance we can record some strokes (data from ghost perhaps?) on a standardized scene and play it back at a later point in time? having a repeatable scenario is generally a huge help when you are trying to nail down a flaky perf issue.
Been prodding around with this, with a with a 25M faces, 50M tris mesh (cube subdiv 11) couple of observations :
kinda feels like it's backing up the GPU ram with regular ram.
{F8277368, width=100%}
If you are having inconsistent performance check that when you are having this flaky behavior you are not out of ram and paging in/out like crazy, cause that would easily explain the performance swings you are seeing.
3.0) while the sculpting is reasonably threaded, everybody idles when the main thread is talking to the GPU (first 7 threads are the TBB threads, 7984 is the main thread) having a colored block means the thread is running, single grey line the thread is sleeping.
{F8277384, width=100%}
the gap where it idles is mostly caused by 2 main offenders
3.1) workbench_deferred_draw_scene marked in blue below.
{F8277386, width=100%}
3.2) VertBuffer_upload_data (also marked in blue)
{F8277389, width=100%}
called from the following call-stack
{F8277395, width=100%}
Added subscriber: @Jeroen-Bakker
#72943.webm
Inside the scope of blender the GPU memory increases with 30 %. Draw performance linux+amd is the same but uses a lot of RAM. Might be a NVIDIA implementation issue. I will check if we can compress the data stream a bit.
Changed status from 'Needs Triage' to: 'Confirmed'