Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster Triangulated Grid Generation #131

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

GeorgeR227
Copy link
Contributor

This PR speeds up triangulated_grid generation by around x20 what it was previously and also adds support for Point3{Float32}. The order of the points is preserved from the original but the order of the triangles has changed so that they are added left to right and bottom to top.

The main gain in the speed here was using the order of the triangles to speed up the orientation generation significantly. The bottleneck now is the glue_triangle section which if improved could lead to another magnitude of speedups.

Below are rough benchmarks run on my local machine.

This is a 8 by 8 grid
  Old: 0.002595 seconds (9.40 k allocations: 1.011 MiB)
  New: 0.000109 seconds (1.18 k allocations: 130.406 KiB)
This is a 16 by 16 grid
  Old: 0.004915 seconds (38.88 k allocations: 3.983 MiB)
  New: 0.000340 seconds (4.20 k allocations: 453.703 KiB)
This is a 32 by 32 grid
  Old: 0.019402 seconds (215.87 k allocations: 16.721 MiB)
  New: 0.001193 seconds (15.94 k allocations: 1.592 MiB)
This is a 64 by 64 grid
  Old: 0.242466 seconds (929.23 k allocations: 68.011 MiB, 69.82% gc time)
  New: 0.003419 seconds (62.43 k allocations: 6.659 MiB)
This is a 128 by 128 grid
  Old: 0.695434 seconds (3.78 M allocations: 271.332 MiB, 60.86% gc time)
  New: 0.024708 seconds (247.52 k allocations: 24.528 MiB, 45.29% gc time)
This is a 256 by 256 grid
  Old: 1.458329 seconds (15.19 M allocations: 1.059 GiB, 26.26% gc time)
  New: 0.089756 seconds (986.28 k allocations: 98.278 MiB, 39.19% gc time)
This is a 512 by 512 grid
  Old: 5.390635 seconds (60.81 M allocations: 4.240 GiB, 19.05% gc time)
  New: 0.308000 seconds (3.94 M allocations: 396.969 MiB, 26.11% gc time)

Better generation speed and support for Point3{Float32}. Benchmarks pending.
This test was checking for above 60% of 162 triangles filled the condition, which is 97.2.
@GeorgeR227 GeorgeR227 requested a review from lukem12345 January 24, 2025 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant