Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!utnut!cs.utexas.edu!math.ohio-state.edu!uunet.ca!canrem!vef!uunorth!torsqnt!jtsv16!itcyyz!yrloc!rbe
From: rbe@yrloc.ipsa.reuter.COM (Robert Bernecky)
Subject: Re: Implementation of forks in C
Message-ID: <1993Jun2.201418.21584@yrloc.ipsa.reuter.COM>
Reply-To: rbe@yrloc.ipsa.reuter.COM (Robert Bernecky)
Organization: Snake Island Research Inc, Toronto
References: <1993May28.040559.24278@csus.edu> <1738@kepler1.rentec.com>
Date: Wed, 2 Jun 93 20:14:18 GMT
Lines: 46

In article <1738@kepler1.rentec.com> andrew@rentec.com (Andrew Mullhaupt) writes:
>In article <1993May28.040559.24278@csus.edu> vpcsc4@sfsuvax1.sfsu.edu (Emmett McLean) writes:
>>
>>Notice that translating code from J to C (but using
>>the J functions in the source) does not guarantee
>>improved performance.
>
>
>The days where charges of "interpretive overhead" stuck to interpreters
>should be long over. A good interpreter should do all its primitives
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Well, that ain't so, Andrew. The interpretive overhead of even the
best interpreters is still there, but you see it when you are working
on SMALL arguments, not large ones. 

It's like certain vector processors, which have a VERY high startup
cost which is then amortized over a large number of elements.
These machines (and interpreters for APL,J, etc) work great on
large arguments, and lousy on small ones. 

That overhead is spent doing things like:
    a. comformability checking: In A+B, are the arrays the same shape,
       or is one of them a singleton or scalar?
    b. type checking: in A+B, are the types of A and B suitable to +?
    c. Execution routine picking: In A+B, we need to choose a 
       "worse case" routine for addition. I.e., if A is integer,
       and B is complex, we need a complex + routine, and an integer
       to complex fetch code for A.
    d. Storage management: Get space for result of A+B, and when
       done, if A or B was a temporary (say, the result of iota 5),
       free up the storage used by that temp.

Even the best interpreter code isn't going to remove these sorts of
overheads. The only way to remove them effectively is to compile the
code, or to perform enough static analysis that you're effectively
doing a compile anyway.

Bob


Robert Bernecky      rbe@yrloc.ipsa.reuter.com  
Snake Island Research Inc  (416) 203-0854 
18 Fifth Street, Ward's Island
Toronto, Ontario M5J 2B9 
Canada
