Here are some micro benchmarks that demonstrate big gains of OpenSCAD rendering with --enable=fast-csg
(a feature I developed in this pull request).
Note: some (but not all) models making heavy use of minkowski may be slower with the feature enabled, as CGALUtils::applyMinkowski is forcing conversions to the old nef format. I hope to address that + publish benchmarks involving minkowski operations soon!*
Note2: these figures need updating, lots of changes since last time I tested these files! Most notably, I'm now proactively falling back to Nef computations in many cases that could have been handled by fast PMP operations on surface meshes, just by fear of hitting corner cases that might corrupt the data. Makes things slower :-(
- uncacheable-grid.scad (see below): 35sec -> 1.5sec (31x faster)
- chainmail.scad (see below): 24min 15sec -> 4min 27sec (5x faster)
- spheres_nested_for_loops.scad (see below): 44sec -> 0.42sec (104x faster)
- spheres_single_for_loop.scad (see below): 48sec -> 0.33sec (146x faster)
- cube-with-half-spheres-dents.scad (see below): 3min 32sec -> 1.2sec (178x faster)
- spheres-grid.scad (see below): 188sec -> 1.1sec (170x faster)
- spheres-grid.scad
-Doverlap=true
(see below): 206sec -> 2.2sec (93x faster) - scalemail.scad
-Duse_sweep=true
: 39sec -> 1.5sec (27x faster) - Bricks benchmark: 61sec -> 0.6s (108x faster)
- maze.scad: ? (more than 10 hours) -> 5min15 (!)
- testdata/scad/issues/issue2342.scad: 3hours 30min -> 17min 26sec (12x faster); Note that lazy-union does better here, but this is a weird test anyway.
- menger.scad: todo
- Cyclone.scad: todo
Note that in almost all these examples, lazy-union
makes things slower when combined with fast-csg
(tested combinations of features, see results here)
To reproduce these figures / test your own files:
- Get OpenSCAD w/ the fast-csg feature (in the GUI, enable
fast-csg
from the settings; in command line just add--enable=fast-csg
): two options:- Download a prebuilt image from openscad/openscad#3641 (see continuous integration, e.g. Linux AppImage, Windows 32bits or Windows 64bits)
- Build from sources: see full instructions here, but you'll need to clone my repo and use the right branch to get the feature, which is under review:
git clone https://github.com/ochafik/openscad ochafik-openscad cd openscad-ochafik git checkout fast-csg-exact-callbacks
- Clone this gist and a couple of helper repositories, set the
OPENSCAD
environment variable to the executable withfast-csg
support and run the benchmarks script:export OPENSCAD=$PWD/OpenSCAD.app/Contents/MacOS/OpenSCAD # export OPENSCAD=$PWD/openscad git clone https://github.com/openscad/scad-utils git clone https://github.com/openscad/list-comprehension-demos # Allows importing sweep.scad export OPENSCADPATH=$PWD:$OPENSCADPATH git clone https://gist.github.com/ochafik/2db96400e3c1f73558fcede990b8a355 openscad-fast-csg-benchmarks cd openscad-fast-csg-benchmarks ./benchmark.sh $OPENSCAD local *.scad
- Note that 4 benchmarks are run in parallel so make sure you have a fast hard drive and cores to spare. You can run the benchmark multiple times to get less noisy data.
- You'll get a
benchmark_results/benchmark_results.tsv
file you can import in any spreadsheet software to do stats over the various runs (example here), and abenchmark_results/output
folder with full logs + output STL files to inspect visually)
Please report any success / failures on the PR!
Hello @ochafik , thank you for this writeup. I'm curious if you would still recommend checking out your specific branch, given it is a couple of years behind openscad master?