Performance: mesh batch cache creation #64261

Open
opened 2019-05-07 18:03:34 +02:00 by Sergey Sharybin · 3 comments

This is a part of performance regression investigation task.

Creation of batch caches for meshes is much more involved than drawing from DerivedMesh. There is no single hotspot. Here is some breakdown on what pops up in profiles.

*_has_visible_e* functions. While it is true that truth is returned on first iteration, those functions does a lot of indirect memory accesses, which has affect on cache coherency., Guess this is why they are quite visible in the profiler.

mesh_render_data_edge_flag. Think this is similar to the case above. But it also does things like BM_edge_in_face() where there will be few iterations, for every edge.

GPU_normal_convert*. This is just a lot of normals to be converted. Making those functions inlined doesn't make visible difference.

In the attached file my computer s[pends 0.3sec in DRW_mesh_batch_cache_create_requested, which is half of the overall time when moving a single vertex.

Possible solution here is to run different stages of DRW_mesh_batch_cache_create_requested() in parallel (should be possible to update vertex buffers in parallel with face buffers i would think).

megaheavy_mesh_edit.blend

This is a part of performance regression investigation task. Creation of batch caches for meshes is much more involved than drawing from DerivedMesh. There is no single hotspot. Here is some breakdown on what pops up in profiles. `*_has_visible_e*` functions. While it is true that truth is returned on first iteration, those functions does a lot of indirect memory accesses, which has affect on cache coherency., Guess this is why they are quite visible in the profiler. `mesh_render_data_edge_flag`. Think this is similar to the case above. But it also does things like `BM_edge_in_face()` where there will be few iterations, for every edge. `GPU_normal_convert*`. This is just a lot of normals to be converted. Making those functions inlined doesn't make visible difference. In the attached file my computer s[pends 0.3sec in `DRW_mesh_batch_cache_create_requested`, which is half of the overall time when moving a single vertex. Possible solution here is to run different stages of `DRW_mesh_batch_cache_create_requested()` in parallel (should be possible to update vertex buffers in parallel with face buffers i would think). [megaheavy_mesh_edit.blend](https://archive.blender.org/developer/F7012934/megaheavy_mesh_edit.blend)
Author
Owner

Added subscriber: @Sergey

Added subscriber: @Sergey

Added subscriber: @fclem

Added subscriber: @fclem

Possible solution here is to run different stages in parallel

Yes! that's why I moved all batch generations to a single function. Only a handfull of functions that use BMesh tagging cannot be parallelized (or they must use own "tag" buffer and maybe that could be even faster).

Maybe some areas can be rewritten to be more data driven (like compression using GPU_normal_convert) but this can use more RAM and i'm not sure how much more beneficial it would be.

>Possible solution here is to run different stages in parallel Yes! that's why I moved all batch generations to a single function. Only a handfull of functions that use BMesh tagging cannot be parallelized (or they must use own "tag" buffer and maybe that could be even faster). Maybe some areas can be rewritten to be more data driven (like compression using GPU_normal_convert) but this can use more RAM and i'm not sure how much more beneficial it would be.
Philipp Oeser removed the
Interest
EEVEE & Viewport
label 2023-02-09 15:15:36 +01: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
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
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#64261
No description provided.