Blender 4.2 Dyntopo sculpt fist stroke performance is very laggy #120593

Open
opened 2024-04-12 20:01:58 +02:00 by Juan Romero · 8 comments

System Information
Operating system: Windows-10-10.0.22621-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 552.12

Blender Version
Broken: version: 4.2.0 Alpha, branch: main, commit date: 2024-04-11 21:26, hash: 52cff75ce080
Worked: (4.1)

Short description of error
When sculpting a mesh of 500.000 triangles in Dyntopo, the first stroke of any of the tools is very laggy, then on the second stroke it improves a lot. It was OK in 4.1

Exact steps for others to reproduce the error

  • Subdivide an mesh to around 1.000.000 triangles
  • Go to Sculpt mode
  • Enable Dyntopo
  • sculp.

In 4.2 is much more laggy than in 4.1 in the first stroke, at least in the file I'm working on.
I can't reproduce it on a default cube, but I can upload my file if needed

**System Information** Operating system: Windows-10-10.0.22621-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 552.12 **Blender Version** Broken: version: 4.2.0 Alpha, branch: main, commit date: 2024-04-11 21:26, hash: `52cff75ce080` Worked: (4.1) **Short description of error** When sculpting a mesh of 500.000 triangles in Dyntopo, the first stroke of any of the tools is very laggy, then on the second stroke it improves a lot. It was OK in 4.1 <video src="/attachments/f15936a5-3d72-4926-8801-6f5e966be702" controls></video> **Exact steps for others to reproduce the error** - Subdivide an mesh to around 1.000.000 triangles - Go to Sculpt mode - Enable Dyntopo - sculp. In 4.2 is much more laggy than in 4.1 in the first stroke, at least in the file I'm working on. I can't reproduce it on a default cube, but I can upload my file if needed
Juan Romero added the
Type
Report
Priority
Normal
Status
Needs Triage
labels 2024-04-12 20:01:59 +02:00
Juan Romero changed title from Blender 4.2 Dyntopo sculpt performance is much worse than 4.1 to Blender 4.2 Dyntopo sculpt fist stroke performance is very laggy 2024-04-12 20:02:33 +02:00

I can confirm that 4.2 is much slower than 4.0.
I attach the file I used for testing.
It may be a little difficult to bisect due to another regression in the area.

@HooglyBoogly, does this ring any bells?

I can confirm that 4.2 is much slower than 4.0. I attach the file I used for testing. It may be a little difficult to bisect due to another regression in the area. @HooglyBoogly, does this ring any bells?
Member

Unfortunately nothing is standing out in performance profiles for me, and I'm not really noticing a noticeable performance difference between the first and second brush strokes.

Unfortunately nothing is standing out in performance profiles for me, and I'm not really noticing a noticeable performance difference between the first and second brush strokes.
Author

do I upload the file to have a look at it?

do I upload the file to have a look at it?
Member

I did a bit of timing with SCOPED_TIMER over the weekend and noticed that SCULPT_stroke_get_location_ex inside sculpt.cc is where the slowdown is happening; I haven't had the chance to dig much further into it though.

I did a bit of timing with `SCOPED_TIMER` over the weekend and noticed that `SCULPT_stroke_get_location_ex` inside `sculpt.cc` is where the slowdown is happening; I haven't had the chance to dig much further into it though.

do I upload the file to have a look at it?

I was able to repro even with a simple plane heavily subdivided. With an M1 MBA so is platform independent.

> do I upload the file to have a look at it? > I was able to repro even with a simple plane heavily subdivided. With an M1 MBA so is platform independent.

Performed several traces on Blender. The first stroke indeed takes longer (detected as hangs in red in XCode Instruments Profiler -> Time Profile)
The second stroke is a bit faster in this case so is not marked in red. By inspecting the call stack I could not find a standing difference, in fact the heaviest call stack is the same for the first and the second stroke:

Heaviest Call Stack Stroke 1 (Severe Hang)

4125 Blender (21975)
4125 main
4125 WM_main(bContext*)
4125 wm_event_do_handlers(bContext*)
4125 wm_handlers_do(bContext*, wmEvent*, ListBase*)
4125 wm_handlers_do_intern(bContext*, wmWindow*, wmEvent*, ListBase*)
4124 wm_handler_operator_call(bContext*, ListBase*, wmEventHandler*, wmEvent*, PointerRNA*, char const*)
4123 blender::ed::sculpt_paint::paint_stroke_modal(bContext*, wmOperator*, wmEvent const*, blender::ed::sculpt_paint::PaintStroke**)
4123 blender::ed::sculpt_paint::paint_space_stroke(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, float const*, float)
4123 blender::ed::sculpt_paint::paint_brush_stroke_add_step(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, float const*, float)
3990 blender::ed::sculpt_paint::sculpt_stroke_update_step(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, PointerRNA*)
3911 do_symmetrical_brush_actions(Sculpt*, Object*, void ()(Sculpt, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*), UnifiedPaintSettings*, PaintModeSettings*)
3911 do_tiled(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*, void ()(Sculpt, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*))
3296 sculpt_topology_update(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*)
2381 blender::bke::pbvh::bmesh_update_topology(PBVH*, PBVHTopologyUpdateMode, float const*, float const*, float, bool, bool)
931 blender::bke::pbvh::long_edge_queue_face_add(blender::bke::pbvh::EdgeQueueContext*, BMFace*)
921 blender::bke::pbvh::edge_queue_tri_in_sphere(blender::bke::pbvh::EdgeQueue const*, BMFace*)
726 closest_on_tri_to_point_v3

Heaviest Call Stack Stroke 2

4019 Blender (21975)
4019 main
4019 WM_main(bContext*)
3509 wm_event_do_handlers(bContext*)
3509 wm_handlers_do(bContext*, wmEvent*, ListBase*)
3509 wm_handlers_do_intern(bContext*, wmWindow*, wmEvent*, ListBase*)
3509 wm_handler_operator_call(bContext*, ListBase*, wmEventHandler*, wmEvent*, PointerRNA*, char const*)
3509 blender::ed::sculpt_paint::paint_stroke_modal(bContext*, wmOperator*, wmEvent const*, blender::ed::sculpt_paint::PaintStroke**)
3509 blender::ed::sculpt_paint::paint_space_stroke(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, float const*, float)
3509 blender::ed::sculpt_paint::paint_brush_stroke_add_step(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, float const*, float)
3294 blender::ed::sculpt_paint::sculpt_stroke_update_step(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, PointerRNA*)
3222 do_symmetrical_brush_actions(Sculpt*, Object*, void ()(Sculpt, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*), UnifiedPaintSettings*, PaintModeSettings*)
3222 do_tiled(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*, void ()(Sculpt, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*))
2725 sculpt_topology_update(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*)
1941 blender::bke::pbvh::bmesh_update_topology(PBVH*, PBVHTopologyUpdateMode, float const*, float const*, float, bool, bool)
698 blender::bke::pbvh::long_edge_queue_face_add(blender::bke::pbvh::EdgeQueueContext*, BMFace*)
688 blender::bke::pbvh::edge_queue_tri_in_sphere(blender::bke::pbvh::EdgeQueue const*, BMFace*)
564 closest_on_tri_to_point_v3

