discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

When modules are cached?

RP
Ronaldo Persiano
Fri, Nov 1, 2019 8:09 PM

I think it needs an answer from one of the developers but my guess is that
2D objects are not cached at all. They live in a world of their own with 64
bit fixed point numbers. Most 2D operations are blindingly fast compared to
the very slow 3D CGAL stuff, so it would normally not give much speed
increase to cache them.

If so, I would expect that bbox0() children() in the following version would
be cached but my tests show the opposite. T() as before.

module complexbbx(p)
intersection(){
render() projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
}

module bbox0()
linear_extrude()
intersection() {
ext = pow(2,16);
hull() {
translate([ ext,    0]) children();
translate([-ext,    0]) children();
}
hull() {
translate([    0, ext]) children();
translate([    0,-ext]) children();
}
}

projection() bbox0() T();
complexbbx([1,1]) T();

> > I think it needs an answer from one of the developers but my guess is that > 2D objects are not cached at all. They live in a world of their own with 64 > bit fixed point numbers. Most 2D operations are blindingly fast compared to > the very slow 3D CGAL stuff, so it would normally not give much speed > increase to cache them. > If so, I would expect that bbox0() children() in the following version would be cached but my tests show the opposite. T() as before. module complexbbx(p) intersection(){ render() projection() bbox0() children(); projection() bbox0() children(); projection() bbox0() children(); projection() bbox0() children(); projection() bbox0() children(); projection() bbox0() children(); projection() bbox0() children(); projection() bbox0() children(); projection() bbox0() children(); } module bbox0() linear_extrude() intersection() { ext = pow(2,16); hull() { translate([ ext, 0]) children(); translate([-ext, 0]) children(); } hull() { translate([ 0, ext]) children(); translate([ 0,-ext]) children(); } } projection() bbox0() T(); complexbbx([1,1]) T();
NH
nop head
Fri, Nov 1, 2019 8:33 PM

Even if bbox was cached you are calling projection many times and it is the
odd one out as it is a very slow CGAL operation but it produces a 2D
results, so perhaps not cached.

On Fri, 1 Nov 2019 at 20:10, Ronaldo Persiano rcmpersiano@gmail.com wrote:

I think it needs an answer from one of the developers but my guess is that

2D objects are not cached at all. They live in a world of their own with 64
bit fixed point numbers. Most 2D operations are blindingly fast compared to
the very slow 3D CGAL stuff, so it would normally not give much speed
increase to cache them.

If so, I would expect that bbox0() children() in the following version would
be cached but my tests show the opposite. T() as before.

module complexbbx(p)
intersection(){
render() projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
projection() bbox0() children();
}

module bbox0()
linear_extrude()
intersection() {
ext = pow(2,16);
hull() {
translate([ ext,    0]) children();
translate([-ext,    0]) children();
}
hull() {
translate([    0, ext]) children();
translate([    0,-ext]) children();
}
}

projection() bbox0() T();
complexbbx([1,1]) T();


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

Even if bbox was cached you are calling projection many times and it is the odd one out as it is a very slow CGAL operation but it produces a 2D results, so perhaps not cached. On Fri, 1 Nov 2019 at 20:10, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > I think it needs an answer from one of the developers but my guess is that >> 2D objects are not cached at all. They live in a world of their own with 64 >> bit fixed point numbers. Most 2D operations are blindingly fast compared to >> the very slow 3D CGAL stuff, so it would normally not give much speed >> increase to cache them. >> > > If so, I would expect that bbox0() children() in the following version would > be cached but my tests show the opposite. T() as before. > > module complexbbx(p) > intersection(){ > render() projection() bbox0() children(); > projection() bbox0() children(); > projection() bbox0() children(); > projection() bbox0() children(); > projection() bbox0() children(); > projection() bbox0() children(); > projection() bbox0() children(); > projection() bbox0() children(); > projection() bbox0() children(); > } > > module bbox0() > linear_extrude() > intersection() { > ext = pow(2,16); > hull() { > translate([ ext, 0]) children(); > translate([-ext, 0]) children(); > } > hull() { > translate([ 0, ext]) children(); > translate([ 0,-ext]) children(); > } > } > > projection() bbox0() T(); > complexbbx([1,1]) T(); > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
RP
Ronaldo Persiano
Fri, Nov 1, 2019 8:48 PM

Even if bbox was cached you are calling projection many times and it is
the odd one out as it is a very slow CGAL operation but it produces a 2D
results, so perhaps not cached.

I checked that the projection of a cube (like bbox0() is) and  the
intersections have a negligible runtime in this case. The repetitive
computation of bbox0() children() (a 3D object) is what is slowing the run.

A simpler and more dramatic case is the following:

module complexbbx3(p)
projection()
intersection(){
render() children();
children();
children();
children();
children();
children();
children();
children();
children();
}

module bbox0()
linear_extrude()
intersection() {
ext = pow(2,16);
hull() {
translate([ ext,    0]) children();
translate([-ext,    0]) children();
}
hull() {
translate([    0, ext]) children();
translate([    0,-ext]) children();
}
}

complexbbx3([1,1])  bbox0() T();

Here, bbox0() T() is a 3D solid, a cube.  complexbbx3(p) applied on a cube
do just the intersection of 9 equal cubes and project it into a square. The
intersection of 9 equal cubes and the (only one) projection have negligible
runtime compared with the bbox0() operation. What the runtimes show is that
the children of  complexbbx3() are evaluated 9 times. So, its children
geometry (a 3D solid) is not cached.

