trianglewins / benchmark
trianglewins: triangulation at scale
Four constrained Delaunay backends for R on country boundaries from geoBoundaries
(sds::CGAZ()), from Kosovo (23 thousand vertices) to the whole world (6.8 million).
Times are medians of repeated runs, each job in its own R process.
Findings
- Constrained triangulation scales the same way in RTriangle, cdtr and trowel; laridae is now slower. On the polygon datasets up to South America (634 thousand vertices), cdtr is within a factor of 1.5 of RTriangle, and trowel within a factor of 2 up to Canada but 3.2 on South America (6.3 s against 2.0 s). laridae takes 3 to 4 times as long as RTriangle on every polygon dataset (6.1 s on South America), where on 6 October it was within a factor of 1.5. The harness shows the same slowdown on small inputs, most of it in building laridae's output tables. For the whole world (6.8 million vertices, 10.1 million triangles) RTriangle took 23 s, cdtr 50 s, laridae 83 s and trowel 159 s. All four produce the same triangle count on every polygon dataset, as in October.
- trowel slows down sharply on large, unordered input. On a million points it takes 160 s, where the others take 2 to 6 s. Its 100 thousand point run is already 9 to 10 times slower than cdtr and RTriangle.
mesh_new()inserts points one at a time in input order, so spade walks a long way to find each point. laridae had the same problem until it sorted points spatially before inserting them. Sorting the points or using spade's bulk load should close most of the gap. - A live mesh pays off for edits. Adding 1000 points to the South America mesh took 10 ms in laridae and 74 ms in trowel, against 2.0 to 2.2 s to rebuild with those points in RTriangle and cdtr, so a live handle is 30 to 200 times faster. On the world mesh laridae took 0.05 s and trowel 0.40 s, against 22 s (RTriangle) and 42 s (cdtr) for a rebuild.
- cdtr uses the least memory. Peak memory for the world was 2.6 GB for cdtr, 3.1 GB for trowel, 5.6 GB for RTriangle and 6.7 GB for laridae (5.6 GB in October). Inserting into laridae's world mesh peaked at 8.9 GB. These figures include R's own copies of the input and output tables.
- RTriangle is the fastest refiner. Area refinement on South America took 2.1 s in RTriangle, against 3.9 s in cdtr, 8.3 s in trowel and 9.4 s in laridae. On the world it took 24 s, against 64 s (cdtr), 117 s (laridae) and 166 s (trowel). cdtr's gap, 1.9 to 2.7 times, is about the same as on the harness's small inputs. What the others give for the extra time is information about how the mesh relates to its input: depth, the origin of each vertex, the input segments behind each constraint edge, and a report of where refinement stopped. laridae and trowel also give a mesh that can be edited. trowel stalled on southern Africa: it took 11 s, stopped incomplete, and left triangles with a 0 degree minimum angle.
- No backend reaches the quality bound on large coastlines. With a 20 degree minimum angle added, every backend stops short on every dataset from Indonesia (254 thousand vertices) upward, either at the 100 thousand Steiner point budget or at the edge-length floor. Only 9 to 75 percent of triangles meet the angle bound; the 9 percent is trowel on southern Africa, which was the same in October. Quality times on large inputs therefore measure how far each backend gets within that budget, not the cost of finishing.
- Shared borders given twice cost little. southern_africa_rings (every border twice, 475 thousand vertices before merging) took 6 to 19 percent longer than the merged version to triangulate in laridae, cdtr and trowel, and produced the same 475,242 triangles. RTriangle refuses it ("Duplicated vertices in P").
- No timeouts. Every job finished within 900 s and 12 GB, the longest in 543 s. The 4 errors are RTriangle's refusals of duplicated vertices. laridae's world insert first failed under the cap (
std::bad_alloc). The cause was this machine, not laridae: R here links the threaded OpenBLAS, which starts one thread per core in every R process, and on 32 cores they reserve 4.3 GB of address space before anything else is loaded. WithOPENBLAS_NUM_THREADS=1, whichbench/run.Rnow sets for every job, it took 0.05 s and peaked at 8.9 GB resident, as in October. None of the backends uses BLAS, and every other job fitted under the cap.
Time against input size
Seconds (log scale) against input vertices (log scale), polygon datasets only. Constrained: the triangulation of the vertices and segments, outside removed. Area: refined until no triangle exceeds bounding box area / 100000. Quality: the same area bound plus a 20 degree minimum angle. A run that timed out or ran out of memory has no point.
Delaunay of points
Points sampled from the world's boundary vertices, no segments, meshed over their convex hull.
Editing a mesh: 1000 new points
laridae and trowel add 1000 points to a live constrained mesh (only the insert is timed). cdtr and RTriangle have no handle, so the time is a rebuild with the points included.
Peak memory
Peak resident memory of the job's R process (MB, log scale), including the input tables.
All runs
Datasets
Method
Inputs come from sds::CGAZ(), the geoBoundaries CGAZ ADM0 GeoParquet (CC BY 4.0). Rings are converted by
bench/cgaz_pslg.py into a vertex table and a segment table: exactly repeated vertices are merged and repeated
segments dropped, so shared borders appear once (except southern_africa_rings, which keeps every ring in full).
Coordinates are longitude and latitude, triangulated as planar xy (coordinate dimension 2; the output is triangles, topological dimension 2). Each backend is called through the same adapter as the
rest of trianglewins, so times include reading the result tables back into R. Every refinement has a Steiner budget of
100000 vertices. The area and angle columns are computed from the output; segment preservation and the empty-circle test
run on inputs up to 50000 vertices. Code: bench/ in
mdsumner/trianglewins.