Hi Andy, Andy Wingo <[email protected]> skribis:
> Still, though, the results are not great: [...] > Here we see that `fold' was inlined once, but to no use. More code for > no more speed. Yes. OTOH, it was inlined *and* specialized; peval only “inlines” where’s there’s at least one static argument (known at compile-time), in which case there’s room for specialization (in this example, *, 1, zero?, and the anonymous lambdas were propagated/resolved as primitives.) In the above example, I agree that we can argue that inlining wasn’t useful. > Waddell and Dybvig report on similar problems in their inlining paper > (Fast and Effective Procedure Inlining, IU CS Dept. TR 484). See > section 4.4 where they discuss this and similar problems. We should > figure out what we can do in these cases; and in the case where we can't > fully inline a call site, perhaps we should abort the attempt to inline > it. Right. I think we should avoid inlining when recursive calls appear in the residual code, as mentioned in the referred section. WDYT? Now, the current heuristic in peval is to “inline” procedures only at call sites with static arguments. Conversely, a general procedure inlining algorithm like Waddell’s may inline even when there are only dynamic arguments. This puts more pressure on the inlining criteria because there are many more potential inlining opportunities. I don’t think an optimization heuristic can be optimal in all cases. So the question is not whether we can find such pathological cases, but how frequent they are in practice. So I think we must keep an eye on the optimized code, like you did, to find out more. Thanks for your feedback! Ludo’.
