discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Problem with large projects

J
jon
Mon, Jun 15, 2020 7:17 PM

Again, I wonder if this "hack" could be automated so that the OpenSCAD
compiler generated this or reformulated a function without explicit user
intervention.  Or some sort of pre-processor.

Sad that one must even consider this

Jon

On 6/15/2020 10:24 AM, nop head wrote:

I knocked 5 seconds of with this hack:

function shelf_screw_positions() = !is_undef($shelf_screw_positions) ?
$shelf_screw_positions :
let(sw = spine_width(), sd = spine_depth(), bc =
box_intrusion(box_type) + box_bezel_clearance(box_type)) [
    translate([z_axis_x + sw / 2, box_depth / 2 - sd + spine_clearance

  • shelf_boss_r + eps]) * rotate([-90, 0, 90]),
        translate([z_axis_x + sw / 2, box_depth / 2 - shelf_boss_r - eps])
                           * rotate([-90, 0, 90]),

    translate([-box_width / 4,               box_depth / 2])          
                       * rotate([-90, 0,  0]),

    translate([box_width / 2,                box_depth / 2 - bc -
shelf_boss_r - eps])        * rotate([-90, 0, -90]),
    translate([box_width / 2,               -box_depth / 2 + bc +
shelf_boss_r + eps])        * rotate([-90, 0, -90]),

    translate([ 10, -box_depth / 2])                                
 * rotate([-90, 0, 180]),
    translate([-10, -box_depth / 2])                                
 * rotate([-90, 0, 180]),

    translate([-box_width / 2,               box_depth / 2 - bc -
shelf_boss_r - eps])        * rotate([-90, 0, 90]),
    translate([-box_width / 2,              -box_depth / 2 + bc +
shelf_boss_r + eps])        * rotate([-90, 0, 90]),

    translate([z_axis_x - sw / 2, box_depth / 2 - sd + spine_clearance

  • shelf_boss_r + eps]) * rotate([-90, 0, -90]),
        translate([z_axis_x - sw / 2, box_depth / 2 - shelf_boss_r - eps])
                           * rotate([-90, 0, -90]),
    ];

In main.scad I have:
$shelf_screw_positions = shelf_screw_positions();

The end effect is it only gets computed once in main and then any
other call gets the value cached in the $variable.

Again, I wonder if this "hack" could be automated so that the OpenSCAD compiler generated this or reformulated a function without explicit user intervention.  Or some sort of pre-processor. Sad that one must even consider this Jon On 6/15/2020 10:24 AM, nop head wrote: > I knocked 5 seconds of with this hack: > > function shelf_screw_positions() = !is_undef($shelf_screw_positions) ? > $shelf_screw_positions : > let(sw = spine_width(), sd = spine_depth(), bc = > box_intrusion(box_type) + box_bezel_clearance(box_type)) [ >     translate([z_axis_x + sw / 2, box_depth / 2 - sd + spine_clearance > + shelf_boss_r + eps]) * rotate([-90, 0, 90]), >     translate([z_axis_x + sw / 2, box_depth / 2 - shelf_boss_r - eps]) >                        * rotate([-90, 0, 90]), > >     translate([-box_width / 4,               box_depth / 2])           >                        * rotate([-90, 0,  0]), > >     translate([box_width / 2,                box_depth / 2 - bc - > shelf_boss_r - eps])        * rotate([-90, 0, -90]), >     translate([box_width / 2,               -box_depth / 2 + bc + > shelf_boss_r + eps])        * rotate([-90, 0, -90]), > >     translate([ 10, -box_depth / 2])                                 >  * rotate([-90, 0, 180]), >     translate([-10, -box_depth / 2])                                 >  * rotate([-90, 0, 180]), > >     translate([-box_width / 2,               box_depth / 2 - bc - > shelf_boss_r - eps])        * rotate([-90, 0, 90]), >     translate([-box_width / 2,              -box_depth / 2 + bc + > shelf_boss_r + eps])        * rotate([-90, 0, 90]), > >     translate([z_axis_x - sw / 2, box_depth / 2 - sd + spine_clearance > + shelf_boss_r + eps]) * rotate([-90, 0, -90]), >     translate([z_axis_x - sw / 2, box_depth / 2 - shelf_boss_r - eps]) >                        * rotate([-90, 0, -90]), > ]; > > In main.scad I have: > $shelf_screw_positions = shelf_screw_positions(); > > The end effect is it only gets computed once in main and then any > other call gets the value cached in the $variable. >
TP
Torsten Paul
Mon, Jun 15, 2020 7:21 PM

On 15.06.20 21:17, jon wrote:

