kennetek / gridfinity-rebuilt-openscad

A ground-up rebuild of the stock gridfinity bins in OpenSCAD
Other
1.15k stars 166 forks source link

improve performance #75

Closed Ruudjhuu closed 1 year ago

Ruudjhuu commented 1 year ago

I noticed the performance of the rendering in preview mode with default values was lacking, even with fast csg. The generation of a 5x5 bin took more than a minute. 20 x 20 base plates was a no go without crashing (I am not able to print it anyway :)).

When measuring the performance, I started rendering with a 1x1 grid and changed it to 5x5 without closing the UI. I managed to cut the time of a 5x5 bin by ~90%.

There are more ways to improve performance, but this is the biggest one which will have impact on every rebuild model (except for vase mode as it does not need a lot of base grids)

The changes in this pull request (first commit) have improved the performance as following

generate bin before change 1x1 to 5x5

OpenSCAD 2023.01.25 https://www.openscad.org/

Copyright (C) 2009-2022 The OpenSCAD Developers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Loaded design '/home/ruud/git/gridfinity-rebuilt-openscad-kennetek/gridfinity-rebuilt-bins.scad'. Compiling design (CSG Tree generation)... Compiling design (CSG Products generation)... Geometries in cache: 109 Geometry cache size in bytes: 1261752 CGAL Polyhedrons in cache: 18 CGAL cache size in bytes: 682464 Compiling design (CSG Products normalization)... Normalized tree has 14 elements! Compile and preview finished. Total rendering time: 0:00:04.466 Loaded design '/home/ruud/git/gridfinity-rebuilt-openscad-kennetek/gridfinity-rebuilt-bins.scad'. Compiling design (CSG Tree generation)... Compiling design (CSG Products generation)... Geometries in cache: 191 Geometry cache size in bytes: 9575512 CGAL Polyhedrons in cache: 84 CGAL cache size in bytes: 15576760 Compiling design (CSG Products normalization)... Normalized tree has 16 elements! Compile and preview finished. Total rendering time: 0:01:06.791

generate bin after change 1x1 to 5x5

OpenSCAD 2023.01.25 https://www.openscad.org/

Copyright (C) 2009-2022 The OpenSCAD Developers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Loaded design '/home/ruud/git/gridfinity-rebuilt-openscad/gridfinity-rebuilt-bins.scad'. Compiling design (CSG Tree generation)... Compiling design (CSG Products generation)... Geometries in cache: 109 Geometry cache size in bytes: 1261752 CGAL Polyhedrons in cache: 14 CGAL cache size in bytes: 437312 Compiling design (CSG Products normalization)... Normalized tree has 14 elements! Compile and preview finished. Total rendering time: 0:00:04.348 Loaded design '/home/ruud/git/gridfinity-rebuilt-openscad/gridfinity-rebuilt-bins.scad'. Compiling design (CSG Tree generation)... Compiling design (CSG Products generation)... Geometries in cache: 190 Geometry cache size in bytes: 2483360 CGAL Polyhedrons in cache: 17 CGAL cache size in bytes: 443584 Compiling design (CSG Products normalization)... Normalized tree has 64 elements! Compile and preview finished. Total rendering time: 0:00:05.976

generate baseplate before change 1x1 to 5x5

OpenSCAD 2023.01.25 https://www.openscad.org/

Copyright (C) 2009-2022 The OpenSCAD Developers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Loaded design '/home/ruud/git/gridfinity-rebuilt-openscad-kennetek/gridfinity-rebuilt-baseplate.scad'. Compiling design (CSG Tree generation)... Compiling design (CSG Products generation)... Geometries in cache: 30 Geometry cache size in bytes: 204504 CGAL Polyhedrons in cache: 6 CGAL cache size in bytes: 84336 Compiling design (CSG Products normalization)... Normalized tree has 44 elements! Compile and preview finished. Total rendering time: 0:00:00.207 Loaded design '/home/ruud/git/gridfinity-rebuilt-openscad-kennetek/gridfinity-rebuilt-baseplate.scad'. Compiling design (CSG Tree generation)... Compiling design (CSG Products generation)... Geometries in cache: 39 Geometry cache size in bytes: 1430944 CGAL Polyhedrons in cache: 38 CGAL cache size in bytes: 2218960 Compiling design (CSG Products normalization)... Normalized tree has 1028 elements! Compile and preview finished. Total rendering time: 0:00:05.843

generate baseplate after change 1x1 to 5x5

OpenSCAD 2023.01.25 https://www.openscad.org/

Copyright (C) 2009-2022 The OpenSCAD Developers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Loaded design '/home/ruud/git/gridfinity-rebuilt-openscad/gridfinity-rebuilt-baseplate.scad'. Compiling design (CSG Tree generation)... Compiling design (CSG Products generation)... Geometries in cache: 36 Geometry cache size in bytes: 546544 CGAL Polyhedrons in cache: 13 CGAL cache size in bytes: 464184 Compiling design (CSG Products normalization)... Normalized tree has 4 elements! Compile and preview finished. Total rendering time: 0:00:01.262 Loaded design '/home/ruud/git/gridfinity-rebuilt-openscad/gridfinity-rebuilt-baseplate.scad'. Compiling design (CSG Tree generation)... Compiling design (CSG Products generation)... Geometries in cache: 44 Geometry cache size in bytes: 576192 CGAL Polyhedrons in cache: 13 CGAL cache size in bytes: 464184 Compiling design (CSG Products normalization)... Normalized tree has 52 elements! Compile and preview finished. Total rendering time: 0:00:00.289