[racket] TR memory optimization: 240 Bytes of garbage for calling TR?

From: Neil Toronto (neil.toronto at gmail.com)
Date: Sat Nov 10 15:30:18 EST 2012

On 11/10/2012 08:22 AM, John Clements wrote:
> (: comb1 (Float -> Float))
> (define (comb1 in)
>    (define delayed1 (flvector-ref v1 c1))
>    (define midnode1 (fl+ delayed1 (fl* g11 m1)))
>    (define out1 (fl+ (fl* g21 midnode1) in))
>    (flvector-set! v1 c1 out1)
>    (define next-c1 (add1 c1))
>    (set! c1 (cond [(<= d1 next-c1) 0]
>                   [else next-c1]))
>    (set! m1 midnode1)
>    out1)
> I can't see anything in this that would cause allocation.

I'll bet `set!' does it. Also, if `comb1' doesn't get inlined at its 
application sites, I think `in' and `out1' will get boxed.

Neil ⊥

Posted on the users mailing list.