Mesh: Calculate edges with VectorSet instead of Map #120224
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#120224
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "mod_moder/blender:calc_edges_vector_set"
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?
Due to legacy reasons (
MEdge
), edge calculation was being done with idea that edges cannot be temporarily copied.But today, edges are just
int2
, so using ofedge *
instead ofedge
actually made things worst.And since
OrderedEdge
itself is the same thing asint2
, there it does not make sense to useMap
for edges.So, now edges are in a hash set. To be able to take index of edges, vector set is used.
The only functional change now is that original edges will be reordered as well. This should be okay just like
an unintentional but stable indices change, but could be avoided by using weak version of
OrderedEdge
.For 2'000 x 2'000 x 2'000 cube edges calculation, change is around
3703.47
->2911.18
ms.In order to reduce memory usage, a template parameter is added to
VectorSet
slots, so they canuse a 32 instead of 64 bit index type. Without that, the performance change is not consistent and
might not be better on a computer with more memory bandwidth.
Co-authored-by: @HooglyBoogly
I like the code in your PR more, but I can't reproduce the speedup with your
calc_edges_becnh.blend
file (thanks for including that here BTW!)Maybe it's worth trying in intermediate version without the change from
Map
toVectorSet
?Or the problem might be that
VectorSet
usesint64_t
for its indices. Maybe it needs a templatespecialization to use
int
instead for this use case.@ -120,1 +94,3 @@
}
const Span<OrderedEdge> task_edges = edge_map.as_span();
MutableSpan<int2> result_edges = new_edges.slice(edge_offsets[task_index]);
std::transform(task_edges.begin(),
I'd try changing this to
result_edges.copy_from(task_edges.cast<int2>())
Hope
OrderedEdge
will be refactored to be based onBaseVec<int, 2>
to make it more safe.I also noticed some change by this way:
3517.18
->3260.55
ms (befor / after ofcopy_from
).And next, i noticed that test file is 3x faster for you. This leed in less real-world case, but i wonder if proof of performance still can be visible on 3k cuboid resolution (or more).
I check 2.7k (limit that can be holded by my RAM) both main and latest state of pr:
7.1
->6.7
s.It seems i was wrong to point out the performance of this refactoring at the begin, since it mainly legacy reducing, but i still think it would be better if it at least seemed better\
Thanks for benchmark check, i think speed improvement is related with memory bandwidth (less number of pointers, smaller size of value in map/set container, more trivial loops for read/write).
Might this is small enough change to be not visible (just like in #114733) for you on your pc (so not sure how to prove speedup for you then).
Using
int
forSimpleVectorSetSlot
works here and improves the performance for me:main: Timer 'mesh_calc_edges': (Average: 976.20 ms, Min: 955.63 ms, Last: 1002.69 ms)
PR with change: Timer 'mesh_calc_edges': (Average: 902.40 ms, Min: 885.50 ms, Last: 904.97 ms)
I'll share the diff in chat.
I can see
3711.94
->2911.18
ms changes with apply your changes @HooglyBoogly thanks for spending time for this!Refactor: Mesh calculate edges: Use VectorSet instead of Mapto Refactoring: Mesh calculate edges: Use VectorSet instead of MapRefactoring: Mesh calculate edges: Use VectorSet instead of Mapto Mesh: Calculate edges with VectorSet instead of Map