> Even if bbox was cached you are calling projection many times and it is > the odd one out as it is a very slow CGAL operation but it produces a 2D > results, so perhaps not cached. > I checked that the projection of a cube (like bbox0() is) and the intersections have a negligible runtime in this case. The repetitive computation of bbox0() children() (a 3D object) is what is slowing the run. A simpler and more dramatic case is the following: module complexbbx3(p) projection() intersection(){ render() children(); children(); children(); children(); children(); children(); children(); children(); children(); } module bbox0() linear_extrude() intersection() { ext = pow(2,16); hull() { translate([ ext, 0]) children(); translate([-ext, 0]) children(); } hull() { translate([ 0, ext]) children(); translate([ 0,-ext]) children(); } } complexbbx3([1,1]) bbox0() T(); Here, bbox0() T() is a 3D solid, a cube. complexbbx3(p) applied on a cube do just the intersection of 9 equal cubes and project it into a square. The intersection of 9 equal cubes and the (only one) projection have negligible runtime compared with the bbox0() operation. What the runtimes show is that the children of complexbbx3() are evaluated 9 times. So, its children geometry (a 3D solid) is not cached.
NH
nop head
Fri, Nov 1, 2019 8:56 PM

What happens if you put render() linear_extrude() in bbox()?

On Fri, 1 Nov 2019 at 20:49, Ronaldo Persiano rcmpersiano@gmail.com wrote:

Even if bbox was cached you are calling projection many times and it is

the odd one out as it is a very slow CGAL operation but it produces a 2D
results, so perhaps not cached.

I checked that the projection of a cube (like bbox0() is) and  the
intersections have a negligible runtime in this case. The repetitive
computation of bbox0() children() (a 3D object) is what is slowing the run.

A simpler and more dramatic case is the following:

module complexbbx3(p)
projection()
intersection(){
render() children();
children();
children();
children();
children();
children();
children();
children();
children();
}

module bbox0()
linear_extrude()
intersection() {
ext = pow(2,16);
hull() {
translate([ ext,    0]) children();
translate([-ext,    0]) children();
}
hull() {
translate([    0, ext]) children();
translate([    0,-ext]) children();
}
}

complexbbx3([1,1])  bbox0() T();

Here, bbox0() T() is a 3D solid, a cube.  complexbbx3(p) applied on a cube
do just the intersection of 9 equal cubes and project it into a square. The
intersection of 9 equal cubes and the (only one) projection have negligible
runtime compared with the bbox0() operation. What the runtimes show is that
the children of  complexbbx3() are evaluated 9 times. So, its children
geometry (a 3D solid) is not cached.


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

What happens if you put render() linear_extrude() in bbox()? On Fri, 1 Nov 2019 at 20:49, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > > Even if bbox was cached you are calling projection many times and it is >> the odd one out as it is a very slow CGAL operation but it produces a 2D >> results, so perhaps not cached. >> > > I checked that the projection of a cube (like bbox0() is) and the > intersections have a negligible runtime in this case. The repetitive > computation of bbox0() children() (a 3D object) is what is slowing the run. > > A simpler and more dramatic case is the following: > > module complexbbx3(p) > projection() > intersection(){ > render() children(); > children(); > children(); > children(); > children(); > children(); > children(); > children(); > children(); > } > > module bbox0() > linear_extrude() > intersection() { > ext = pow(2,16); > hull() { > translate([ ext, 0]) children(); > translate([-ext, 0]) children(); > } > hull() { > translate([ 0, ext]) children(); > translate([ 0,-ext]) children(); > } > } > > complexbbx3([1,1]) bbox0() T(); > > > Here, bbox0() T() is a 3D solid, a cube. complexbbx3(p) applied on a cube > do just the intersection of 9 equal cubes and project it into a square. The > intersection of 9 equal cubes and the (only one) projection have negligible > runtime compared with the bbox0() operation. What the runtimes show is that > the children of complexbbx3() are evaluated 9 times. So, its children > geometry (a 3D solid) is not cached. > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
RP
Ronaldo Persiano
Fri, Nov 1, 2019 9:07 PM

What happens if you put render() linear_extrude() in bbox()?

Sorry but my last tests were wrong. It seems that the geometry of bbox0()
T() is really cached. That is, it seems that only 3D geometry are cached,
what is a shame.

> > What happens if you put render() linear_extrude() in bbox()? > Sorry but my last tests were wrong. It seems that the geometry of bbox0() T() is really cached. That is, it seems that only 3D geometry are cached, what is a shame.
W
wellidontknow@gmx.net
Fri, Nov 1, 2019 10:12 PM

Hey, sorry if it says so somewhere, I haven't sen it - but can I change my subscription to this list somewhere to send daily digests instead of dozens of mails a day?

MM
Michael Marx
Fri, Nov 1, 2019 11:36 PM

http://lists.openscad.org/mailman/options/discuss_lists.openscad.org

There is a link in the first pinned post on the Forum.


From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of wellidontknow@gmx.net
Sent: Sat, 2 Nov 2019 09:12
To: discuss@lists.openscad.org
Subject: [OpenSCAD] Change mailing to daily digest?

Hey, sorry if it says so somewhere, I haven't sen it - but can I change my subscription to this
list somewhere to send daily digests instead of dozens of mails a day?

--
This email has been checked for viruses by AVG.
https://www.avg.com

http://lists.openscad.org/mailman/options/discuss_lists.openscad.org There is a link in the first pinned post on the Forum. _____ From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of wellidontknow@gmx.net Sent: Sat, 2 Nov 2019 09:12 To: discuss@lists.openscad.org Subject: [OpenSCAD] Change mailing to daily digest? Hey, sorry if it says so somewhere, I haven't sen it - but can I change my subscription to this list somewhere to send daily digests instead of dozens of mails a day? -- This email has been checked for viruses by AVG. https://www.avg.com