being the culprit
With the gc3:
f1 =: 3 : '(>: each)^:(<y) (<0)'
(6!:2) 'f1 100000'
33.0624
Without it
(6!:2) 'f1 100000'
0.272726
It still works:
f1 5
+-+-+-+-+-+
|0|1|2|3|4|
+-+-+-+-+-+
Why is it doing this operation (garbage collection?) every 10 loops
https://github.com/jsoftware/jsource/blob/e68277f408433fe34fd31f0161a31c
96d9ccb44e/jsrc/cp.c#L97
Can anyone elaborate on this? Is the 10 count too frequent?
Repeatedly running f1 100000 does not result in a memory leak as far as
I can tell.
cp.c
static DF1(jtply1){PROLOG(0040);DECLFG;A b,hs,j,x,*xv,y,z;B*bv,q;I
i,k,m,n,*nv,old,p=0;
hs=sv->h; m=AN(hs);
RZ(x=ravel(hs)); RZ(y=from(j=grade1(x),x)); nv=AV(y);
GATV(x,BOX,m,1,0); xv=AAV(x);
while(p<m&&0>nv[p])p++;
if(p<m){
RZ(z=ca(w));
n=nv[m-1]; k=p;
while(k<m&&!nv[k]){xv[k]=z; ++k;}
RZ(b=eq(ainf,from(j,ravel(gs)))); bv=BAV(b); q=k<m?bv[k]:0;
old=jt->tnextpushx;
for(i=1;i<=n;++i){
RZ(z=CALL1(f1,y=z,fs));
if(q&&equ(y,z)){DO(m-k, xv[k]=z; ++k;); break;}
while(k<m&&i==nv[k]){xv[k]=z; ++k; q=k<m?bv[k]:0;}
if(!(i%10))gc3(x,z,0L,old);
}}
if(0<p){
RZ(fs=inv(fs)); f1=VAV(fs)->f1;
RZ(z=ca(w));
n=nv[0]; k=p-1;
RZ(b=eq(scf(-inf),from(j,ravel(gs)))); bv=BAV(b); q=bv[k];
old=jt->tnextpushx;
for(i=-1;i>=n;--i){
RZ(z=CALL1(f1,y=z,fs));
if(q&&equ(y,z)){DO(1+k, xv[k]=z; --k;); break;}
while(0<=k&&i==nv[k]){xv[k]=z; --k; q=0<=k?bv[k]:0;}
# ----------------> if(!(i%10))gc3(x,z,0L,old);
}}
z=ope(reshape(shape(hs),from(grade1(j),x))); EPILOG(z);
}
void jtgc3(J jt,A x,A y,A z,I old){
if(x)ra(x); if(y)ra(y); if(z)ra(z);
tpop(old);
if(x)tpush(x); if(y)tpush(y); if(z)tpush(z);
}
---------- Forwarded message ----------
From: Joe Bogner <joebog...@gmail.com>
Date: Tue, Jan 10, 2017 at 6:26 PM
Subject: Re: ^: slowness with boxes
To: programm...@jsoftware.com
For a little more color: previous discussion: http://www.jsoftwa
re.com/pipermail/programming/2014-March/035994.html
I'm going to switch back to using i. for this
On Tue, Jan 10, 2017 at 6:15 PM, Joe Bogner <joebog...@gmail.com> wrote:
Looks like it is due to the boxing. Please disregard
http://code.jsoftware.com/wiki/Vocabulary/comma#dyadic mentions that
append in place special code does not work for boxes
f4 =: 3 : 0
a=:a:
for_n. (i. y) do. a=:a,(<n) end.
)
(6!:2) 'f4 100'
0.000336555
(6!:2) 'f4 1000'
0.0149772
(6!:2) 'f4 10000'
0.667025
(6!:2) 'f4 20000'
2.69115
(6!:2) 'f4 100000'
170.261
On Tue, Jan 10, 2017 at 5:26 PM, Joe Bogner <joebog...@gmail.com>
wrote:
Why are these so different in execution speed? I'm surprised assembling
that linking boxes makes that much of a difference over an number. I
need
it to be boxed because I'm going to something more complex with each
iteration.
f1 =: 3 : '(>: each)^:(<y) (<0)'
(6!:2) 'f1 100'
6.01622e_5
(6!:2) 'f1 1000'
0.0012719
(6!:2) 'f1 10000'
0.145702
(6!:2) 'f1 100000'
33.0624
f2 =: 3 : '(>:)^:(<y) (0)'
(6!:2) 'f2 100'
4.24675e_5
(6!:2) 'f2 1000'
0.000189688
(6!:2) 'f2 10000'
0.00180487
(6!:2) 'f2 100000'
0.0256836
I'm thinking of using ^: to execute something N times with an
increasing
argument.
I could use i. but wanted to try something different
JVERSION
Engine: j805/j64/windows
Release: commercial/2016-12-11T08:02:16
Library: 8.05.11
Qt IDE: 1.5.3s/5.6.2
Platform: Win 64
Installer: J805 install
InstallPath: c:/program files/j64-805
Contact: www.jsoftware.com
----------------------------------------------------------------------