Again, I wonder if this "hack" could be automated so that
the OpenSCAD compiler generated this or reformulated a
function without explicit user intervention.  Or some sort
of pre-processor.

To me it seems more useful to fix the root cause.

ciao,
Torsten.

On 15.06.20 21:17, jon wrote: > Again, I wonder if this "hack" could be automated so that > the OpenSCAD compiler generated this or reformulated a > function without explicit user intervention.  Or some sort > of pre-processor. To me it seems more useful to fix the root cause. ciao, Torsten.
NH
nop head
Mon, Jun 15, 2020 7:46 PM

Each constant assignment would need to track if its value depended on
special variables or a function that depends on special variables. I
suspect most don't, in which a big optimisation would be to skip
re-evaluating them.

On Mon, 15 Jun 2020 at 20:23, Torsten Paul Torsten.Paul@gmx.de wrote:

On 15.06.20 21:17, jon wrote:

Again, I wonder if this "hack" could be automated so that
the OpenSCAD compiler generated this or reformulated a
function without explicit user intervention.  Or some sort
of pre-processor.

To me it seems more useful to fix the root cause.

ciao,
Torsten.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Each constant assignment would need to track if its value depended on special variables or a function that depends on special variables. I suspect most don't, in which a big optimisation would be to skip re-evaluating them. On Mon, 15 Jun 2020 at 20:23, Torsten Paul <Torsten.Paul@gmx.de> wrote: > On 15.06.20 21:17, jon wrote: > > Again, I wonder if this "hack" could be automated so that > > the OpenSCAD compiler generated this or reformulated a > > function without explicit user intervention. Or some sort > > of pre-processor. > > To me it seems more useful to fix the root cause. > > ciao, > Torsten. > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
J
jon
Mon, Jun 15, 2020 7:50 PM

I only made my [ridiculous] suggestion because I believe that this
performance problem has been present for a long time, implying that
fixing the root cause is not likely in the near term

Jon

On 6/15/2020 3:46 PM, nop head wrote:

Each constant assignment would need to track if its value depended on
special variables or a function that depends on special variables. I
suspect most don't, in which a big optimisation would be to skip
re-evaluating them.

On Mon, 15 Jun 2020 at 20:23, Torsten Paul <Torsten.Paul@gmx.de
mailto:Torsten.Paul@gmx.de> wrote:

 On 15.06.20 21:17, jon wrote:

Again, I wonder if this "hack" could be automated so that
the OpenSCAD compiler generated this or reformulated a
function without explicit user intervention.  Or some sort
of pre-processor.

 To me it seems more useful to fix the root cause.

 ciao,
   Torsten.
I only made my [ridiculous] suggestion because I believe that this performance problem has been present for a long time, implying that fixing the root cause is not likely in the near term Jon On 6/15/2020 3:46 PM, nop head wrote: > Each constant assignment would need to track if its value depended on > special variables or a function that depends on special variables. I > suspect most don't, in which a big optimisation would be to skip > re-evaluating them. > > On Mon, 15 Jun 2020 at 20:23, Torsten Paul <Torsten.Paul@gmx.de > <mailto:Torsten.Paul@gmx.de>> wrote: > > On 15.06.20 21:17, jon wrote: > > Again, I wonder if this "hack" could be automated so that > > the OpenSCAD compiler generated this or reformulated a > > function without explicit user intervention.  Or some sort > > of pre-processor. > > To me it seems more useful to fix the root cause. > > ciao, >   Torsten. >
TP
Torsten Paul
Mon, Jun 15, 2020 8:03 PM

On 15.06.20 21:50, jon wrote:

I only made my [ridiculous] suggestion because I believe
that this performance problem has been present for a long
time, implying that fixing the root cause is not likely
in the near term

I think the chance for a specific issue to be fixed has
not much correlation to how old the issue is.

In my opinion the chances depend on how complicated it seems
to be and/or how difficult it is to reproduce (= anticipated
time needed to get it fixed) and the amount of time and
motivation people have available.

Example with some really nice work:
https://github.com/openscad/openscad/pull/3351

ciao,
Torsten.

On 15.06.20 21:50, jon wrote: > I only made my [ridiculous] suggestion because I believe > that this performance problem has been present for a long > time, implying that fixing the root cause is not likely > in the near term I think the chance for a specific issue to be fixed has not much correlation to how old the issue is. In my opinion the chances depend on how complicated it seems to be and/or how difficult it is to reproduce (= anticipated time needed to get it fixed) and the amount of time and motivation people have available. Example with some really nice work: https://github.com/openscad/openscad/pull/3351 ciao, Torsten.