Performed several traces on Blender. The first stroke indeed takes longer (detected as hangs in red in XCode Instruments Profiler -> Time Profile) The second stroke is a bit faster in this case so is not marked in red. By inspecting the call stack I could not find a standing difference, in fact the heaviest call stack is the same for the first and the second stroke: Heaviest Call Stack Stroke 1 (Severe Hang) > 4125 Blender (21975) > 4125 main > 4125 WM_main(bContext*) > 4125 wm_event_do_handlers(bContext*) > 4125 wm_handlers_do(bContext*, wmEvent*, ListBase*) > 4125 wm_handlers_do_intern(bContext*, wmWindow*, wmEvent*, ListBase*) > 4124 wm_handler_operator_call(bContext*, ListBase*, wmEventHandler*, wmEvent*, PointerRNA*, char const*) > 4123 blender::ed::sculpt_paint::paint_stroke_modal(bContext*, wmOperator*, wmEvent const*, blender::ed::sculpt_paint::PaintStroke**) > 4123 blender::ed::sculpt_paint::paint_space_stroke(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, float const*, float) > 4123 blender::ed::sculpt_paint::paint_brush_stroke_add_step(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, float const*, float) > 3990 blender::ed::sculpt_paint::sculpt_stroke_update_step(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, PointerRNA*) > 3911 do_symmetrical_brush_actions(Sculpt*, Object*, void (*)(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*), UnifiedPaintSettings*, PaintModeSettings*) > 3911 do_tiled(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*, void (*)(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*)) > 3296 sculpt_topology_update(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*) > 2381 blender::bke::pbvh::bmesh_update_topology(PBVH*, PBVHTopologyUpdateMode, float const*, float const*, float, bool, bool) > 931 blender::bke::pbvh::long_edge_queue_face_add(blender::bke::pbvh::EdgeQueueContext*, BMFace*) > 921 blender::bke::pbvh::edge_queue_tri_in_sphere(blender::bke::pbvh::EdgeQueue const*, BMFace*) > 726 closest_on_tri_to_point_v3 Heaviest Call Stack Stroke 2 > 4019 Blender (21975) > 4019 main > 4019 WM_main(bContext*) > 3509 wm_event_do_handlers(bContext*) > 3509 wm_handlers_do(bContext*, wmEvent*, ListBase*) > 3509 wm_handlers_do_intern(bContext*, wmWindow*, wmEvent*, ListBase*) > 3509 wm_handler_operator_call(bContext*, ListBase*, wmEventHandler*, wmEvent*, PointerRNA*, char const*) > 3509 blender::ed::sculpt_paint::paint_stroke_modal(bContext*, wmOperator*, wmEvent const*, blender::ed::sculpt_paint::PaintStroke**) > 3509 blender::ed::sculpt_paint::paint_space_stroke(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, float const*, float) > 3509 blender::ed::sculpt_paint::paint_brush_stroke_add_step(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, float const*, float) > 3294 blender::ed::sculpt_paint::sculpt_stroke_update_step(bContext*, wmOperator*, blender::ed::sculpt_paint::PaintStroke*, PointerRNA*) > 3222 do_symmetrical_brush_actions(Sculpt*, Object*, void (*)(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*), UnifiedPaintSettings*, PaintModeSettings*) > 3222 do_tiled(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*, void (*)(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*)) > 2725 sculpt_topology_update(Sculpt*, Object*, Brush*, UnifiedPaintSettings*, PaintModeSettings*) > 1941 blender::bke::pbvh::bmesh_update_topology(PBVH*, PBVHTopologyUpdateMode, float const*, float const*, float, bool, bool) > 698 blender::bke::pbvh::long_edge_queue_face_add(blender::bke::pbvh::EdgeQueueContext*, BMFace*) > 688 blender::bke::pbvh::edge_queue_tri_in_sphere(blender::bke::pbvh::EdgeQueue const*, BMFace*) > 564 closest_on_tri_to_point_v3

As for which commit may have caused the regression I can't tell exactly since trying to go back that far in time
gives me lots of libraries and dependency errors compiling Blender to effectively triage.

The most recent and significant commit in those files has been this refactor from @HooglyBoogly https://projects.blender.org/blender/blender/commit/488de130b39764b2d8564594fc720aa6159e3f39

If someone can test blender before and after that commit we could confirm or rule it out.
@HooglyBoogly could you double check that commit? maybe is a tiny change that caused the overhead and is buried in that refactor?

As for which commit may have caused the regression I can't tell exactly since trying to go back that far in time gives me lots of libraries and dependency errors compiling Blender to effectively triage. The most recent and significant commit in those files has been this refactor from @HooglyBoogly [https://projects.blender.org/blender/blender/commit/488de130b39764b2d8564594fc720aa6159e3f39](url) If someone can test blender before and after that commit we could confirm or rule it out. @HooglyBoogly could you double check that commit? maybe is a tiny change that caused the overhead and is buried in that refactor?
Member

We agreed in the module meeting to use the "Normal" priority for this report, since it's just the first stroke with the issue, and because the issue isn't clear in the code, so it may be best handled as part of general optimization development.

We agreed in the module meeting to use the "Normal" priority for this report, since it's just the first stroke with the issue, and because the issue isn't clear in the code, so it may be best handled as part of general optimization development.
Hans Goudey added
Priority
Normal
and removed
Priority
High
labels 2024-04-30 19:14:37 +02: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
5 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#120593
No description provided.