Skip to content

Object pooling in splitpolygon#1438

Open
jbroll wants to merge 2 commits intojscad:masterfrom
jbroll:pr/upstream-perf-splitpolygon
Open

Object pooling in splitpolygon#1438
jbroll wants to merge 2 commits intojscad:masterfrom
jbroll:pr/upstream-perf-splitpolygon

Conversation

@jbroll
Copy link
Copy Markdown
Contributor

@jbroll jbroll commented Feb 18, 2026

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Does your submission pass tests?

Note: please do NOT include build files (those generate by the build-xxx commands) with your PR,

Thank you for your help in advance, much appreciated !

jbroll and others added 2 commits February 18, 2026 13:03
Reduce allocations in the hot path by pooling:
- Result object (reused between calls)
- vertexIsBack array (pre-allocated, grows as needed)
- frontvertices/backvertices arrays (pre-allocated)

Also internalizes the vertices.length < 3 guard into removeConsecutiveDuplicates
rather than requiring callers to check before calling.

Benchmark results show 63-66% speedup for sphere/torus unions:
- union sphere(16): 12.1ms → 4.5ms
- union sphere(32): 96.1ms → 33.2ms
- union torus(16): 61.9ms → 21.2ms

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Measures performance of the hot-path splitPolygonByPlane function across
coplanar, front-only, back-only, and spanning split cases.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@z3dev
Copy link
Copy Markdown
Member

z3dev commented Feb 19, 2026

@jbroll these are fine but you’ll have to prove there’s a performance benefit. Please run the performance suite, at least for the booleans.

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.

2 participants