No subject

From: ()
Date: Mon Dec 3 19:58:15 EST 2012

because `for/or' expands to a significant pile of code. More
importantly, it turns out that the loop inside `positione-accettabile?'
is unrolled a little (i.e., a recursive call or two is inlined), so
after the unrolling, `sistemabile?' is used in multiple places.

Tuning the inlining heuristics can easily make this kind of program go
faster. Turning the inlining heuristics to make this program go faster
while also not slowing down other programs --- well, that's much more
difficult. Of all the ways that I've worked on the compiler, experiments
with the inlining heuristics have felt particularly unrewarding. :)

For example, it might seem that inlining of recursive calls should be
delayed until after other inlining opportunities, which might give you
more the result that you expect in this case. I've implemented that,
though, and that heuristic is currently disabled, because it doesn't
seem to work better on average.

At Fri, 7 Dec 2012 11:20:12 +0100, Pierpaolo Bernardi wrote:
> I too have a curiosity about inlining.
> 
> In the following fragment of code, all the functions defined are used
> in only one place. Optimization coach says the first and the fourth
> are inlined, but not the others:
> 
> (define (posizione-accettabile? tabella pezzi)
>   (and (for/or ((posizione (in-list le-posizioni)))
>          (or (array-ref tabella (posizione-x posizione) (posizione-y posizione))
>              (copribile? posizione pezzi tabella)))
>        (for/and ((p (in-list pezzi)))
>          (sistemabile? p tabella))))
> 
> (define (sistemabile? pezzo tabella)
>   (for/or ((p (in-list pezzo)))
>     (sistemabile-orientazione? (first p) tabella)))
> 
> (define (sistemabile-orientazione? orientazione tabella)
>   (for/or ((posizione (in-list le-posizioni)))
>     (compatibile? orientazione posizione tabella)))
> 
> (define (copribile? posizione pezzi tabella)
>   (for/or ((pezzo (in-list pezzi)))
>     (copribile-orientazione? posizione pezzo tabella)))
> 
> (define (copribile-orientazione? posizione pezzo tabella)
>   (for/or ((p (in-list pezzo)))
>     (compatibile? (first p) posizione tabella)))
> 
> Naively, I thought this was a no brainer for the inliner: small
> functions, used only once, no complex control flow.  Why does it gives
> up?
> 
> BTW, doing the inlines manually does actually make a difference in the
> total running time, so It would be nice to have this done
> automatically.
> 
> (Attached there's the whole, compilable, program).
> 
> Cheers
> P.


Posted on the users mailing list.