You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The initialization of the Accel2D takes some seconds to complete (4-7) with just 6k faces in the tests performed in 2 different PCs, both with Windows 11, AMD cpu and NVIDIA gpu.
After reviewing the code I've seen there's room for improvements without major changes.
Performance bottlenecks:
As we see in the 'collect' and 'insert verts' sections, we can cache the results of Point_to_Point2Ds for each vertex to avoid repeated calls.
# collect all involved pts so we can find bboxwithtime_it('collect', enabled=Accel2D.DEBUG):
bbox=BBox2D()
withtime_it('collect verts', enabled=Accel2D.DEBUG):
bbox.insert_points(ptforvinvertsforptinPoint_to_Point2Ds(v.co, v.normal))
withtime_it('collect edges and faces', enabled=Accel2D.DEBUG):
bbox.insert_points(
ptforefinchain(edges, faces)
foref_ptsinzip(*[Point_to_Point2Ds(v.co, v.normal) forvinef.verts])
forptinef_pts
)
.........
# inserting vertswithtime_it('insert verts', enabled=Accel2D.DEBUG):
forvinverts:
forptinPoint_to_Point2Ds(v.co, v.normal):
tot_inserted+=1i, j=self.compute_ij(pt)
self._put((i, j), v)
In the 'insert edges and faces', we see the same bottleneck issue, but we can pre-compute the ij coordinates and cache them to avoid extra compute. We can also remove the dedundant BBox2D creation for faces since we can directly compute min/max from the cached ij coordinates, which will speed up the code as well.
Accel2D initilization Bottlenecks
Related issues: #842 - #1246 - #1423
The initialization of the Accel2D takes some seconds to complete (4-7) with just 6k faces in the tests performed in 2 different PCs, both with Windows 11, AMD cpu and NVIDIA gpu.
After reviewing the code I've seen there's room for improvements without major changes.
Performance bottlenecks:
As we see in the 'collect' and 'insert verts' sections, we can cache the results of
Point_to_Point2Ds
for each vertex to avoid repeated calls.In the 'insert edges and faces', we see the same bottleneck issue, but we can pre-compute the ij coordinates and cache them to avoid extra compute. We can also remove the dedundant BBox2D creation for faces since we can directly compute min/max from the cached ij coordinates, which will speed up the code as well.
Implications
Proposed Solution
The text was updated successfully, but these errors were encountered: