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
There is a significant performance regression in the @turf/union module when upgrading from version 7.1.0 to 7.2.0. Union operations are more than 10 times slower in 7.2.0.
Reproduction Steps
Create a test file (e.g., test-union.js) with the following content:
import { circle } from '@turf/circle';
import { featureCollection } from '@turf/helpers';
import { union } from '@turf/union';
const circles = [];
for (let i = 0; i < 1000; i++) {
circles.push(circle([i * 0.1, 0], 200));
}
console.time('union');
union(featureCollection(circles));
console.timeEnd('union');
Install Dependencies with v7.1.0: npm install @turf/circle @turf/helpers @turf/[email protected]
Run the test file: node test-union.js
Observe the timing output (around 500 ms).
Upgrade to version 7.2.0: npm install @turf/[email protected]
Run the test file again: node test-union.js
Note the increased timing output (around 5.5 s).
Expected Behavior:
The union operation should complete in a similar timeframe across these minor versions (around 500 ms for the provided test).
Observed Behavior:
• v7.1.0: ~500 ms
• v7.2.0: ~5.5 s
This performance degradation is critical, especially for workflows involving large numbers of geometries.
Additional Context:
This slowdown might be due to changes in the union implementation or dependencies in v7.2.0. Any investigation or fixes to address this regression would be greatly appreciated.
The text was updated successfully, but these errors were encountered:
Just looking to confirm that this is due to the change to polyclip-ts. Running the bechmarks from that repo (modified to also include the old polygon-clipping library), polyclip-ts is pretty much always behind by an order of magnitude, if not worse.
Hole_Hole
polyclip-ts x 1,327 ops/sec ±0.47% (96 runs sampled)
w8r x 69,672 ops/sec ±0.30% (98 runs sampled)
JSTS x 7,563 ops/sec ±0.75% (98 runs sampled)
polygon-clipping x 21,782 ops/sec ±0.22% (99 runs sampled)
- Fastest is w8r
Asia union
polyclip-ts x 2.37 ops/sec ±1.13% (10 runs sampled)
w8r x 19.85 ops/sec ±1.99% (37 runs sampled)
JSTS x 27.36 ops/sec ±1.24% (49 runs sampled)
polygon-clipping x 14.31 ops/sec ±2.57% (40 runs sampled)
- Fastest is JSTS
States clip
polyclip-ts x 30.90 ops/sec ±1.03% (55 runs sampled)
w8r x 422 ops/sec ±0.28% (94 runs sampled)
JSTS x 336 ops/sec ±0.63% (90 runs sampled)
polygon-clipping x 333 ops/sec ±0.45% (90 runs sampled)
- Fastest is w8r
Based on what I can see on that repo, it's implied their results are at least the most correct, at least compared to the library its based on, but the drop in performance to achieve this (if it is the case) seems really unfortunate.
Fortunately, the turf methods that use this are relatively thin wrappers around the underlying library, so duplicating the old 7.1 version (or just installing it separately) is pretty doable (ignoring the negative effect on bundle size that might have if that matters for your use case)
There is a significant performance regression in the @turf/union module when upgrading from version 7.1.0 to 7.2.0. Union operations are more than 10 times slower in 7.2.0.
Reproduction Steps
Install Dependencies with v7.1.0:
npm install @turf/circle @turf/helpers @turf/[email protected]
Run the test file:
node test-union.js
Observe the timing output (around 500 ms).
Upgrade to version 7.2.0:
npm install @turf/[email protected]
Run the test file again:
node test-union.js
Note the increased timing output (around 5.5 s).
Expected Behavior:
The union operation should complete in a similar timeframe across these minor versions (around 500 ms for the provided test).
Observed Behavior:
• v7.1.0: ~500 ms
• v7.2.0: ~5.5 s
This performance degradation is critical, especially for workflows involving large numbers of geometries.
Environment:
• Node.js version: 22
• OS: macOS, Ubuntu
Additional Context:
This slowdown might be due to changes in the union implementation or dependencies in v7.2.0. Any investigation or fixes to address this regression would be greatly appreciated.
The text was updated successfully, but these errors were encountered: