Skip to content

Scanbeam and offsets small optimizations - #1106

Open
avo-uxv wants to merge 3 commits into
AngusJohnson:mainfrom
avo-uxv:clipper-scanbeam-offets-optimizations
Open

Scanbeam and offsets small optimizations#1106
avo-uxv wants to merge 3 commits into
AngusJohnson:mainfrom
avo-uxv:clipper-scanbeam-offets-optimizations

Conversation

@avo-uxv

@avo-uxv avo-uxv commented Jul 29, 2026

Copy link
Copy Markdown

Hi @AngusJohnson,

Here are a couple of small targeted performance improvements, with the ulterior aim of speeding up zone fills in KiCAD (using the C++ version).

  1. Skip intersection sorting when active edges retain their X order at the top of a scanbeam
  2. Reduce allocation and copying while constructing offset paths

Testing
I added some tests for scanbeam and offsets in CPP and C# to test the correctness of these changes. Full disclaimer that I have not tested the delphi version

Benchmarking (CPP only)
Performance was measured with temporary google benchmark workloads comparing this branch against main using GCC release builds and one CPU core.
The workloads covered:

  • Scanbeams with sorted, crossing, and mixed-overlap edges
  • Closed polygons with round joins
  • Open paths with round caps
  • Joined open paths
  • Single-point round offsets
  • Input sizes from 16 to 1024 elements

Overall, Scanbeam workloads improved by approximately 2.2% and offset workloads by 4–7%. Individual offset cases ranged from roughly 0 to 12% faster. Round-cap workloads showed some of the most consistent gains. Memory usage was effectively unchanged in the largest tested workloads.

The benchmarks were used for validation only and are not included in this PR

Looking forward to your feedback.

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